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

      • setSystemChannelFlag

        public void setSystemChannelFlag​(int systemChannelFlag)
        Sets the system channel flags.
        Parameters:
        systemChannelFlag - The system channel flag.
      • 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​(java.util.function.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 java.lang.String getIconHash()
        Gets the icon hash of the server.
        Returns:
        The icon hash of the server.
      • setIconHash

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

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

        public void setSplashHash​(java.lang.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.
      • 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.
      • getOrCreateServerThreadChannel

        public ServerThreadChannel getOrCreateServerThreadChannel​(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.
      • getOrCreateServerStageVoiceChannel

        public ServerStageVoiceChannel getOrCreateServerStageVoiceChannel​(com.fasterxml.jackson.databind.JsonNode data)
        Gets or creates a server stage voice channel.
        Parameters:
        data - The json data of the channel.
        Returns:
        The server stage voice channel.
      • getOrCreateServerForumChannel

        public ServerForumChannel getOrCreateServerForumChannel​(com.fasterxml.jackson.databind.JsonNode data)
        Gets or creates a server forum channel.
        Parameters:
        data - The json data of the channel.
        Returns:
        The server forum channel.
      • getOrCreateUnknownServerChannel

        public UnknownServerChannel getOrCreateUnknownServerChannel​(com.fasterxml.jackson.databind.JsonNode data)
        Gets or creates an unknown server channel.
        Parameters:
        data - The json data of the channel.
        Returns:
        The unknown server channel.
      • getOrCreateUnknownRegularServerChannel

        public UnknownRegularServerChannel getOrCreateUnknownRegularServerChannel​(com.fasterxml.jackson.databind.JsonNode data)
        Gets or creates an unknown regular server channel.
        Parameters:
        data - The json data of the channel.
        Returns:
        The unknown regular server channel.
      • removeMember

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

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

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

        public void incrementMemberCount()
        Increments the member count.
      • addMembers

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

        public java.util.List<Member> addAndGetMembers​(com.fasterxml.jackson.databind.JsonNode membersJson)
        Adds members to the server and returns the added members.
        Parameters:
        membersJson - An array of guild member objects.
        Returns:
        The added members.
      • setName

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

        public void setRulesChannelId​(long rulesChannelId)
        Sets the rules channel of the server.
        Parameters:
        rulesChannelId - The rules channel of the server.
      • setModeratorsOnlyChannelId

        public void setModeratorsOnlyChannelId​(long moderatorsOnlyChannelId)
        Sets the moderators-only channel of the server.
        Parameters:
        moderatorsOnlyChannelId - The moderators-only channel of the server.
      • setBoostLevel

        public void setBoostLevel​(BoostLevel boostLevel)
        Sets the boost level of the server.
        Parameters:
        boostLevel - The boost level of the server.
      • setNsfwLevel

        public void setNsfwLevel​(NsfwLevel nsfwLevel)
        Sets the NSFW level of the server.
        Parameters:
        nsfwLevel - The NSFW level of the server.
      • setPreferredLocale

        public void setPreferredLocale​(java.util.Locale preferredLocale)
        Sets the preferred locale of the server.
        Parameters:
        preferredLocale - The preferred locale of the server.
      • setServerBoostCount

        public void setServerBoostCount​(int serverBoostCount)
        Sets the server boost count of the server.
        Parameters:
        serverBoostCount - The server boost count of the server.
      • setDescription

        public void setDescription​(java.lang.String description)
        Sets the description of the server.
        Parameters:
        description - The description of the server.
      • setDiscoverySplashHash

        public void setDiscoverySplashHash​(java.lang.String discoverySplashHash)
        Sets the discovery splash hash of the server.
        Parameters:
        discoverySplashHash - The discovery splash hash of the server.
      • getDiscoverySplashHash

        public java.lang.String getDiscoverySplashHash()
        Gets the discovery splash hash of the server.
        Returns:
        The discovery splash hash of the server.
      • setVanityUrlCode

        public void setVanityUrlCode​(VanityUrlCode vanityUrlCode)
        Sets the vanity url code of the server.
        Parameters:
        vanityUrlCode - The vanity url code of the server.
      • setServerFeatures

        public void setServerFeatures​(java.util.Collection<ServerFeature> serverFeatures)
        Sets the server feature of the server.
        Parameters:
        serverFeatures - The server feature of the server.
      • setAudioConnection

        public void setAudioConnection​(AudioConnectionImpl audioConnection)
        Sets the audio connection of the server.
        Parameters:
        audioConnection - The audio connection.
      • setPendingAudioConnection

        public void setPendingAudioConnection​(AudioConnectionImpl audioConnection)
        Sets the pending audio connection of the server.

        A pending connection is a connect that is currently trying to connect to a websocket and establish an udp connection but has not finished.

        Parameters:
        audioConnection - The audio connection.
      • removeAudioConnection

        public void removeAudioConnection​(AudioConnection audioConnection)
        Removes an audio connection from the server.
        Parameters:
        audioConnection - The audio connection to remove.
      • getName

        public java.lang.String getName()
        Specified by:
        getName in interface Nameable
      • getDescription

        public java.util.Optional<java.lang.String> getDescription()
        Specified by:
        getDescription in interface Server
      • getPreferredLocale

        public java.util.Locale getPreferredLocale()
        Specified by:
        getPreferredLocale in interface Server
      • getNickname

        public java.util.Optional<java.lang.String> getNickname​(User user)
        Specified by:
        getNickname in interface Server
      • getTimeout

        public java.util.Optional<java.time.Instant> getTimeout​(User user)
        Specified by:
        getTimeout in interface Server
      • getUserServerAvatarHash

        public java.util.Optional<java.lang.String> getUserServerAvatarHash​(User user)
        Specified by:
        getUserServerAvatarHash in interface Server
      • isPending

        public boolean isPending​(long userId)
        Specified by:
        isPending in interface 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
      • getJoinedAtTimestamp

        public java.util.Optional<java.time.Instant> getJoinedAtTimestamp​(User user)
        Specified by:
        getJoinedAtTimestamp in interface Server
      • isLarge

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

        public java.util.Optional<User> getOwner()
        Specified by:
        getOwner in interface Server
      • getOwnerId

        public long getOwnerId()
        Specified by:
        getOwnerId in interface Server
      • getApplicationId

        public java.util.Optional<java.lang.Long> getApplicationId()
        Specified by:
        getApplicationId in interface Server
      • getIcon

        public java.util.Optional<Icon> getIcon()
        Specified by:
        getIcon in interface Server
      • getSplash

        public java.util.Optional<Icon> getSplash()
        Specified by:
        getSplash in interface Server
      • getPruneCount

        public java.util.concurrent.CompletableFuture<java.lang.Integer> getPruneCount​(int days)
        Specified by:
        getPruneCount in interface Server
      • pruneMembers

        public java.util.concurrent.CompletableFuture<java.lang.Integer> pruneMembers​(int days,
                                                                                      java.lang.String reason)
        Specified by:
        pruneMembers in interface Server
      • getInvites

        public java.util.concurrent.CompletableFuture<java.util.Set<RichInvite>> getInvites()
        Specified by:
        getInvites in interface Server
      • getMembers

        public java.util.Set<User> getMembers()
        Specified by:
        getMembers in interface Server
      • getRealMembers

        public java.util.Set<Member> getRealMembers()
        Gets the real member objects of the server.
        Returns:
        The real members.
      • getMemberById

        public java.util.Optional<User> getMemberById​(long id)
        Specified by:
        getMemberById in interface Server
      • getRealMemberById

        public java.util.Optional<Member> getRealMemberById​(long userId)
        Gets the real member object for the user with the given id.
        Parameters:
        userId - The id of the user.
        Returns:
        The real member.
      • isMember

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

        public java.util.List<Role> getRoles()
        Specified by:
        getRoles in interface Server
      • getWidgetChannelId

        public java.util.Optional<java.lang.Long> getWidgetChannelId()
        Specified by:
        getWidgetChannelId in interface Server
      • getMaxPresences

        public java.util.Optional<java.lang.Integer> getMaxPresences()
        Specified by:
        getMaxPresences in interface Server
      • getMaxMembers

        public java.util.Optional<java.lang.Integer> getMaxMembers()
        Specified by:
        getMaxMembers in interface Server
      • getMaxVideoChannelUsers

        public java.util.Optional<java.lang.Integer> getMaxVideoChannelUsers()
        Specified by:
        getMaxVideoChannelUsers in interface Server
      • getRoleById

        public java.util.Optional<Role> getRoleById​(long id)
        Specified by:
        getRoleById in interface Server
      • delete

        public java.util.concurrent.CompletableFuture<java.lang.Void> delete​(java.lang.String reason)
        Specified by:
        delete in interface Deletable
      • leave

        public java.util.concurrent.CompletableFuture<java.lang.Void> leave()
        Specified by:
        leave in interface Server
      • addRoleToUser

        public java.util.concurrent.CompletableFuture<java.lang.Void> addRoleToUser​(User user,
                                                                                    Role role,
                                                                                    java.lang.String reason)
        Specified by:
        addRoleToUser in interface Server
      • removeRoleFromUser

        public java.util.concurrent.CompletableFuture<java.lang.Void> removeRoleFromUser​(User user,
                                                                                         Role role,
                                                                                         java.lang.String reason)
        Specified by:
        removeRoleFromUser in interface Server
      • reorderRoles

        public java.util.concurrent.CompletableFuture<java.lang.Void> reorderRoles​(java.util.List<Role> roles,
                                                                                   java.lang.String reason)
        Specified by:
        reorderRoles 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
      • requestMember

        public java.util.concurrent.CompletableFuture<User> requestMember​(long userId)
        Specified by:
        requestMember in interface Server
      • kickUser

        public java.util.concurrent.CompletableFuture<java.lang.Void> kickUser​(User user,
                                                                               java.lang.String reason)
        Specified by:
        kickUser in interface Server
      • banUser

        public java.util.concurrent.CompletableFuture<java.lang.Void> banUser​(java.lang.String userId,
                                                                              long deleteMessageDuration,
                                                                              java.util.concurrent.TimeUnit unit,
                                                                              java.lang.String reason)
        Specified by:
        banUser in interface Server
      • unbanUser

        public java.util.concurrent.CompletableFuture<java.lang.Void> unbanUser​(long userId,
                                                                                java.lang.String reason)
        Specified by:
        unbanUser in interface Server
      • requestBan

        public java.util.concurrent.CompletableFuture<Ban> requestBan​(long userId)
        Specified by:
        requestBan in interface Server
      • getBans

        public java.util.concurrent.CompletableFuture<java.util.Set<Ban>> getBans​(java.lang.Integer limit,
                                                                                  java.lang.Long after)
        Specified by:
        getBans in interface Server
      • getBans

        public java.util.concurrent.CompletableFuture<java.util.Set<Ban>> getBans()
        Specified by:
        getBans in interface Server
      • getWebhooks

        public java.util.concurrent.CompletableFuture<java.util.List<Webhook>> getWebhooks()
        Specified by:
        getWebhooks in interface Server
      • getAllIncomingWebhooks

        public java.util.concurrent.CompletableFuture<java.util.List<Webhook>> getAllIncomingWebhooks()
        Specified by:
        getAllIncomingWebhooks in interface Server
      • getAuditLog

        public java.util.concurrent.CompletableFuture<AuditLog> getAuditLog​(int limit)
        Specified by:
        getAuditLog in interface Server
      • joinServerThreadChannel

        public java.util.concurrent.CompletableFuture<java.lang.Void> joinServerThreadChannel​(long channelId)
        Specified by:
        joinServerThreadChannel in interface Server
      • leaveServerThreadChannel

        public java.util.concurrent.CompletableFuture<java.lang.Void> leaveServerThreadChannel​(long channelId)
        Specified by:
        leaveServerThreadChannel in interface Server
      • requestStickers

        public java.util.concurrent.CompletableFuture<java.util.Set<Sticker>> requestStickers()
        Specified by:
        requestStickers in interface Server
      • requestStickerById

        public java.util.concurrent.CompletableFuture<Sticker> requestStickerById​(long id)
        Specified by:
        requestStickerById in interface Server
      • addSticker

        public void addSticker​(Sticker sticker)
        Adds a sticker to the server's cache.
        Parameters:
        sticker - The sticker to add to the server's cache.
      • removeSticker

        public void removeSticker​(Sticker sticker)
        Removes a sticker from the server's cache.
        Parameters:
        sticker - The sticker to remove from the server's cache.
      • 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
      • equals

        public boolean equals​(java.lang.Object o)
        Overrides:
        equals in class java.lang.Object
      • hashCode

        public int hashCode()
        Overrides:
        hashCode in class java.lang.Object
      • toString

        public java.lang.String toString()
        Overrides:
        toString in class java.lang.Object