From 96f7a2e9c422bad71a34f1d5f292f809452d60d1 Mon Sep 17 00:00:00 2001 From: Robert Date: Tue, 11 Aug 2020 11:09:11 +0200 Subject: [PATCH] Added search command --- bot.py | 9 +++++++++ cogs/search.py | 18 ++++++++++++++++++ 2 files changed, 27 insertions(+) create mode 100644 cogs/search.py diff --git a/bot.py b/bot.py index 83aba1f..8a94f91 100644 --- a/bot.py +++ b/bot.py @@ -1,7 +1,16 @@ import discord from discord.ext import commands from utils import config +import os bot = commands.Bot(config.get("prefix")) +@bot.event +async def on_ready(): + print("Loading cogs...", end=" ", flush=True) + for file in os.listdir("./cogs"): + if file.endswith(".py"): + bot.load_extension(f"cogs.{file[:-3]}") + print("Done!") + bot.run(config.get("token")) \ No newline at end of file diff --git a/cogs/search.py b/cogs/search.py new file mode 100644 index 0000000..1815c87 --- /dev/null +++ b/cogs/search.py @@ -0,0 +1,18 @@ +import discord +from discord.ext import commands + +class Search(commands.Cog): + def __init__(self, bot: commands.Bot): + self.bot = bot + + @commands.command(name="search", description="Searches Jisho", usage="", aliases=["s"]) + @commands.cooldown(1, 5) + async def search(self, ctx: commands.Context, *, query: str = None): + if query == None: + return + + await ctx.send(query) + + +def setup(bot: commands.Bot): + bot.add_cog(Search(bot)) \ No newline at end of file