Procházet zdrojové kódy

added /say as cog module

BaumSplitter41 před 4 měsíci
rodič
revize
0f48e4046d
2 změnil soubory, kde provedl 19 přidání a 2 odebrání
  1. 17 0
      VPD_BOT/cogs/say.py
  2. 2 2
      VPD_BOT/main.py

+ 17 - 0
VPD_BOT/cogs/say.py

@@ -0,0 +1,17 @@
+import discord
+from discord.ext import commands
+from discord.commands import Option
+from discord.commands import slash_command
+
+
+class Base(commands.Cog):
+    def __init__(self, bot: discord.Bot):
+        self.bot = 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}")
+
+
+def setup(bot: discord.Bot):
+    bot.add_cog(Base(bot))

+ 2 - 2
VPD_BOT/main.py

@@ -177,7 +177,7 @@ async def greet(ctx, user: str = Option(discord.User, "The user, you want to gre
 
 #---------------------------------#
 ## Say
-@bot.slash_command(description="Let the bot send a message")
+"""@bot.slash_command(description="Let the bot send a message")
 async def say(
         ctx,
         text: str = Option(description="Input the text you want to send"),
@@ -185,7 +185,7 @@ async def say(
 ):  
     channel= discord.utils.get(ctx.guild.channels, id = int(channel_input[2:-1]))
     await channel.send(text)
-    await ctx.respond("Message sent", ephemeral=True)
+    await ctx.respond("Message sent", ephemeral=True)"""
 #---------------------------------#
 
 #---------------------------------#