Class ServerImpl

    • Constructor Detail

      • ServerImpl

        public ServerImpl​(DiscordApiImpl api,
                          com.fasterxml.jackson.databind.JsonNode data)
        Creates a new server object.
        Parameters:
        api - The discord api instance.
        data - The json data of the server.
    • Method Detail

      • isReady

        public boolean isReady​()
        Checks if the server is ready (all members are cached).
        Returns:
        Whether the server is ready or not.
      • addServerReadyConsumer

        public void addServerReadyConsumer​(Consumer<Server> consumer)
        Adds a consumer which will be informed once the server is ready. If the server is already ready, it will immediately call the consumer, otherwise it will be called from the websocket reading thread.
        Parameters:
        consumer - The consumer which should be called.
      • getIconHash

        public String getIconHash​()
        Gets the icon hash of the server.
        Returns:
        The icon hash of the server.
      • setIconHash

        public void setIconHash​(String iconHash)
        Sets the icon hash of the server.
        Parameters:
        iconHash - The icon hash of the server.
      • getSplashHash

        public String getSplashHash​()
        Gets the splash hash of the server.
        Returns:
        The splash hash of the server.
      • setSplashHash

        public void setSplashHash​(String splashHash)
        Sets the splash hash of the server.
        Parameters:
        splashHash - The splash hash of the server.
      • setSystemChannelId

        public void setSystemChannelId​(long systemChannelId)
        Sets the system channel id of the server.
        Parameters:
        systemChannelId - The system channel id of the server.
      • setAfkChannelId

        public void setAfkChannelId​(long afkChannelId)
        Sets the afk channel id of the server.
        Parameters:
        afkChannelId - The afk channel id of the server.
      • setAfkTimeout

        public void setAfkTimeout​(int afkTimeout)
        Sets the afk timeout of the server.
        Parameters:
        afkTimeout - The afk timeout to set.
      • setVerificationLevel

        public void setVerificationLevel​(VerificationLevel verificationLevel)
        Sets the verification level of the server.
        Parameters:
        verificationLevel - The verification level of the server.
      • setRegion

        public void setRegion​(Region region)
        Sets the region of the server.
        Parameters:
        region - The region of the server.
      • setDefaultMessageNotificationLevel

        public void setDefaultMessageNotificationLevel​(DefaultMessageNotificationLevel defaultMessageNotificationLevel)
        Sets the default message notification level of the server.
        Parameters:
        defaultMessageNotificationLevel - The default message notification level to set.
      • setOwnerId

        public void setOwnerId​(long ownerId)
        Sets the server owner id.
        Parameters:
        ownerId - The owner id to set.
      • setApplicationId

        public void setApplicationId​(long applicationId)
        Sets the application id.
        Parameters:
        applicationId - The application id to set.
      • setExplicitContentFilterLevel

        public void setExplicitContentFilterLevel​(ExplicitContentFilterLevel explicitContentFilterLevel)
        Sets the explicit content filter level of the server.
        Parameters:
        explicitContentFilterLevel - The explicit content filter level to set.
      • setMultiFactorAuthenticationLevel

        public void setMultiFactorAuthenticationLevel​(MultiFactorAuthenticationLevel multiFactorAuthenticationLevel)
        Sets the multi factor authentication level of the server.
        Parameters:
        multiFactorAuthenticationLevel - The multi factor authentication level to set.
      • addChannelToCache

        public void addChannelToCache​(ServerChannel channel)
        Adds a channel to the cache.
        Parameters:
        channel - The channel to add.
      • removeChannelFromCache

        public void removeChannelFromCache​(long channelId)
        Removes a channel from the cache.
        Parameters:
        channelId - The id of the channel to remove.
      • removeRole

        public void removeRole​(long roleId)
        Removes a role from the cache.
        Parameters:
        roleId - The id of the role to remove.
      • addCustomEmoji

        public void addCustomEmoji​(KnownCustomEmoji emoji)
        Adds a custom emoji.
        Parameters:
        emoji - The emoji to add.
      • removeCustomEmoji

        public void removeCustomEmoji​(KnownCustomEmoji emoji)
        Removes a custom emoji.
        Parameters:
        emoji - The emoji to remove.
      • getOrCreateRole

        public Role getOrCreateRole​(com.fasterxml.jackson.databind.JsonNode data)
        Gets or create a new role.
        Parameters:
        data - The json data of the role.
        Returns:
        The role.
      • getOrCreateChannelCategory

        public ChannelCategory getOrCreateChannelCategory​(com.fasterxml.jackson.databind.JsonNode data)
        Gets or creates a channel category.
        Parameters:
        data - The json data of the channel.
        Returns:
        The server text channel.
      • getOrCreateServerTextChannel

        public ServerTextChannel getOrCreateServerTextChannel​(com.fasterxml.jackson.databind.JsonNode data)
        Gets or creates a server text channel.
        Parameters:
        data - The json data of the channel.
        Returns:
        The server text channel.
      • getOrCreateServerVoiceChannel

        public ServerVoiceChannel getOrCreateServerVoiceChannel​(com.fasterxml.jackson.databind.JsonNode data)
        Gets or creates a server voice channel.
        Parameters:
        data - The json data of the channel.
        Returns:
        The server voice channel.
      • removeMember

        public void removeMember​(User user)
        Removes a member from the server.
        Parameters:
        user - The user to remove.
      • decrementMemberCount

        public void decrementMemberCount​()
        Decrements the member count.
      • addMember

        public void addMember​(com.fasterxml.jackson.databind.JsonNode member)
        Adds a member to the server.
        Parameters:
        member - The user to add.
      • incrementMemberCount

        public void incrementMemberCount​()
        Increments the member count.
      • setNickname

        public void setNickname​(User user,
                                String nickname)
        Sets the nickname of the user.
        Parameters:
        user - The user.
        nickname - The nickname to set.
      • setSelfMuted

        public void setSelfMuted​(long userId,
                                 boolean muted)
        Sets the self-muted state of the user with the given id.
        Parameters:
        userId - The id of the user.
        muted - Whether the user with the given id is self-muted or not.
      • setSelfDeafened

        public void setSelfDeafened​(long userId,
                                    boolean deafened)
        Sets the self-deafened state of the user with the given id.
        Parameters:
        userId - The id of the user.
        deafened - Whether the user with the given id is self-deafened or not.
      • setMuted

        public void setMuted​(long userId,
                             boolean muted)
        Sets the muted state of the user with the given id.
        Parameters:
        userId - The id of the user.
        muted - Whether the user with the given id is muted or not.
      • setDeafened

        public void setDeafened​(long userId,
                                boolean deafened)
        Sets the deafened state of the user with the given id.
        Parameters:
        userId - The id of the user.
        deafened - Whether the user with the given id is deafened or not.
      • addMembers

        public void addMembers​(com.fasterxml.jackson.databind.JsonNode members)
        Adds members to the server.
        Parameters:
        members - An array of guild member objects.
      • setName

        public void setName​(String name)
        Sets the name of the server.
        Parameters:
        name - The name of the server.
      • getUnorderedChannels

        public Collection<ServerChannel> getUnorderedChannels​()
        Gets an unordered collection with all channels in the server.
        Returns:
        An unordered collection with all channels in the server.
      • isSelfMuted

        public boolean isSelfMuted​(long userId)
        Specified by:
        isSelfMuted in interface Server
      • isSelfDeafened

        public boolean isSelfDeafened​(long userId)
        Specified by:
        isSelfDeafened in interface Server
      • isMuted

        public boolean isMuted​(long userId)
        Specified by:
        isMuted in interface Server
      • isDeafened

        public boolean isDeafened​(long userId)
        Specified by:
        isDeafened in interface Server
      • isLarge

        public boolean isLarge​()
        Specified by:
        isLarge in interface Server
      • getMemberCount

        public int getMemberCount​()
        Specified by:
        getMemberCount in interface Server
      • isMember

        public boolean isMember​(User user)
        Specified by:
        isMember in interface Server
      • selfMute

        public void selfMute​()
        Specified by:
        selfMute in interface Server
      • selfUnmute

        public void selfUnmute​()
        Specified by:
        selfUnmute in interface Server
      • selfDeafen

        public void selfDeafen​()
        Specified by:
        selfDeafen in interface Server
      • selfUndeafen

        public void selfUndeafen​()
        Specified by:
        selfUndeafen in interface Server
      • cleanup

        public void cleanup​()
        Description copied from interface: Cleanupable
        Does any cleanup that would prevent this instance from being eligible for garbage collection like cancelling scheduled repeated tasks or calling cleanup on "owned" cleanupable objects. This method has to be thread-safe and idempotent.
        Specified by:
        cleanup in interface Cleanupable
      • hashCode

        public int hashCode​()
        Overrides:
        hashCode in class Object