What I'm trying to do: I am making a riddle command with my discord.py
bot. Every time someone runs the command for a new riddle, it removes the most recent message pinned (the author of said message being the bot) and pins the new message. I am trying to make the bot look for a certain keyword in an embed's title, rather than relying on whether the pinned message was sent by the bot or not.
Problem: I have not found a way to check the content of an embed title. The only question I found that was mostly related to my question was for an on_message()
event, but I wasn't very sure how to incorporate it.
Code:
@client.command(aliases=["riddle"],pass_context=True)
@commands.guild_only()
@has_permissions(manage_messages=True)
async def rid(ctx, prize=None, *, rid=None):
if prize == None and rid == None:
await ctx.send('Format: `bl!riddle "cool prize" Sometimes it\'s brown and sticky, what is it?`')
elif prize is not None and rid == None:
await ctx.send('Format: `bl!riddle "a nice prize" Fluffy like candy but not a cloud, what am I?`')
elif prize is not None and rid is not None:
embed = discord.Embed(title, "Today's Riddle: ", description=rid, color=0x8d78d9) # The embed title the bot would read
embed.set_footer(text=f"Prize: {prize} | Host: {ctx.message.author}")
try:
await ctx.message.delete()
except:
pass
pinner = await ctx.send(embed=embed)
channel = ctx.channel
pins = await channel.pins()
x = 1
while x is not 0:
for message in pins:
if message.author.id == 733237477170741280: # this is what I want to replace
await message.unpin()
x = x - 1
else:
continue
if x == 0:
break
await pinner.pin()
Images:
This is what the embed looks like.
Other questions I have looked at: