JMK OS
JMK OS

Reputation: 3

Discord.py bot.send_message() does not go to the channel it has been called at

I have made a Discord.py Discord bot called JMKBot (version 4.0). When I use the bot.say() function, it says it wherever the user called it, for example

@bot.command()
async def example():
    bot.say("example")
    print("example command run!")

will say it in the same channel where I call >example.

But bot.send_message() requires a destination variable, and I cannot make it automatically go to the channel the command was called at.

How would I make the destination variable go to the channel the command was called at?

Upvotes: 0

Views: 545

Answers (1)

Patrick Haugh
Patrick Haugh

Reputation: 61052

@bot.command(pass_context=True)
async def example(ctx):
    await bot.send_message(ctx.message.channel, 'Example')

Pass the context into the command and then get the channel from the message attribute.

Upvotes: 1

Related Questions