コード例 #1
0
    def __init__(self, config: dict, startup_extensions: List[str]):
        # TODO: Change prefix to . when syncing
        # commands.when_mentioned_or('e!')
        super().__init__(command_prefix='.', case_insensitive=True, description='A bot to run CSGO PUGS.',
                         help_command=commands.DefaultHelpCommand(verify_checks=False),
                         intents=discord.Intents(
                             guilds=True, members=True, bans=True, emojis=True, integrations=True, invites=True,
                             voice_states=True, presences=False, messages=True, guild_messages=True, dm_messages=True,
                             reactions=True, guild_reactions=True, dm_reactions=True, typing=True, guild_typing=True,
                             dm_typing=True
                         ))
        self.token: str = config['discord_token']
        self.bot_IP: str = config['bot_IP']
        self.steam_web_api_key = config['steam_web_API_key']
        self.servers: List[CSGOServer] = []
        # Will need to change for when there is multiple server queue
        self.users_not_ready: List[discord.Member] = []
        for i, server in enumerate(config['servers']):
            self.servers.append(
                CSGOServer(i, server['server_address'], server['server_port'], server['server_password'],
                           server['RCON_password']))
        self.web_server = WebServer(bot=self)
        self.dev: bool = False
        self.version: str = __version__
        self.queue_ctx: commands.Context = None
        self.queue_voice_channel: discord.VoiceChannel = None

        logger = logging.getLogger('discord')
        logger.setLevel(logging.DEBUG)
        handler = logging.FileHandler(filename='discord.log', encoding='utf-8', mode='w')
        handler.setFormatter(logging.Formatter('%(asctime)s:%(levelname)s:%(name)s: %(message)s'))
        logger.addHandler(handler)

        for extension in startup_extensions:
            self.load_extension(f'cogs.{extension}')
コード例 #2
0
ファイル: bot.py プロジェクト: bboychris168/ICL-Bot
    def __init__(self, config: dict, startup_extensions: List[str]):
        super().__init__(command_prefix=commands.when_mentioned_or('icl.'), case_insensitive=True, description='ICL Bot',
                         help_command=commands.DefaultHelpCommand(verify_checks=False),
                         intents=discord.Intents(
                             guilds=True, members=True, bans=True, emojis=True, integrations=True, invites=True,
                             voice_states=True, presences=False, messages=True, guild_messages=True, dm_messages=True,
                             reactions=True, guild_reactions=True, dm_reactions=True, typing=True, guild_typing=True,
                             dm_typing=True
                         ))
        fileConfig('logging.conf')
        self.logger = logging.getLogger(f'ICL_bot.{__name__}')
        self.logger.debug(f'Version = {__version__}')
        self.logger.debug(f'config.json = \n {pprint.pformat(config)}')

        self.token: str = config['discord_token']
        self.faceit_token: str = config['faceit_token']
        self.bot_IP: str = config['bot_IP']
        if 'bot_port' in config:
            self.bot_port: int = config['bot_port']
        else:
            self.bot_port: int = 3000
        self.web_server = WebServer(bot=self)
        self.dev: bool = False
        self.version: str = __version__

        self.matches: List[Match] = []

        for extension in startup_extensions:
            self.load_extension(f'cogs.{extension}')
コード例 #3
0
ファイル: bot.py プロジェクト: KovuTheHusky/discord-10man
    def __init__(self, config: dict, startup_extensions: List[str]):
        super().__init__(
            command_prefix=commands.when_mentioned_or('.'),
            case_insensitive=True,
            description='A bot to run CSGO PUGS.',
            help_command=commands.DefaultHelpCommand(verify_checks=False),
            intents=discord.Intents(guilds=True,
                                    members=True,
                                    bans=True,
                                    emojis=True,
                                    integrations=True,
                                    invites=True,
                                    voice_states=True,
                                    presences=False,
                                    messages=True,
                                    guild_messages=True,
                                    dm_messages=True,
                                    reactions=True,
                                    guild_reactions=True,
                                    dm_reactions=True,
                                    typing=True,
                                    guild_typing=True,
                                    dm_typing=True))
        fileConfig('logging.conf')
        self.logger = logging.getLogger(f'10man.{__name__}')
        self.logger.debug(f'Version = {__version__}')
        self.logger.debug(f'config.json = \n {pprint.pformat(config)}')

        self.token: str = config['discord_token']
        self.bot_IP: str = config['bot_IP']
        if 'bot_port' in config:
            self.bot_port: int = config['bot_port']
        else:
            self.bot_port: int = 3000
        self.steam_web_api_key = config['steam_web_API_key']
        self.servers: List[CSGOServer] = []
        # Will need to change for when there is multiple server queue
        self.users_not_ready: List[discord.Member] = []
        for i, server in enumerate(config['servers']):
            self.servers.append(
                CSGOServer(i, server['server_address'], server['server_port'],
                           server['server_password'], server['RCON_password']))
        self.web_server = WebServer(bot=self)
        self.dev: bool = False
        self.version: str = __version__
        self.queue_ctx: commands.Context = None
        self.queue_voice_channel: discord.VoiceChannel = None
        self.match_size = 10
        self.spectators: List[discord.Member] = []
        self.connect_dm = False
        self.queue_captains: List[discord.Member] = []

        for extension in startup_extensions:
            self.load_extension(f'cogs.{extension}')