Nikos
Nikos

Reputation: 125

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,):

Upvotes: 2

Views: 564

Answers (1)

Alpha
Alpha

Reputation: 329

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 :)

Upvotes: 2

Related Questions