Sfoglia il codice sorgente

Outsourced the greet command into a cogs file. Changes module name of the say cog.

BaumSplitter41 4 mesi fa
parent
commit
a5f20262f1
3 ha cambiato i file con 23 aggiunte e 9 eliminazioni
  1. 21 0
      VPD_BOT/cogs/greet.py
  2. 2 2
      VPD_BOT/cogs/say.py
  3. 0 7
      VPD_BOT/main.py

+ 21 - 0
VPD_BOT/cogs/greet.py

@@ -0,0 +1,21 @@
+import discord
+from discord.ext import commands
+from discord.commands import Option
+from discord.commands import slash_command
+import os
+from dotenv import load_dotenv
+
+class greet(commands.Cog):
+    def __init__(self, bot: discord.Bot):
+        self.bot = bot
+
+
+
+#Command initialization
+    @slash_command(description="Greet a User")
+    async def greet(self, ctx, user: str = Option(discord.User, "The user, you want to greet")):
+        await ctx.respond(f"Hello {user.mention}")
+
+
+def setup(bot: discord.Bot):
+    bot.add_cog(greet(bot))

+ 2 - 2
VPD_BOT/cogs/say.py

@@ -5,7 +5,7 @@ from discord.commands import slash_command
 import os
 from dotenv import load_dotenv
 
-class Say(commands.Cog):
+class say(commands.Cog):
     def __init__(self, bot: discord.Bot):
         self.bot = bot
 
@@ -25,4 +25,4 @@ class Say(commands.Cog):
 
 
 def setup(bot: discord.Bot):
-    bot.add_cog(Say(bot))
+    bot.add_cog(say(bot))

+ 0 - 7
VPD_BOT/main.py

@@ -172,13 +172,6 @@ async def on_ready():
 #DONT Touch anything above this line, unless you know what you are doing!#
 #---------------------------------------------------------------------------------------#
 
-#---------------------------------#
-## Greet
-@bot.slash_command(description="Greet a User")
-async def greet(ctx, user: str = Option(discord.User, "The user, you want to greet")):
-    await ctx.respond(f"Hello {user.mention}")
-#---------------------------------#
-
 #_________________________________#
 #BAN SYSTEM