Reputation: 55
I'm trying to make a meme command (where random images come out) personally dedicated to the server and I would like the author of the meme to be mentioned. But I'm afraid that if I also create images for the author other than the author. My question is essentially: How do I put both the image and the author in the same variable? (Sorry if I explained myself wrong)
Code
#random image embed
@client.command(aliases=["IM","im"])
async def image_embed(ctx):
tartufo=[
'https://cdn.discordapp.com/attachments/640563710104043530/731555200489357362/salvenee.jpg',
'https://cdn.discordapp.com/attachments/640563710104043530/731552604546662511/unknown.png',
'https://media.gettyimages.com/photos/rocks-balancing-on-driftwood-sea-in-background-picture-id153081592?s=612x612'
]
embed = discord.Embed(
color=discord.Colour.dark_blue()
)
embed.set_image(url=random.choice(tartufo))
embed.set_footer(text=f'Richiesto da {ctx.author.name}')
await ctx.send(embed=embed)
Upvotes: 0
Views: 488
Reputation: 60994
You can make a list of tuples where the elements of each tuple are the url and author:
images = [
('url1', 'author1'),
('url2', 'author2'),
('url3', 'author3'),
('url4', 'author4'),
]
url, author = random.choice(images)
embed.set_image(url=url)
embed.set_footer(text=f'Author is {author}')
Upvotes: 1