Noob trying to make an embed

hi, I’m very very new to python and I’m trying me best to code a spooky little bot for discord, as a gift. but I’m having some trouble attaching images to a random.choice outcome. I’ve tried a few different ways but I just can’t seem to get it to work. this is my embed attempt, I’ve shortened the http links to the images here though. If anyone has any advice I would really appreciate it thanks.

if message.content.startswith('!maglite'):
      maglite_embed=[embed1,embed2,embed3,embed4,embed5]
      maglites=random.choice(maglite_embed) 

     embed1 = discord.Embed(
     title='Light Flashes',
     color=discord.Color(0xe91e63)), 
     embed.set_thumbnail(url="https:.gif")

     embed2 = discord.Embed(
     title='Light On',
     color=discord.Color(0x1abc9c)), 
     embed.set_thumbnail(url="https:.png")

     embed3 = discord.Embed(
     title='Light Stays On',
     color=discord.Color(0x9b59b6)), 
     embed.set_thumbnail(url="https:.png")

     embed4 = discord.Embed(
     title='Light Off',
     color=discord.Color(0x206694)), 
     embed.set_thumbnail(url="https:.png")

     embed5 = discord.Embed(
     title='Light Stays Off',
     color=discord.Color(0x11806a)), 
     embed.set_thumbnail(url="https.png")

     await message.channel.send(embed=maglites))
1 Like

I think that you might not have specified the whole image URL.
Also, the https protocol starts with https://
In your code, you are using https:
on embed5, you also forgot the colon after https.
Happy to help!

1 Like

You should use the variable names of the embeds (embed1, embed2, etc) to set the thumbnail, not just embed.set_thumbnail() . Also make sure to declare and define your embed objects before you use them in your list (for example: maglite_embed).

You are in the right track of your code, just need a little tinkering:

embed1 = discord.Embed(title='Light Flashes', color=discord.Color(0xe91e63))
embed1.set_thumbnail(url="https: .png")

embed2 = discord.Embed(title='Light On', color=discord.Color(0x1abc9c))
embed2.set_thumbnail(url="https: .png")

embed3 = discord.Embed(title='Light Stays On', color=discord.Color(0x9b59b6))
embed3.set_thumbnail(url="https: .png")

embed4 = discord.Embed(title='Light Off', color=discord.Color(0x206694))
embed4.set_thumbnail(url="https: .png")

embed5 = discord.Embed(title='Light Stays Off', color=discord.Color(0x11806a))
embed5.set_thumbnail(url="https: .png")

maglite_embed = [embed1, embed2, embed3, embed4, embed5]

Then in your if statement, you would pick one of these at random and send it as a message:

if message.content.startswith('!maglite'):
    chosen_embed = random.choice(maglite_embed)
    await message.channel.send(embed=chosen_embed)
1 Like