A
A
AnaChamKa2021-04-09 23:12:50
Python
AnaChamKa, 2021-04-09 23:12:50

How to get muteRole role id to put it in on_message?

How to get the muteRole role id to put it in 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()

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question