Class JDADiscordService

java.lang.Object
net.essentialsx.discord.JDADiscordService
All Implemented Interfaces:
com.earth2me.essentials.IEssentialsModule, DiscordService

public class JDADiscordService extends Object implements DiscordService, com.earth2me.essentials.IEssentialsModule
  • Constructor Details

  • Method Details

    • getChannel

      public net.dv8tion.jda.api.entities.channel.concrete.TextChannel getChannel(String key, boolean primaryFallback)
    • getDefinedChannel

      public net.dv8tion.jda.api.entities.channel.concrete.TextChannel getDefinedChannel(String key, boolean primaryFallback)
    • getWebhookMessage

      public club.minnced.discord.webhook.send.WebhookMessage getWebhookMessage(String message)
    • getWebhookMessage

      public club.minnced.discord.webhook.send.WebhookMessage getWebhookMessage(String message, String avatarUrl, String name, boolean groupMentions)
    • sendMessage

      public void sendMessage(DiscordMessageEvent event, String message, boolean groupMentions)
    • startup

      public void startup() throws LoginException, InterruptedException
      Throws:
      LoginException
      InterruptedException
    • isRegistered

      public boolean isRegistered(String key)
      Description copied from interface: DiscordService
      Checks if a MessageType by the given key is already registered.
      Specified by:
      isRegistered in interface DiscordService
      Parameters:
      key - The MessageType key to check.
      Returns:
      true if a MessageType with the provided key is registered, otherwise false.
    • registerMessageType

      public void registerMessageType(Plugin plugin, MessageType type)
      Description copied from interface: DiscordService
      Registers a message type to be used in the future.

      In the future, this method will automatically populate the message type in the EssentialsX Discord config.

      Specified by:
      registerMessageType in interface DiscordService
      type - The MessageType to be registered.
    • sendMessage

      public void sendMessage(MessageType type, String message, boolean allowGroupMentions)
      Description copied from interface: DiscordService
      Sends a message to a message type channel.
      Specified by:
      sendMessage in interface DiscordService
      Parameters:
      type - The message type/destination of this message.
      message - The exact message to be sent.
      allowGroupMentions - Whether the message should allow the pinging of roles, @here, or @everyone.
    • sendChatMessage

      public void sendChatMessage(Player player, String chatMessage)
      Description copied from interface: DiscordService
      Sends a chat message to the default chat channel with the same format used for regular chat messages specified in the EssentialsX Discord configuration.

      Note: Messages sent with this method will not fire a DiscordChatMessageEvent.

      Specified by:
      sendChatMessage in interface DiscordService
      Parameters:
      player - The player who send the message.
      chatMessage - The chat message the player has sent.
    • sendChatMessage

      public void sendChatMessage(net.essentialsx.api.v2.ChatType chatType, Player player, String chatMessage)
      Description copied from interface: DiscordService
      Sends a chat message to the appropriate chat channel depending on the chat type with the format specified for that type in the EssentialsX Discord configuration.

      Note: Messages sent with this method will not fire a DiscordChatMessageEvent.

      Specified by:
      sendChatMessage in interface DiscordService
      player - The player who send the message.
      chatMessage - The chat message the player has sent.
    • getInteractionController

      public InteractionController getInteractionController()
      Description copied from interface: DiscordService
      Gets the InteractionController instance.
      Specified by:
      getInteractionController in interface DiscordService
      Returns:
      the InteractionController instance.
    • updatePrimaryChannel

      public void updatePrimaryChannel()
    • parseMessageEmotes

      public String parseMessageEmotes(String message)
    • updateListener

      public void updateListener()
    • updatePresence

      public void updatePresence()
    • updateTypesRelay

      public void updateTypesRelay()
    • updateConsoleRelay

      public void updateConsoleRelay()
    • shutdown

      public void shutdown()
    • getMemberById

      public CompletableFuture<InteractionMember> getMemberById(String id)
      Description copied from interface: DiscordService
      Gets an InteractionMember by their Discord ID.
      Specified by:
      getMemberById in interface DiscordService
      Parameters:
      id - The ID of the member to look up.
      Returns:
      A future which will complete with the member or null if none is reachable.
    • getRole

      public InteractionRole getRole(String id)
      Description copied from interface: DiscordService
      Gets an InteractionRole by its Discord ID.
      Specified by:
      getRole in interface DiscordService
      Parameters:
      id - The ID of the role to look up.
      Returns:
      the role or null if none by that ID exists.
    • modifyMemberRoles

      public CompletableFuture<Void> modifyMemberRoles(InteractionMember member, Collection<InteractionRole> addRoles, Collection<InteractionRole> removeRoles)
      Description copied from interface: DiscordService
      Adds or removes roles to the given InteractionMember.
      Specified by:
      modifyMemberRoles in interface DiscordService
      Parameters:
      member - The member to add/remove roles to/from.
      addRoles - The roles to add to the member, or null to add none.
      removeRoles - The roles to remove from the member, or null to remove none.
      Returns:
      A future which will complete when all requests operations have been completed.
    • getInviteUrl

      public String getInviteUrl()
      Description copied from interface: DiscordService
      Gets the Discord invite URL given in the EssentialsX Discord configuration.
      Specified by:
      getInviteUrl in interface DiscordService
    • getJda

      public net.dv8tion.jda.api.JDA getJda()
    • getUnsafe

      public Unsafe getUnsafe()
      Description copied from interface: DiscordService
      Gets unstable API that is subject to change at any time.
      Specified by:
      getUnsafe in interface DiscordService
      Returns:
      the unsafe instance.
      See Also:
    • getGuild

      public net.dv8tion.jda.api.entities.Guild getGuild()
    • getPlugin

      public EssentialsDiscord getPlugin()
    • getSettings

      public DiscordSettings getSettings()
    • getConsoleWebhook

      public WrappedWebhookClient getConsoleWebhook()
    • isInvalidStartup

      public boolean isInvalidStartup()
    • isDebug

      public boolean isDebug()