Ejemplo n.º 1
0
    async def soft_ban(self, ctx, target: discord.Member, *, reason="None"):
        """
        Soft Bans a target from your server, a soft ban will ban someone then unban them straight away,
        this will remove all their messages from the last 48 hours
        Requires either the permission to ban or any role with the following names:
        Admin, Mod, soft.


        Targets can be a mention, Name or ID.
        Your Administrator may require you to give a reason.
        If enabled a Soft Ban entry will be created in the Audit log Channel
        """
        if (target.top_role >= ctx.author.top_role) and (ctx.guild.owner !=
                                                         ctx.author):
            raise error.PowerTrip
        if target.top_role >= ctx.me.top_role:
            raise error.BotPowerTrip
        settings = await self.db.fetch_settings(ctx.guild)
        if settings['log_enabled']:
            if (settings['force_reason']) and (reason == "None"):
                raise error.NoReason
            embed = builder.logger(target, "Soft Ban", ctx.author, reason,
                                   settings['log_avatar'])
            log_channel = self.bot.get_channel(int(settings['log_channel']))
            await log_channel.send(embed=embed)
        await target.ban(reason=f'{ctx.author}: {reason}',
                         delete_message_days=2)
        await ctx.send(f'\N{HAMMER} {target} was soft banned',
                       delete_after=120)
        await target.unban(reason="Soft Ban, see Ban entry for reason")
        await self.db.increment_soft()
Ejemplo n.º 2
0
    async def kick(self, ctx, target: discord.Member, *, reason="None"):
        """
        Kicks a target from your server, requires either the permission to kick or any role with the following names:
        Admin, Mod, Kick.

        Targets can be a mention, Name or ID.
        Your Administrator may require you to give a reason.
        If enabled a Kick entry will be created in the Audit log Channel
        """
        if (target.top_role >= ctx.author.top_role) and (ctx.guild.owner !=
                                                         ctx.author):
            raise error.PowerTrip
        if target.top_role >= ctx.me.top_role:
            raise error.BotPowerTrip
        settings = await self.db.fetch_settings(ctx.guild)
        if settings['log_enabled']:
            if (settings['force_reason']) and (reason == "None"):
                raise error.NoReason
            embed = builder.logger(target, "Kick", ctx.author, reason,
                                   settings['log_avatar'])
            log_channel = self.bot.get_channel(int(settings['log_channel']))
            await log_channel.send(embed=embed)
        await target.kick(reason=f'{ctx.author}({ctx.author.id}): {reason}')
        await ctx.send(f'\N{HAMMER} {target} got kicked', delete_after=120)
        await self.db.increment_kick()
Ejemplo n.º 3
0
    async def mute(self, ctx, target: discord.Member, *, reason=None):
        """
        Mute's a target, stopping them from using their microphone. Will override all roles they have.

        To unmute use unmute. To check if someone is muted use check.
        Targets can be a mention, Name or ID.
        A reason is only used if your custom audit log entry is configured to allow mute entries.
        """
        if (target.top_role >= ctx.author.top_role) and (ctx.guild.owner !=
                                                         ctx.author):
            raise error.PowerTrip
        if target.top_role >= ctx.me.top_role:
            raise error.BotPowerTrip
        if target.voice is None:
            return await ctx.send(
                "They need to be connected to a voice channel before I can change that!"
            )
        await target.edit(mute=True)
        await ctx.send(f"{target} muted")
        settings = await self.db.fetch_settings(ctx.guild)
        if settings['trigger_on_mute'] and settings['log_enabled']:
            if (settings['force_reason']) and (reason is None):
                raise error.NoReason
            em = builder.logger(target, "Mute", ctx.author, reason,
                                settings['log_avatar'])
            log = self.bot.get_channel(int(settings.log_channel))
            await log.send(embed=em)
Ejemplo n.º 4
0
 async def on_member_unban(self, guild, user):
     await asyncio.sleep(3)
     settings = await self.db.fetch_settings(guild)
     if (not settings['trigger_on_manual']) or (
             not settings['log_enabled']):
         return
     if not self.perms_check(guild, settings):
         return
     async for entry in guild.audit_logs(
             action=discord.AuditLogAction.unban, limit=10):
         if entry.target.id == user.id:
             if entry.user.id == self.bot.user.id:
                 return
             em = builder.logger(user, "Unban", entry.user, entry.reason,
                                 settings['log_avatar'])
             log_channel = self.bot.get_channel(settings['log_channel'])
             await log_channel.send(embed=em)
Ejemplo n.º 5
0
    async def unban(self, ctx, id, *, reason="None"):
        """
        Unbans a target from your server, requires either the permission to ban or any role with the following names:
        Admin, Mod, Ban.

        Targets can only be a user ID.
        Your Administrator may require you to give a reason.
        If enabled a unban entry will be created in the Audit log Channel
        """
        target = discord.Object(id=id)
        settings = await self.db.fetch_settings(ctx.guild)
        if settings['log_enabled']:
            if (settings['force_reason']) and (reason == "None"):
                raise error.NoReason
            embed = builder.logger(target, "Unban", ctx.author, reason,
                                   settings['log_avatar'])
            log_channel = self.bot.get_channel(int(settings['log_channel']))
            await log_channel.send(embed=embed)
        await guild.unban(reason=f'{ctx.author}({ctx.author.id}): {reason}')