I have a discord channel that is full of embedded messages. I would like have the bot display a random embedded message from this channel in to any other channel where the command is called, similar to the functionality shown below.
When I call this code while pointed at the embed channel it returns an error: "discord.errors.HTTPException: 400 Bad Request (error code: 50006): Cannot send an empty message"
I believe this is caused by the channel being totally embeds, but I am very stupid and open to being corrected. I have confirmed that the bot has full admin privileges and thus can see/write into any channel. I've also confirmed that the below code works on non-embeds in other channels.
Thank you in advance for any assistance you can provide.
@client.command()
async def bestpost(ctx):
channel = client.get_channel(channelID)
best_posts = []
async for message in channel.history(limit=500):
best_posts.append(message)
random_bestpost = random.choice(best_posts).content
await ctx.send(random_bestpost)
If the channel is totally embeds, then you have to look into the message's embed rather than the message content. From there you can just send the embed or access a property of the embed and send that.
For example:
@client.command()
async def bestpost(ctx):
channel = client.get_channel(channelID)
best_posts = []
async for message in channel.history(limit=500):
best_posts.append(message)
random_bestpost = random.choice(best_posts).embeds[0]
await ctx.send(embed=random_bestpost)