Exemplo n.º 1
0
    async def mute(self, ctx, member: discord.Member, *, reason: str = None):
        """Server mute the mentioned user(only text channels), requires you to have manage roles permission"""

        state = state_instance.get_state(ctx.guild.id)
        text_channels = ctx.guild.text_channels
        mute_role = None
        if await permissions.check_priv(ctx, member):
            return
        if state.mute_exists:
            mute_role = get(ctx.guild.roles, name="Muted")
        else:
            mute_role = await ctx.guild.create_role(name="Muted")
            for channel in text_channels:
                await channel.set_permissions(mute_role,
                                              send_messages=False,
                                              manage_permissions=False,
                                              manage_channels=False,
                                              manage_webhooks=False,
                                              manage_messages=False)
            state.mute_exists = True

        for role in member.roles[::-1]:
            if role.name == "Muted":
                return await ctx.send(f"{member.name} is already muted")
        try:
            await member.add_roles(mute_role,
                                   reason=default.responsible(
                                       ctx.author, reason))
            await ctx.send(default.actionmessage("muted"))
        except Exception as e:
            await ctx.send(e)
Exemplo n.º 2
0
 async def massban(self, ctx, reason: ActionReason, *members: MemberID):
     """ Mass bans multiple members from the server. """
     try:
         for member_id in members:
             await ctx.guild.ban(discord.Object(id=member_id),
                                 reason=default.responsible(
                                     ctx.author, reason))
         await ctx.send(default.actionmessage("massbanned", mass=True))
     except Exception as e:
         await ctx.send(e)
Exemplo n.º 3
0
    async def kick(self, ctx, member: discord.Member, *, reason=None):
        """Kick the mentioned user, requires you to have kick members permission"""

        if await permissions.check_priv(ctx, member):
            return

        try:
            await member.kick(reason=default.responsible(ctx.author, reason))
            await ctx.send(default.actionmessage("kicked"))
        except Exception as e:
            await ctx.send(e)
Exemplo n.º 4
0
    async def ban(self, ctx, member: MemberID, *, reason: str = None):
        """ Bans a user from the current server. """
        m = ctx.guild.get_member(member)
        if m is not None and await permissions.check_priv(ctx, m):
            return

        try:
            await ctx.guild.ban(discord.Object(id=member),
                                reason=default.responsible(ctx.author, reason))
            await ctx.send(default.actionmessage("banned"))
        except Exception as e:
            await ctx.send(e)
Exemplo n.º 5
0
    async def unmute(self, ctx, member: discord.Member, *, reason: str = None):
        """ Unmutes a user from the current server. """
        if await permissions.check_priv(ctx, member):
            return

        muted_role = next((g for g in ctx.guild.roles if g.name == "Muted"),
                          None)

        if not muted_role:
            return await ctx.send(
                "Are you sure you've made a role called **Muted**? Remember that it's case sensetive too..."
            )

        try:
            await member.remove_roles(muted_role,
                                      reason=default.responsible(
                                          ctx.author, reason))
            await ctx.send(default.actionmessage("unmuted"))
        except Exception as e:
            await ctx.send(e)