W
W
wz2021-10-06 13:29:52
Python
wz, 2021-10-06 13:29:52

How to edit a bot message?

Hello, hello, I’m doing a command to issue a ping bot, but since the ping command in Windows has a long count, I decided to edit messages after counting, something like this: I

unknown.pngunknown.png

wrote such a simple code:

@bot.command()
async def ping(ctx):
    emb = discord.Embed(description=f"Подсчет пинга...")
    await ctx.send(embed=emb)
    getBDping = os.system("ping айпи.сервера")
    emb = discord.Embed(
        description=f"""
        **Пинг Сообщений**
        ``{round(bot.latency * 1000)}мс``\n
        **Пинг Базы**
        ``{getBDping}мс``
        """)
    await ctx.message.edit(embed=emb)

But it gives me an error that the bot cannot edit a non-own message, help.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
R
retUrn3d, 2021-10-06
@rensly

Just take and edit the bot's message, not what is passed to you from the context.

@bot.command()
async def ping(ctx):
    emb = discord.Embed(description=f"Подсчет пинга...")
    msg = await ctx.send(embed=emb)
    getBDping = os.system("ping айпи.сервера")
    emb = discord.Embed(
        description=f"""
        **Пинг Сообщений**
        ``{round(bot.latency * 1000)}мс``\n
        **Пинг Базы**
        ``{getBDping}мс``
        """)
    await msg.edit(embed=emb)

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question