bot.py 文件源码

python
阅读 26 收藏 0 点赞 0 评论 0

项目:ModTools 作者: MattBSG 项目源码 文件源码
def cmd_ignore(self, message, author, server, option, new_id, reason=None):
        """
        Usage: {command_prefix}ignore [ + | - | add | remove ] <channel ID> ["reason"]
        Adds or removes the channel ID to the list of ignored channels when outputting to the server log
        """
        if await self.has_roles(message.channel, author, server, command='ignore'):
            if option not in ['+', '-', 'add', 'remove']:
                raise CommandError('Invalid option "%s" specified, use +, -, add, or remove' % option)
            try:
                channel = discord.utils.get(server.channels, id=new_id)
                if not channel:
                    int('this')
            except:
                raise CommandError('Invalid Channel: {}'.format(new_id))
            if option in ['+', 'add']:
                self.server_index[server.id][12].append(channel.id)
            else:
                try:
                    self.server_index[server.id][12].remove(channel.id)
                except ValueError:
                    raise CommandError('No such channel in ignore list : {}'.format(new_id))
            await self.write_to_modlog(message, author, server, reason)
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号