I've tried looking at other solutions but they havent worked for me. What im trying to do is make the bot edit its own message at a slight delay.
if message.content.startswith('(dev)messageedit'):
await message.channel.send('old message')
time.sleep(1)
await message.edit('new message')
The error im getting is:
TypeError: edit() takes 1 positional argument but 2 were given
It would be great if you could help me!
If you take a look at the docs, you'll see that you need to specify what you are editing in the message. In your case that would be the content
.
https://discordpy.readthedocs.io/en/master/api.html?highlight=edit#discord.Message.edit
await message.edit(content='new message')
I am not sure from your question if you want to edit the message you send first with old_message
, but if you do, you would also need to define it first:
old_message = await message.channel.send('old message')
await old_message.edit(content='new message')
Also, sidenote, I would recommend using asyncio.sleep
instead of time.sleep
, since time.sleep
is blocking your bot from doing other things.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.