英文:
discord.py remove roles from Discord bot
问题
我想在命令上为用户移除角色
@bot.command()
async def remove(ctx):
guild = bot.get_guild('server_id')
role = discord.utils.get(ctx.guild.roles, id='role_id')
await ctx.author.remove_roles(role)
但角色没有从用户身上移除。
英文:
I want remove roles for user on command
@bot.command()
async def remove(ctx):
guild = bot.get_guild('server_id')
role = discord.utils.get(ctx.guild.roles, id='role_id')
await ctx.author.remove_roles(role)
But role not remove from user.
答案1
得分: 1
Your code is not indented right:
@bot.command()
async def remove(ctx):
role = discord.utils.get(ctx.guild.roles, id='role_id')
await ctx.author.remove_roles(role)
英文:
Your code is not indented right:
@bot.command()
async def remove(ctx):
role = discord.utils.get(ctx.guild.roles, id='role_id')
await ctx.author.remove_roles(role)
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论