I am trying to send discord message to channel using python bot, but when I print it's author, it's me and not the bot. So later I can't edit it because of the author.
How can I send message as the bot?
My function:
@bot.command(name="send")
async def send(ctx: Context) -> None:
message = "message"
await ctx.channel.send(message)
print(ctx.message.author)
Because ctx.message
is the message that invoked the command, not the message sent by the bot... So ctx.message.author
is the person that invoked the command, which is you.
print(ctx.message.author) # <- "print the author of the message that invoked this command"
When you use Messageable.send()
, it returns the message it sent. Thus, ctx.channel.send()
returns the message that it sends. The .author
of that message is your bot, and that is the message you can edit.
message = await ctx.channel.send("something")