Example #1
0
    async def get_application(self, application_id: int) -> AppInfo:
        """
        Gets an application by ID.

        :param application_id: The client ID of the application to fetch.
        :return: A new :class:`.AppInfo` object corresponding to the application.
        """
        data = await self.http.get_app_info(application_id=application_id)
        appinfo = AppInfo(self, **data)

        return appinfo
Example #2
0
    async def start(self, shard_count: int):
        """
        Starts the bot.

        :param shard_count: The number of shards to boot.
        """
        if self.bot_type & BotType.BOT:
            self.application_info = AppInfo(
                self, **(await self.http.get_app_info(None)))

        async with multio.asynclib.task_manager() as tg:
            self.events.task_manager = tg

            for shard_id in range(0, shard_count):
                await tg.spawn(self.handle_shard(shard_id, shard_count))
Example #3
0
    async def get_authorized_apps(self) -> typing.Sequence[AuthorizedApp]:
        """
        Gets a list of authorized applications for this user.

        :return: A sequence of :class:`~.AuthorizedApp`.
        """
        data = await self._bot.http.get_authorized_apps()
        final = []

        for item in data:
            id = int(item.get("id", 0))
            final.append(
                AuthorizedApp(id=id,
                              scopes=item.get("scopes", []),
                              application=AppInfo(self._bot, **item)))

        return final
Example #4
0
 async def _background_get_app_info(self):
     """
     Gets the application info in the background.
     """
     appinfo = AppInfo(self, **(await self.http.get_app_info(None)))
     self.application_info = appinfo