示例#1
0
    def get_guild(self,
                  name: t.Optional[str] = None,
                  uuid: t.Optional[str] = None) -> guild.Guild:
        """
        Get the info about a Hypixel Guild, Either using Name or UUID.

        Parameters
        ----------
        name: `t.Optional[str]`
            The Name of the Guild. Defaults to None.
        uuid: `t.Optional[str]`
            The ID Of the guild. Defaults to None.

        Returns
        -------
        `guild.Guild`
            The Guild Object with certain Attributes for you to access, and use it.
        """
        if uuid:
            json = self._fetch(self.url["guild"], {"id": uuid})
        elif name:
            json = self._fetch(self.url["guild"], {"name": name})
        else:
            raise InvalidArgumentError(
                "Please provide a Named argument of the guild's Name or guild's ID."
            )

        if not json["guild"]:
            raise GuildNotFoundError("Return Value is null")
        return guild.Guild(json["guild"])
示例#2
0
    def get_guild(self,
                  name: t.Optional[str] = None,
                  uuid: t.Optional[str] = None) -> guild.Guild:
        """
        Get the Info about a Hypixel Guild, Either using Name or UUID.

        Parameters:
            name (t.Optional[str]): The Name of the Guild.
            uuid (t.Optional[str]): The ID Of the guild.

        Returns:
            guild (Guild): The Guild Object with certain Attributes for you to access, and use it.
        """
        if uuid:
            json, success = self._fetch("/guild", {"id": uuid})
        elif name:
            json, success = self._fetch("/guild", {"name": name})
        else:
            raise InvalidArgumentError(
                "Please provide a Named argument of the guild's Name or guild's ID."
            )

        if not success:
            raise HypixelAPIError(
                "The Key given is invalid, or something else has problem.")

        if not json["guild"]:
            raise GuildNotFoundError("Return Value is null")

        return guild.Guild(json["guild"])