Reputation: 55
StackOverflow community. I am making a trivia command on my discord fun bot.
I want it to delete the messages it sends when the game is over.
I wanna do this by adding all the message objects to a list then deleting all of them at the end of the command.
I know you can iterate through the list then deleting them 1 by 1, but I am very scared of rate limitations. Is there a way to delete lists of messages in just 1 API call?
Thank you in advance!
Upvotes: 1
Views: 134
Reputation: 131
You could use this: https://discordpy.readthedocs.io/en/latest/api.html#discord.TextChannel.delete_messages
await TextChannel.delete_messages(messages)
Another option is that if you know the maximum time of a trivia game, you can use delete_after
kwarg in send():
https://discordpy.readthedocs.io/en/latest/api.html#discord.abc.Messageable.send
await Messageable.send('content', delete_after=SECONDS)
If I recall correctly, discord.py handles the ratelimits for you, so you shouldn't worry much. (double check as im not sure!)
Upvotes: 1