Пример #1
0
def run(discord_token, donate_url=None):
    """ Create the bot, add the cogs and run it. """
    bot = commands.Bot(command_prefix=('a!', 'A!'), case_insensitive=True)
    bot.add_cog(cogs.CacherCog(bot, DATA_PATH))
    bot.add_cog(cogs.ConsoleCog(bot))
    bot.add_cog(cogs.HelpCog(bot, BOT_COLOR))
    bot.add_cog(cogs.QueueCog(bot, BOT_COLOR))

    if donate_url:
        bot.add_cog(cogs.DonateCog(bot, BOT_COLOR, donate_url))

    bot.run(discord_token)
Пример #2
0
def run(discord_token, dbl_token=None, donate_url=None, generic=False):
    """ Create the bot, add the cogs and run it. """
    bot = commands.Bot(command_prefix=('q!', 'Q!'), case_insensitive=True)
    bot.add_cog(cogs.CacherCog(bot, DATA_PATH))
    bot.add_cog(cogs.ConsoleCog(bot))
    bot.add_cog(cogs.HelpCog(bot, BOT_COLOR))
    bot.add_cog(cogs.QueueCog(bot, BOT_COLOR))
    bot.add_cog(cogs.TeamDraftCog(bot, BOT_COLOR))

    if not generic:
        bot.add_cog(cogs.MapDraftCog(bot, BOT_COLOR))

    if dbl_token:
        bot.add_cog(cogs.DblCog(bot, dbl_token))

    if donate_url:
        bot.add_cog(cogs.DonateCog(bot, BOT_COLOR, donate_url))

    bot.run(discord_token)
Пример #3
0
def run(discord_token, api_base_url, api_key, dbl_token=None, donate_url=None):
    """ Create the bot, add the cogs and run it. """
    api_helper = ApiHelper(api_base_url, api_key)
    bot = commands.Bot(command_prefix=('q!', 'Q!'), case_insensitive=True)
    bot.add_cog(cogs.CacherCog(bot, DATA_PATH))
    bot.add_cog(cogs.ConsoleCog(bot))
    bot.add_cog(cogs.HelpCog(bot, BOT_COLOR))
    bot.add_cog(cogs.AuthCog(bot, api_helper, BOT_COLOR))
    bot.add_cog(cogs.QueueCog(bot, api_helper, BOT_COLOR))
    bot.add_cog(cogs.TeamDraftCog(bot, BOT_COLOR))
    bot.add_cog(cogs.MapDraftCog(bot, BOT_COLOR))

    if dbl_token:
        bot.add_cog(cogs.DblCog(bot, dbl_token))

    if donate_url:
        bot.add_cog(cogs.DonateCog(bot, BOT_COLOR, donate_url))

    bot.run(discord_token)
Пример #4
0
    def __init__(self, discord_token, api_base_url, api_key, dbl_token=None, donate_url=None):
        """ Set attributes and configure bot. """
        # Call parent init
        super().__init__(command_prefix=('q!', 'Q!'), case_insensitive=True)

        # Set argument attributes
        self.discord_token = discord_token
        self.api_base_url = api_base_url
        self.api_key = api_key
        self.dbl_token = dbl_token
        self.donate_url = donate_url

        # Set constants
        self.color = 0x000000
        self.guild_data_file = 'guild_data.json'

        # Create session for API
        self.session = aiohttp.ClientSession(loop=self.loop)
        self.api_helper = ApiHelper(self.session, self.api_base_url, self.api_key)

        # Initialize set of errors to ignore
        self.ignore_error_types = set()

        # Add check to not respond to DM'd commands
        self.add_check(lambda ctx: ctx.guild is not None)
        self.ignore_error_types.add(commands.errors.CheckFailure)

        # Add cogs
        self.add_cog(cogs.CacherCog(self))
        self.add_cog(cogs.ConsoleCog(self))
        self.add_cog(cogs.HelpCog(self))
        self.add_cog(cogs.AuthCog(self))
        self.add_cog(cogs.QueueCog(self))
        self.add_cog(cogs.TeamDraftCog(self))
        self.add_cog(cogs.MapDraftCog(self))
        self.add_cog(cogs.StatsCog(self))

        if self.dbl_token:
            self.add_cog(cogs.DblCog(self))

        if self.donate_url:
            self.add_cog(cogs.DonateCog(self))