Package net.essentialsx.discord
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 Summary
-
Method Summary
Modifier and TypeMethodDescriptionnet.dv8tion.jda.api.entities.channel.concrete.TextChannel
getChannel
(String key, boolean primaryFallback) net.dv8tion.jda.api.entities.channel.concrete.TextChannel
getDefinedChannel
(String key, boolean primaryFallback) net.dv8tion.jda.api.entities.Guild
getGuild()
Gets theInteractionController
instance.Gets the Discord invite URL given in the EssentialsX Discord configuration.net.dv8tion.jda.api.JDA
getJda()
getMemberById
(String id) Gets anInteractionMember
by their Discord ID.Gets anInteractionRole
by its Discord ID.Gets unstable API that is subject to change at any time.club.minnced.discord.webhook.send.WebhookMessage
getWebhookMessage
(String message) club.minnced.discord.webhook.send.WebhookMessage
getWebhookMessage
(String message, String avatarUrl, String name, boolean groupMentions) boolean
isDebug()
boolean
boolean
isRegistered
(String key) Checks if aMessageType
by the given key is already registered.modifyMemberRoles
(InteractionMember member, Collection<InteractionRole> addRoles, Collection<InteractionRole> removeRoles) Adds or removesroles
to the givenInteractionMember
.parseMessageEmotes
(String message) void
registerMessageType
(Plugin plugin, MessageType type) Registers a message type to be used in the future.void
sendChatMessage
(net.essentialsx.api.v2.ChatType chatType, Player player, String chatMessage) 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.void
sendChatMessage
(Player player, String chatMessage) Sends a chat message to thedefault chat channel
with the same format used for regular chat messages specified in the EssentialsX Discord configuration.void
sendMessage
(DiscordMessageEvent event, String message, boolean groupMentions) void
sendMessage
(MessageType type, String message, boolean allowGroupMentions) Sends a message to a message type channel.void
shutdown()
void
startup()
void
void
void
void
void
-
Constructor Details
-
JDADiscordService
-
-
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
-
getWebhookMessage
-
sendMessage
-
startup
- Throws:
LoginException
InterruptedException
-
isRegistered
Description copied from interface:DiscordService
Checks if aMessageType
by the given key is already registered.- Specified by:
isRegistered
in interfaceDiscordService
- Parameters:
key
- TheMessageType
key to check.- Returns:
- true if a
MessageType
with the provided key is registered, otherwise false.
-
registerMessageType
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 interfaceDiscordService
- Parameters:
type
- TheMessageType
to be registered.
-
sendMessage
Description copied from interface:DiscordService
Sends a message to a message type channel.- Specified by:
sendMessage
in interfaceDiscordService
- 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
Description copied from interface:DiscordService
Sends a chat message to thedefault 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 interfaceDiscordService
- 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 interfaceDiscordService
- Parameters:
player
- The player who send the message.chatMessage
- The chat message the player has sent.
-
getInteractionController
Description copied from interface:DiscordService
Gets theInteractionController
instance.- Specified by:
getInteractionController
in interfaceDiscordService
- Returns:
- the
InteractionController
instance.
-
updatePrimaryChannel
public void updatePrimaryChannel() -
parseMessageEmotes
-
updateListener
public void updateListener() -
updatePresence
public void updatePresence() -
updateTypesRelay
public void updateTypesRelay() -
updateConsoleRelay
public void updateConsoleRelay() -
shutdown
public void shutdown() -
getMemberById
Description copied from interface:DiscordService
Gets anInteractionMember
by their Discord ID.- Specified by:
getMemberById
in interfaceDiscordService
- 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
Description copied from interface:DiscordService
Gets anInteractionRole
by its Discord ID.- Specified by:
getRole
in interfaceDiscordService
- 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 removesroles
to the givenInteractionMember
.- Specified by:
modifyMemberRoles
in interfaceDiscordService
- Parameters:
member
- The member to add/remove roles to/from.addRoles
- The roles to add to themember
, or null to add none.removeRoles
- The roles to remove from themember
, or null to remove none.- Returns:
- A future which will complete when all requests operations have been completed.
-
getInviteUrl
Description copied from interface:DiscordService
Gets the Discord invite URL given in the EssentialsX Discord configuration.- Specified by:
getInviteUrl
in interfaceDiscordService
-
getJda
public net.dv8tion.jda.api.JDA getJda() -
getUnsafe
Description copied from interface:DiscordService
Gets unstable API that is subject to change at any time.- Specified by:
getUnsafe
in interfaceDiscordService
- Returns:
the unsafe
instance.- See Also:
-
getGuild
public net.dv8tion.jda.api.entities.Guild getGuild() -
getPlugin
-
getSettings
-
getConsoleWebhook
-
isInvalidStartup
public boolean isInvalidStartup() -
isDebug
public boolean isDebug()
-