Interface DiscordService
- All Known Implementing Classes:
JDADiscordService
public interface DiscordService
A class which provides numerous methods to interact with EssentialsX Discord.
-
Method Summary
Modifier and TypeMethodDescriptionGets theInteractionController
instance.Gets the Discord invite URL given in the EssentialsX Discord configuration.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.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
.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
(MessageType type, String message, boolean allowGroupMentions) Sends a message to a message type channel.
-
Method Details
-
sendMessage
Sends a message to a message type channel.- 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
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
.- Parameters:
player
- The player who send the message.chatMessage
- The chat message the player has sent.
-
sendChatMessage
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
.- Parameters:
player
- The player who send the message.chatMessage
- The chat message the player has sent.
-
isRegistered
Checks if aMessageType
by the given key is already registered.- Parameters:
key
- TheMessageType
key to check.- Returns:
- true if a
MessageType
with the provided key is registered, otherwise false.
-
registerMessageType
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.
- Parameters:
type
- TheMessageType
to be registered.
-
getInteractionController
InteractionController getInteractionController()Gets theInteractionController
instance.- Returns:
- the
InteractionController
instance.
-
getMemberById
Gets anInteractionMember
by their Discord ID.- 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
Gets anInteractionRole
by its Discord ID.- Parameters:
id
- The ID of the role to look up.- Returns:
- the role or null if none by that ID exists.
-
modifyMemberRoles
CompletableFuture<Void> modifyMemberRoles(InteractionMember member, Collection<InteractionRole> addRoles, Collection<InteractionRole> removeRoles) Adds or removesroles
to the givenInteractionMember
. -
getInviteUrl
String getInviteUrl()Gets the Discord invite URL given in the EssentialsX Discord configuration. -
getUnsafe
Unsafe getUnsafe()Gets unstable API that is subject to change at any time.- Returns:
the unsafe
instance.- See Also:
-