Exemplo n.º 1
0
    def get_caseinsensitive_achievement(self, name):
        if self._achievements is None:
            self._achievements = _CaseInsensitiveDict()
            for achievement in getattr(self, "_iter_achievements"):
                self._achievements[achievement.name] = achievement

        try:
            return self._achievements[name]
        except KeyError:
            return None
Exemplo n.º 2
0
    async def asyncSetUp(self):
        self.ctx = mock_discord.MockContext()
        self.ctx.bot.all_commands = _CaseInsensitiveDict()
        self.ctx.bot.add_command = partial(GroupMixin.add_command,
                                           self.ctx.bot)

        setup_general_commands(self.ctx.bot)
        setup_pomwars_commands(self.ctx.bot)

        self.ctx.bot.commands = set(self.ctx.bot.all_commands.values())
Exemplo n.º 3
0
    def __init__(self,
                 command_prefix,
                 help_command=DefaultHelpCommand(),
                 description=None,
                 **kwargs):
        self.command_prefix = command_prefix
        self.extra_events = {}
        self._BotBase__cogs = {}
        self._BotBase__extensions = {}
        self._checks = []
        self._check_once = []
        self._before_invoke = None
        self._after_invoke = None
        self._help_command = None
        self.description = inspect.cleandoc(description) if description else ""
        self.owner_id = kwargs.get("owner_id")
        self.owner_ids = kwargs.get("owner_ids", set())
        self._skip_check = lambda x, y: x == y
        self.help_command = help_command
        self.case_insensitive = kwargs.get("case_insensitive", False)
        self.all_commands = _CaseInsensitiveDict(
        ) if self.case_insensitive else {}

        self.ws = None
        self.loop = asyncio.get_event_loop()
        self.http = HTTPClient(None, loop=self.loop)

        self._handlers = {"ready": self._handle_ready}
        self._hooks = {}
        self._listeners = {}

        self._connection = None
        self._closed = False
        self._ready = asyncio.Event()

        self._redis = None
        self._amqp = None
        self._amqp_channel = None
        self._amqp_queue = None
Exemplo n.º 4
0
 def __init__(self, case_insensitive=True):
     self.all_commands = _CaseInsensitiveDict() if case_insensitive else {}
     self.case_insensitive = case_insensitive
Exemplo n.º 5
0
    def __init__(self, command_prefix=None, **kwargs):
        self.command_prefix = command_prefix
        self.extra_events = {}
        self._BotBase__cogs = {}
        self._BotBase__extensions = {}
        self._checks = []
        self._check_once = []
        self._before_invoke = None
        self._after_invoke = None
        self._help_command = None
        self.description = ""
        self.owner_id = None
        self.owner_ids = set()
        self._skip_check = lambda x, y: x == y
        self.case_insensitive = True
        self.all_commands = _CaseInsensitiveDict(
        ) if self.case_insensitive else {}
        self.strip_after_prefix = False

        self.ws = None
        self.loop = asyncio.get_event_loop()
        self.http = HTTPClient(None, loop=self.loop)

        self._handlers = {"ready": self._handle_ready}
        self._hooks = {}
        self._listeners = {}

        self._closed = False
        self._ready = asyncio.Event()

        self._redis = None
        self._amqp = None
        self._amqp_channel = None
        self._amqp_queue = None

        self.config = Config()
        self.session = aiohttp.ClientSession(loop=self.loop)
        self.http_uri = f"http://{self.config.BOT_API_HOST}:{self.config.BOT_API_PORT}"
        self.id = kwargs.get("bot_id")
        self.cluster = kwargs.get("cluster_id")
        self.cluster_count = kwargs.get("cluster_count")
        self.version = kwargs.get("version")
        self.pool = None
        self.prom = None

        self._enabled_events = [
            "MESSAGE_CREATE",
            "MESSAGE_REACTION_ADD",
            "READY",
        ]

        self._cogs = [
            "admin",
            "configuration",
            "core",
            "direct_message",
            "error_handler",
            "events",
            "general",
            "miscellaneous",
            "modmail_channel",
            "owner",
            "premium",
            "snippet",
        ]