简体   繁体   中英

how can i make my discord.py bot send a message i choose to a channel i choose?

so I'm trying to build a command where you say like;say #channel hi and it sends the channel the message.

@commands.command()
@commands.has_permissions(manage_channels=True)
async def say(self,):

You can do something like this:

@commands.command()
@commands.has_permissions(manage_channels=True)
async def say(self, channel: discord.TextChannel = None, *, message):
    await channel.send(message)

Where the channel is your server's text channel you want to send the message to.Also as you can see I use a * in the command.This means that you can write more than one word as a message:)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM