【发布时间】:2021-04-09 09:21:56
【问题描述】:
我想做的事:我正在用我的 discord.py 机器人制作一个谜语命令。每次有人为新谜语运行命令时,它都会删除最近固定的消息(所述消息的作者是机器人)并固定新消息。我试图让机器人在嵌入标题中查找某个关键字,而不是依赖于固定消息是否由机器人发送。
问题:我还没有找到检查嵌入标题内容的方法。我发现与我的问题最相关的唯一问题是an on_message() event,但我不太确定如何合并它。
代码:
@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()
图片:
这就是嵌入的样子。
我看过的其他问题:
【问题讨论】:
标签: python discord discord.py