【发布时间】:2021-05-25 17:25:10
【问题描述】:
async def mute(ctx, user: discord.User,time,*,reason):
if user:
await ctx.message.delete()
if discord.utils.get(ctx.guild.roles, name="mute"):
role = discord.utils.get(ctx.guild.roles, name="mute")
addroles = []
for i in user.roles:
try:
await user.remove_roles(i)
addroles.append(i.id)
except:
print(f"Can't remove the role {i}")
await user.add_roles(role)
cmd_used("mute",ctx.author,ctx.message.content)
embed=discord.Embed(title=f"""{bot.user.name}""",colour=maincolor)
embed.add_field(name=f"""`{ctx.author}` muted you from `{user.guild.name}`""",value=f"""time: {time}s, reason: {reason}""",inline=True)
await user.send(embed=embed)
await asyncio.sleep(int(time))
await user.remove_roles(role)
print(addroles)
await user.add_roles(addroles)
#errors: AttributeError: 'list' object has no attribute 'id'
基本上我的静音命令实际上不起作用,因为它使他们静音并且不会恢复他们的旧角色。 我需要一些帮助。
【问题讨论】:
标签: python discord.py