【问题标题】:How do I make a verification system in Python for Discord Bots?如何在 Python 中为 Discord Bots 制作验证系统?
【发布时间】:2021-10-07 04:31:55
【问题描述】:

我正在尝试制作一个适用于我的 Discord 服务器网络的验证系统。 这是我希望机器人在您输入“.agree”后执行的操作:

  1. 检查您是否在名为“verify_here”的频道中发送了消息。
  2. 如果您是在该频道中发送的,请添加“成员”角色。
  3. 发送消息“{message.author},谢谢!”
  4. 3 秒后删除两条消息。

这是我的代码:

@client.event
async def on_message(message):
    verify_channel = client.get_channel(868120833858621470)
    verify_role = get(member.guild.roles, id='871383440694587462')
    if message.content == '.agree' in verify_channel:
        await member.add_roles(message.author, verify_role)
        await message.send(f'{message.author}, thanks!')

奇怪的是我没有收到任何错误消息。它只是行不通。什么都没有发生。机器人没有添加任何角色,并且机器人没有发送任何消息。我试过寻求帮助,但是关于为 Python Discord Bots 制作验证系统的指南很少。我也尝试了不同的代码布局方式,但都没有奏效。

注意:我将为我的整个 Discord 服务器网络使用这个机器人和验证系统,这意味着我希望机器人检查频道名称而不是频道 ID。

我怎样才能做到这一点?

【问题讨论】:

    标签: python discord discord.py chatbot


    【解决方案1】:

    使用

    if message.content == '.agree' and message.channel == verify_channel:
        await member.add_roles(message.author, verify_role)
        await message.channel.send(f'{message.author}, thanks!')
    

    而不是

    if message.content == '.agree' in verify_channel:
        await member.add_roles(message.author, verify_role)
        await message.send(f'{message.author}, thanks!')
    

    希望这是有道理的:)

    【讨论】:

      猜你喜欢
      • 2019-04-27
      • 1970-01-01
      • 2021-05-04
      • 2020-05-13
      • 1970-01-01
      • 2021-09-10
      • 1970-01-01
      • 1970-01-01
      • 2015-06-23
      相关资源
      最近更新 更多