Skip to content Skip to sidebar Skip to footer

Update Embed Messages Every 5 Minutes (discord.py)

I wanted my bot to update his embed message every 5 minutes for ever, is that possible? Like I do !update-message And my bots sends the message programmed for example Title: Number

Solution 1:

First, you can look at that.

Then, here's how i would do it. Adapt it to your need (also, note that this is code from the rewrite branch. If you're using latest i really much advice you to migrate to rewrite as latest is deprecated anyway and its developpement is in standby) :

asyncdefmy_background_task():
    await client.wait_until_ready()
    whilenot client.is_closed():
        message = await client.get_channel(channelId).fetch_message(messageId)
        await message.edit(embed = newEmbed)
        await asyncio.sleep(300)

bg_task = client.loop.create_task(my_background_task())

NB : Don't forget to replace channelId by the id of the channel the message is in, messageId by the id of the message you want to edit and newEmbed by the changed embed

Post a Comment for "Update Embed Messages Every 5 Minutes (discord.py)"