Answer the question
In order to leave comments, you need to log in
Is it possible to make the last two messages repeat if they are the same [Discord.py]?
Interesting, is it possible to make the bot repeat the content of the last two messages if they are the same? I tried to write to a txt file and compare the last two lines, but for some reason the bot doesn’t write, it doesn’t see the file :(
If you can link to posts / articles / answers or an example of how best to implement)
Answer the question
In order to leave comments, you need to log in
Try this solution. I think you need to start somewhere :)
# Объявляем глобальную переменную, в которой будет лежать последнее сообщение.
my_message = None
@bot.event
async def on_message(message):
global my_message
# Если автор сообщения не бот и содержания сообщения соответствует хранимому сообщению, отправляем его.
if message.author != bot.user:
if my_message == message.content:
await message.channel.send(message.content)
my_message = message.content
await bot.process_commands(message)
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question