Ejemplo n.º 1
0
    async def post_guild_count(self):
        """This function is a coroutine.

        Parameters
        ----------
        None

        Returns
        -------
        str
            Returns a success message

        Raises
        ------
        glennbotlist.NoKey
            Raised when self.token is None
        """
        if self.token is None:
            raise errors.NoKey("No API Key was passed")

        await self.request("POST",
                           f"bot/{self.bot.user.id}/stats",
                           data={
                               "serverCount": len(self.bot.guilds),
                               "shardCount": self.bot.shard_count or 0
                           },
                           headers={"authorization": self.token})

        if self.logging:
            print(
                f"Your guild count of {len(self.bot.guilds)} and shard count of {self.bot.shard_count} was posted successfully"
            )
Ejemplo n.º 2
0
    async def fetch_has_voted(self, user_id: int):
        """This function is a coroutine.

        Requires authorization

        Parameters
        ----------
        user_id: `int`
            ID of the user to get whether they have voted

        Returns
        ------
        boolean
            Whether the user has voted for the bot

        Raises
        ------
        glennbotlist.NoKey
            Raised when self.token is None
        """
        if self.token is None:
            raise errors.NoKey("No API Key was passed")

        bot_id = self.bot.user.id
        if self.bot_id is not None:
            bot_id = self.bot_id

        resp = await self.request("GET",
                                  url=f"bot/{bot_id}/votes",
                                  headers={"authorization": self.token})

        current = resp['current_votes']['current_users']
        return str(user_id) in current
Ejemplo n.º 3
0
    async def fetch_vote_count(self):
        """This function is a coroutine.

        Requires authorization

        Parameters
        ----------
        None

        Returns
        -------
        int
            Amount of votes the bot has received

        Raises
        ------
        glennbotlist.NoKey
            Raised when self.token is None
        """

        if self.token is None:
            raise errors.NoKey("No API Key was passed")

        bot_id = self.bot.user.id
        if self.bot_id is not None:
            bot_id = self.bot_id

        resp = await self.request("GET",
                                  url=f"bot/{bot_id}/votes",
                                  headers={"authorization": self.token})

        a = resp['current_votes']['alltime']
        m = len(resp['current_votes']['monthly'])

        return {"alltime": a, "monthly": m}
Ejemplo n.º 4
0
    async def fetch_bot_votes(self):
        """This function is a coroutine.

        Requires authorization

        Parameters
        ----------
        None

        Returns
        -------
        dict
            Dictionary of bot votes

        Raises
        ------
        glennbotlist.Not200
            Http status code of the request was not 200
        """
        if self.token is None:
            raise errors.NoKey("No API Key was passed")

        bot_id = self.bot.user.id
        if self.bot_id is not None:
            bot_id = self.bot_id

        data = await self.request("GET",
                                  url=f"bot/{bot_id}/votes",
                                  headers={"authorization": self.token})

        return data