Как получить id роли
muteRole, чтобы занести её в
on_message
@commands.command()
@commands.has_permissions(manage_messages=True)
async def mute(self, ctx, member: discord.Member, *, reason=None):
muteRole = discord.utils.get(ctx.guild.roles, name="My_mute")
if not muteRole:
muteRole = await ctx.guild.create_role(name="My_mute")
await member.add_roles(muteRole, reason=reason)
await ctx.send(f"{member.mention} получил мут по причине {reason}")
await member.send(f"Ты получил мут на {ctx.guild.name} за {reason}")
@commands.Cog.listener()
async def on_message(self, message):
roleid = muteRole.id
block_role = message.guild.get_role(roleid)
if block_role in message.author.roles:
await message.delete()