Пример #1
0
    async def punish(self, bot: rainbot, message: discord.Message, *, reason=None, purge_limit=None):
        ctx = DummyContext(await bot.get_context(message))
        ctx.author = message.guild.me  # bot

        guild_config = await bot.db.get_guild_config(message.guild.id)
        punishments = guild_config.detection_punishments[self.name]

        reason = reason or f'Detection triggered: {self.name}'

        for _ in range(punishments.warn):
            ctx.command = bot.get_command('warn add')
            await ctx.invoke(bot.get_command('warn add'), member=message.author, reason=reason)

        if punishments.kick:
            try:
                ctx.command = bot.get_command('kick')
                await ctx.invoke(bot.get_command('kick'), member=message.author, reason=reason)
            except discord.NotFound:
                pass

        if punishments.ban:
            try:
                ctx.command = bot.get_command('ban')
                await ctx.invoke(bot.get_command('ban'), member=message.author, reason=reason)
            except discord.NotFound:
                pass

        if punishments.delete:
            if purge_limit:
                ctx.command = bot.get_command('purge')
                await ctx.invoke(bot.get_command('purge'), member=message.author, limit=purge_limit)
            else:
                try:
                    await message.delete()
                except discord.NotFound:
                    pass

        if punishments.mute:
            try:
                time = await UserFriendlyTime(default='nil').convert(ctx, punishments.mute)
            except commands.BadArgument:
                # ignore as bad argument
                pass
            else:
                delta = time.dt - message.created_at
                try:
                    await bot.mute(ctx.author, message.author, delta, reason=reason)
                except discord.NotFound:
                    pass
Пример #2
0
def setup(bot: rainbot) -> None:
    bot.add_cog(Detections(bot))
Пример #3
0
def setup(bot: rainbot) -> None:
    bot.add_cog(Roles(bot))
Пример #4
0
def setup(bot: rainbot) -> None:
    bot.add_cog(Moderation(bot))
Пример #5
0
def setup(bot: rainbot) -> None:
    bot.add_cog(Giveaways(bot))
Пример #6
0
def setup(bot: rainbot) -> None:
    bot.add_cog(Tags(bot))
Пример #7
0
def setup(bot: rainbot) -> None:
    bot.add_cog(Logging(bot))