@bot.listen() not doing anything #6367
-
I'm running this code, and its supposed to delete what a user says and have my bot say it with certain stuff around it. @bot.listen()
async def on_message(message):
channel = bot.get_channel(channel I want)
author = message.author
if author == user id:
await channel.delete_message(message)
await channel.send(f"A Message!?,\n"
f"It reads: {message.content}")
else:
return and its not throwing any errors, and when that user says something, the bot does nothing at all. Win 10, py 3.8 |
Beta Was this translation helpful? Give feedback.
Replies: 4 comments
-
There are a few issues with this code as-is.
|
Beta Was this translation helpful? Give feedback.
-
Here: https://stackoverflow.com/questions/42182243/deleting-user-messages-in-discord-py |
Beta Was this translation helpful? Give feedback.
-
also, I think it might be |
Beta Was this translation helpful? Give feedback.
-
I think you're looking for discord.TextChannel.delete_messages. |
Beta Was this translation helpful? Give feedback.
There are a few issues with this code as-is.
author
is of typediscord.Member
(ordiscord.User
). You cannot compare this to a numeric ID. If you want to compare it with an ID you need to doauthor.id == 123456...
delete_message
in any channel class.