say.py 765 B

1234567891011121314151617181920212223
  1. import discord
  2. from discord.ext import commands
  3. from discord.commands import Option
  4. from discord.commands import slash_command
  5. class Say(commands.Cog):
  6. def __init__(self, bot: discord.Bot):
  7. self.bot = bot
  8. @slash_command(description="Let the bot send a message")
  9. async def say(
  10. ctx,
  11. text: str = Option(description="Input the text you want to send"),
  12. channel_input: discord.TextChannel = Option(description="Select the channel,where you want to send the message.")
  13. ):
  14. channel= discord.utils.get(ctx.guild.channels, id = int(channel_input[2:-1]))
  15. await channel.send(text)
  16. await ctx.respond("Message sent", ephemeral=True)
  17. def setup(bot: discord.Bot):
  18. bot.add_cog(Say(bot))