【发布时间】:2020-11-14 03:26:30
【问题描述】:
我正在尝试制作一个静音命令,该命令将提到的用户静音(显然)并在未找到静音角色时创建静音角色。由于某种原因,添加角色部分没有添加角色而没有返回错误。 这是代码:
@client.command()
@commands.has_permissions(manage_roles = True)
async def mute(ctx):
guild = ctx.guild
member = discord.Member
mute_role = discord.utils.get(ctx.guild.roles, name = "Muted")
if discord.utils.get(ctx.guild.roles, name = "Muted"):
await ctx.send("Role already exists")
await member.add_roles(mute_role)
await ctx.send("Muted")
else:
await guild.create_role(name = "Muted", color = discord.Color(0x000001))
await ctx.send("Created Role")
await member.add_roles(mute_role)
await ctx.send("Muted")
任何帮助将不胜感激。
【问题讨论】:
标签: discord.py