【问题标题】:Discord Bot on_member_joinDiscord Bot on_member_join
【发布时间】:2021-07-03 17:55:15
【问题描述】:

我需要一个不和谐机器人的帮助,

import discord
client = discord.Client()

@client.event
async def on_member_join(member):
    print('new member')
    role = discord.utils.get(member.guild.roles, name='Unnamend')
    await member.add_roles(role)
    print(str(member.roles))

这是我的代码,如果我加入,我没有收到消息或角色,有人知道我该如何解决吗?

【问题讨论】:

    标签: python discord discord.py


    【解决方案1】:

    似乎缺少 Intent。

    确保为您的应用打开Discord Developer Portal 中所有必要的选项。

    要将它们实现到您的代码中,您可以使用以下代码:

    intents = discord.Intents.all() # Imports all the Intents
    client = commands.Bot(command_prefix="YourPrefix", intents=intents)
    

    或者在你的情况下:

    intents = discord.Intents.all() # Imports all the Intents
    client = discord.Client(intents=intents)
    

    【讨论】:

      猜你喜欢
      • 2021-07-15
      • 2021-01-28
      • 2021-06-15
      • 2021-01-19
      • 2022-10-21
      • 2021-01-20
      • 1970-01-01
      • 1970-01-01
      • 2020-07-16
      相关资源
      最近更新 更多