示例#1
0
    async def setmodlog(self,
                        ctx,
                        log_name: lower,
                        channel: discord.TextChannel = None):
        """Sets the log channel for various types of logging

        Valid types: all, member_warn, member_mute, member_unmute, member_kick, member_ban, member_unban, member_softban, message_purge, channel_lockdown, channel_slowmode
        """
        channel_id = None
        if channel:
            try:
                await channel.send('Testing the logs')
            except discord.Forbidden:
                raise BotMissingPermissionsInChannel(['send_messages'],
                                                     channel)
            channel_id = str(channel.id)

        valid_logs = DEFAULT['modlog'].keys()
        if log_name == 'all':
            for i in valid_logs:
                await self.bot.db.update_guild_config(
                    ctx.guild.id, {'$set': {
                        f'modlog.{i}': channel_id
                    }})
        else:
            if log_name not in valid_logs:
                raise commands.BadArgument(
                    'Invalid log name, pick one from below:\n' +
                    ', '.join(valid_logs))

            await self.bot.db.update_guild_config(
                ctx.guild.id, {'$set': {
                    f'modlog.{log_name}': channel_id
                }})
        await ctx.send(self.bot.accept)
示例#2
0
    async def setlog(self,
                     ctx,
                     log_name: lower,
                     channel: discord.TextChannel = None):
        """Sets the log channel for various types of logging

        Valid types: all, message_delete, message_edit, member_join, member_remove, member_ban, member_unban, vc_state_change, channel_create, channel_delete, role_create, role_delete
        """
        valid_logs = DEFAULT['logs'].keys()
        channel_id = None
        if channel:
            try:
                await channel.send('Testing the logs')
            except discord.Forbidden:
                raise BotMissingPermissionsInChannel(['send_messages'],
                                                     channel)
            channel_id = str(channel.id)

        if log_name == 'all':
            for i in valid_logs:
                await self.bot.db.update_guild_config(
                    ctx.guild.id, {'$set': {
                        f'logs.{i}': channel_id
                    }})
        else:
            if log_name not in valid_logs:
                raise commands.BadArgument(
                    'Invalid log name, pick one from below:\n' +
                    ', '.join(valid_logs))

            await self.bot.db.update_guild_config(
                ctx.guild.id, {'$set': {
                    f'logs.{log_name}': channel_id
                }})
        await ctx.send(self.bot.accept)
示例#3
0
    async def setmodlog(self, ctx, log_name: lower, channel: discord.TextChannel=None):
        """Sets the log channel for various types of logging

        Valid types: all, member_mute, member_unmute, member_kick, member_ban, member_unban, member_softban, message_purge
        """
        channel_id = None
        if channel:
            try:
                await channel.send('Testing the logs')
            except discord.Forbidden:
                raise BotMissingPermissionsInChannel(['send_messages'], channel)
            channel_id = str(channel.id)

        valid_logs = self.default['modlog'].keys()
        if log_name == 'all':
            for i in valid_logs:
                await self.bot.mongo.config.guilds.find_one_and_update({'guild_id': str(ctx.guild.id)}, {'$set': {f'modlog.{i}': channel_id}}, upsert=True)
        else:
            if log_name not in valid_logs:
                raise commands.BadArgument('Invalid log name, pick one from below:\n' + ', '.join(valid_logs))

            await self.bot.mongo.config.guilds.find_one_and_update({'guild_id': str(ctx.guild.id)}, {'$set': {f'modlog.{log_name}': channel_id}}, upsert=True)
        await ctx.send(self.bot.accept)