【问题标题】:I have a problem with my discord.py ticket system我的 discord.py 票务系统有问题
【发布时间】:2021-10-07 09:34:02
【问题描述】:

这是我的代码:

#Ticket
@client.command(pass_context=True)
async def setuppartnership(ctx):
    guild = ctx.guild
    embed = discord.Embed(
        title = 'Richiesta Partnership',
        description = 'Vuoi fare partnership? Usa la reazione qui sotto per creare un nuovo ticket.',
        color=0x53eeff
    )
 
     
    msg = await ctx.send(embed=embed)
    await msg.add_reaction("????")
    msg = await msg.channel.fetch_message(msg.id)
    
    
    while True:
        def check(reaction, user):
            return str(reaction) == '????' and ctx.author == user
        await client.wait_for("reaction_add", check=check)
        ticket_channel = await guild.create_text_channel(name=f'partnership・{ctx.author.name}')
        await ticket_channel.set_permissions(ctx.author, send_messages=True, read_messages=True, add_reactions=True, embed_links=True, attach_files=True, read_message_history=True, external_emojis=True)
        await ticket_channel.set_permissions(ctx.guild.get_role(ctx.guild.id), send_messages=False, read_messages=False)

#这段代码有效,但我有一个问题:只有执行命令生成打开票的反应消息的人才能打开一个,让我解释一下:如果我运行命令 !setuppartnership 它会生成一个命令我点击反应他打开了一张票,但他只为执行命令的我创建它,因为如果另一个帐户点击反应没有任何反应,你可以帮助我。

【问题讨论】:

标签: python discord discord.py ticket-system


【解决方案1】:

不要使用循环来等待事件。

您可以在此处找到事件列表及其功能:https://discordpy.readthedocs.io/en/stable/api.html?highlight=reaction#event-reference

你要找的是on_raw_reaction_add()你可以通过payload.member得到反应人的成员对象

注意:你必须检查payload.message_id == <your-message-id>

【讨论】:

  • 非常感谢您的回答,不幸的是我不太擅长使用 on_raw_reaction_add() 函数,如果您可以将其插入我的代码段中,您将非常友好,再次感谢。
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 2011-07-28
  • 2020-07-31
  • 1970-01-01
  • 1970-01-01
  • 2022-01-05
  • 1970-01-01
相关资源
最近更新 更多