【发布时间】:2020-10-11 07:58:31
【问题描述】:
所以,我创建了一个命令!vx new,它在某个类别中创建了一个具有作者和管理员设置的所有权限的新频道。现在我想创建一个删除票证的命令 - !vx close。这是我想出的代码,它可以工作,但问题是它可以从票证中的任何用户那里收到“是”。
@client.command(name='close', aliases=['delete'])
@commands.has_permissions(administrator=True)
async def close(ctx):
await ctx.send("Do you want to delete this channel?")
@commands.Cog.listener()
async def on_reaction_add(self, reaction, user: discord.Member):
def check(reaction, user):
name_list = []
for emoji in reaction.message.reactions:
name_list.append(emoji.emoji)
return '✅' in name_list and reaction.message.author.id == MyBotID and reaction.message.content == "Do you want to delete this channel?" and user.guild_permissions.administrator
if check(reaction, user):
await ctx.send("K!")
await ctx.channel.delete()
我希望输入!vx close 的用户用叉号/勾号做出反应,如果作者用勾号做出反应,它将关闭工单,如果作者用叉号做出反应,则不会关闭。
编辑 - 上面的代码也不起作用。
【问题讨论】:
标签: python python-3.x discord discord.py-rewrite