Skip to content
Advertisement

Discord.py Error when trying to edit embed after X seconds

So, after like an hour of trying I gave up. I was trying to make my embed get edited after 5 seconds but it did not work. I keep getting this error:

”Instance of ‘Embed’ has no ‘message’ member”

import discord
import random
import asyncio
import time
from discord.ext import commands


class ppsize(commands.Cog):

    def __init__(self, client):
        self.client = client

    @commands.command(aliases=['mypp', 'sizepp'])
    async def PPPSize(self, ctx):
        responses = [ # Or values, however you want to name it
        'is 2cm.',
        'is 38cm.',
        'is 0cm.',
        'is too small to be measured.',
        '-16cm.',
        'bigger than a whole house.',
        '6cm.',
        'is 9cm',
        'is 13cm'
    ]
        pp = discord.Embed(title="Activating PP Size Measurement...!", description="Loading PP Size...")
        pp.set_image(url="https://tul.imgix.net/content/article/banana.jpg?auto=format,compress&w=1200&h=630&fit=crop")
        pp2 = discord.Embed(title="PP Size Measurement Has Been Activated!", description=random.choice(responses))
        pp2.set_image(url="https://tul.imgix.net/content/article/banana.jpg?auto=format,compress&w=1200&h=630&fit=crop")
        
        await ctx.send(embed=pp)
        await asyncio.sleep(5)
        await pp.message.edit(embed=pp2)



def setup(client):
    client.add_cog(ppsize(client))

Pretty basic command but no clue what to do. Also do I need the ‘Import time’?

Advertisement

Answer

You’re trying to edit the embed instead of the actual posted message.

await pp.message.edit(embed=pp2)

is referring to the embed. That embed doesn’t have an attribute called ‘message’, hence the error.

To fix this:

message = await ctx.send(embed=pp)
await asyncio.sleep(5)
await message.edit(embed=pp2)   
User contributions licensed under: CC BY-SA
1 People found this is helpful
Advertisement