python - 如何在 discord.py 中添加角色?
问题描述
我正在尝试为某人添加角色,但是当我这样做时
client.add_roles(member, role)
我已经尝试了所有我能想到的代码,它只是给了我这个信息,我已经查看了其他几个问题来寻找答案,但每个人都说要执行我尝试过的那个命令,但它不会工作。
@client.command(pass_context=True)
@commands.has_role('Unverified')
async def verify(ctx, nickname):
gmember = ctx.message.author #This is the looking for the memeber
role = discord.utils.get(gmember.server.roles, name='Guild Member')
channel = client.get_channel(401160140864094209)
await gmember.edit(nick=f"{nickname}")
await ctx.channel.purge(limit=1)
r = requests.get("This is the link to the API but it shows my key and everything so not going to put it here but it works in other commands")
#if nickname in role:
# await ctx.send(f"You have already verified your account.")
if nickname.encode() in r.content:
await channel.send(f'@here ``{nickname}`` is in the guild.')
await client.add_roles(gmember, role)
else:
await gmember.kick()
的实例Bot
没有add_roles
成员pylint
(no-member)
解决方案
await gmember.add_roles(role)
你可以在这里
阅读更多
推荐阅读
- python - “密集”类型的对象没有 len()
- artificial-intelligence - 如何在边缘实现安全关键型 AI 计算集群?
- jenkins - 无法从代码分析中排除包
- amazon-web-services - AWS ECS 服务错误:必须启用任务长 arn 格式才能使用 ECS 托管标签启动服务任务
- regex - Powershell 在特定字符串之前添加行
- vue.js - ChartJS和VueJS中条形图中每个条的颜色不同
- snackbar - 基本 Snackbar 示例未显示在 Material Design Components for Web
- excel - 循环将粘贴行复制到列中,执行计算并存储结果
- c# - 通用windows平台后台运行巨大进程时如何制作交互式UI?
- angular - Themeable Browser Cordova Plugin:后退、前进和关闭按钮的图像未显示