R
R
Ratatuy2020-12-20 18:21:41
Python
Ratatuy, 2020-12-20 18:21:41

Discord.py how to change embed multiple times in a row?

I need to change embed several times in a row.
Here is my code:

@client.command()
async def loading(ctx):
  load1=discord.Embed(title='Прогресс __0%__',color=2358184)
  load2=discord.Embed(title='Прогресс __25%__',color=2358184)
  load3=discord.Embed(title='Прогресс __50%__',color=2358184)
  load4=discord.Embed(title='Прогресс __75%__',color=2358184)
  load5=discord.Embed(title='Прогресс __100%__',color=2358184)
  complete=discord.Embed(title='Загрузка завершена!',color=2358184)
  msg=await ctx.send(embed=load1)
  await asyncio.sleep(1)
  msg1=await msg.edit(embed=load2)
  await asyncio.sleep(1)
  msg2=await msg1.edit(embed=load3)
  await asyncio.sleep(1)
  msg3=await msg2.edit(embed=load4)
  await asyncio.sleep(1)
  msg4=await msg3.edit(embed=load5)
  await asyncio.sleep(1)
  complete=await msg5.edit(embed=complete)

But he only changes once.
What is wrong here?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
M
Maxim Nevzorov, 2020-12-20
@Ratatuy

Traceback (most recent call last):
  File "/home/fixator/Red-V3/lib/python3.8/site-packages/redbot/core/dev_commands.py", line 202, in _eval
    result = await func()
  File "<string>", line 13, in func
AttributeError: 'NoneType' object has no attribute 'edit'

discord.Message.edit returns nothing .
Use the method of the .editoriginal post:
load1=discord.Embed(title='Прогресс __0%__',color=2358184)
  load2=discord.Embed(title='Прогресс __25%__',color=2358184)
  load3=discord.Embed(title='Прогресс __50%__',color=2358184)
  load4=discord.Embed(title='Прогресс __75%__',color=2358184)
  load5=discord.Embed(title='Прогресс __100%__',color=2358184)
  complete=discord.Embed(title='Загрузка завершена!',color=2358184)
  msg=await ctx.send(embed=load1)
  await asyncio.sleep(1)
  await msg.edit(embed=load2)
  await asyncio.sleep(1)
  await msg.edit(embed=load3)
  await asyncio.sleep(1)
  await msg.edit(embed=load4)
  await asyncio.sleep(1)
  await msg.edit(embed=load5)
  await asyncio.sleep(1)
  await msg.edit(embed=complete)

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question