AttributeError: 'NoneType' 对象没有属性 'get_role'

问题描述 投票:0回答:0

我试图让所有用户都具有特定角色,但我不知道如何获得这个特定角色,我搜索并找到了

guild.get_role(ROLE_ID)
,但不起作用;-;

import discord
from discord.ext import commands
import os

TOKEN    = # token
GUILD_ID = # guild id
ROLE_ID  = # role id

bot = commands.Bot(command_prefix='+', intents=discord.Intents.all())
guild = bot.get_guild(GUILD_ID)

admin_role = guild.get_role(ROLE_ID)

bot.run(TOKEN)

错误:

AttributeError: 'NoneType' object has no attribute 'get_role'

我不知道如何解决帮助;-;

discord.py attributeerror
© www.soinside.com 2019 - 2024. All rights reserved.