我正在尝试在 discord.py 中创建一个静音命令,一切似乎都是正确的。每当我使用该命令时,我的机器人都不会响应我给它的消息,也不会给出静音角色。代码如下:
@commands.has_permissions(manage_roles=True)
async def mute(ctx, user: discord.Member, *, reason="No reason provided"):
await user.mute(reason=reason)
role = discord.utils.get(ctx.guild.roles, name="Muted")
mute = discord.Embed(title=f"User {user.name}#{user.discriminator} has been muted. <a:m_verifyblack:850825891780100096>", color=0xF4D03F, description=f"Reason: {reason}\nBy: {ctx.author.mention}")
await ctx.message.delete()
await ctx.channel.send(embed=mute)
await user.send(embed=mute)
@mute.error
async def mute_error(ctx, error):
if isinstance(error, commands.MissingPermissions):
await ctx.send("**:no_entry_sign: You cant do that!**")```