discord.py从Discord机器人中删除角色

huangapple go评论84阅读模式
英文:

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)

huangapple
  • 本文由 发表于 2023年4月13日 21:00:12
  • 转载请务必保留本文链接:https://go.coder-hub.com/76005745.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定