A
A
ah0R2021-09-10 18:45:22
Python
ah0R, 2021-09-10 18:45:22

How to make the bot with buttons react to past messages on reload?

I have a code for a bot:

@bot.command()
async def tesss(ctx): 
        emb = discord.Embed(title = ':pencil: Роли Discord', description = "**Автоматическое выдача роли - <@&792385427679477790>**", colour = 0xFF005C)
        emb.set_image(url = 'https://media.discordapp.net/attachments/716571065270140938/880854910005047366/-7.png?width=701&height=701')
        emb.set_footer(text = 'Monro FamQ', icon_url = 'https://media.discordapp.net/attachments/716571065270140938/880854176735854622/-6.png?width=701&height=701')
        await ctx.send(
            embed = emb,
            components = [
                Button(style = ButtonStyle.green, label = "Стать другом Monro!", emoji = '❤️'),
                Button(style = ButtonStyle.blue, label = "Получить дополнительные роли!", emoji = '❤️'),
                Button(style = ButtonStyle.red, label = "Перестать быть другом Monro!")    
            ]
        )

It also stands on the hosting, which reboots it once a day.
How to make the bot work when you click on the old message after reboot?

Answer the question

In order to leave comments, you need to log in

2 answer(s)
A
antares4045, 2021-09-10
@ah0R

I agree with the speakers who recommend changing the hosting, but you can fasten the database (well, or just a file) and save the context to it (using, for example, pickle) and, when loading, accordingly check for the presence of the saved context. With bot apis, I have never had such a need, to be honest, - maybe some specifics will come out, but when finalized with a file, it definitely has to take off.

A
Alexander Prokopenko, 2021-09-10
@Goverl

The answer is to change the hosting that does not restart the bot. Or not at all.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question