Package net.essentialsx.discord.util
Class DiscordUtil
java.lang.Object
net.essentialsx.discord.util.DiscordUtil
-
Field Summary
Modifier and TypeFieldDescriptionstatic final CopyOnWriteArrayList
<String> static final String
static final club.minnced.discord.webhook.send.AllowedMentions
static final String
static final List
<net.dv8tion.jda.api.entities.Message.MentionType> static final club.minnced.discord.webhook.send.AllowedMentions
-
Method Summary
Modifier and TypeMethodDescriptionstatic CompletableFuture
<net.dv8tion.jda.api.entities.Webhook> createWebhook
(net.dv8tion.jda.api.entities.channel.concrete.TextChannel channel, String webhookName) Creates a webhook with the given name in the given channel.static void
dispatchDiscordMessage
(JDADiscordService jda, MessageType messageType, String message, boolean allowPing, String avatarUrl, String name, UUID uuid) static String
getAvatarUrl
(JDADiscordService jda, Player player) static net.dv8tion.jda.api.entities.Role
getHighestRole
(JDADiscordService jda, net.dv8tion.jda.api.entities.Member member, Predicate<net.dv8tion.jda.api.entities.Role> fail) static CompletableFuture
<net.dv8tion.jda.api.entities.Webhook> getOrCreateWebhook
(net.dv8tion.jda.api.entities.channel.concrete.TextChannel channel, String webhookName) Gets or creates a webhook with the given name in the given channel.static String
getRoleColorFormat
(JDADiscordService jda, net.dv8tion.jda.api.entities.Member member) Gets the uppermost bukkit color code of a given member or an empty string if the server version is < 1.16.static String
getRoleFormat
(JDADiscordService jda, net.dv8tion.jda.api.entities.Member member) Gets the highest role of a given member or an empty string if the member has no roles.static WrappedWebhookClient
getWebhookClient
(long id, String token, okhttp3.OkHttpClient client) Creates aWebhookClient
.static boolean
Checks is the supplied user has at least one of the supplied roles.static boolean
matchesRole
(net.dv8tion.jda.api.entities.Role role, String roleDefinition) Checks if the provided role matches the provided role definition (string representation of id or the role's name)
-
Field Details
-
ADVANCED_RELAY_NAME
- See Also:
-
CONSOLE_RELAY_NAME
- See Also:
-
NO_GROUP_MENTIONS
-
ALL_MENTIONS_WEBHOOK
public static final club.minnced.discord.webhook.send.AllowedMentions ALL_MENTIONS_WEBHOOK -
NO_GROUP_MENTIONS_WEBHOOK
public static final club.minnced.discord.webhook.send.AllowedMentions NO_GROUP_MENTIONS_WEBHOOK -
ACTIVE_WEBHOOKS
-
-
Method Details
-
getWebhookClient
public static WrappedWebhookClient getWebhookClient(long id, String token, okhttp3.OkHttpClient client) Creates aWebhookClient
.- Parameters:
id
- The id of the webhook.token
- The token of the webhook.client
- The http client of the webhook.- Returns:
- The
WebhookClient
.
-
getOrCreateWebhook
public static CompletableFuture<net.dv8tion.jda.api.entities.Webhook> getOrCreateWebhook(net.dv8tion.jda.api.entities.channel.concrete.TextChannel channel, String webhookName) Gets or creates a webhook with the given name in the given channel.- Parameters:
channel
- The channel to search for/create webhooks in.webhookName
- The name of the webhook to search for/create.- Returns:
- A future which completes with the webhook by the given name in the given channel, or null if the bot lacks the proper permissions.
-
createWebhook
public static CompletableFuture<net.dv8tion.jda.api.entities.Webhook> createWebhook(net.dv8tion.jda.api.entities.channel.concrete.TextChannel channel, String webhookName) Creates a webhook with the given name in the given channel.- Parameters:
channel
- The channel to search for webhooks in.webhookName
- The name of the webhook to look for.- Returns:
- A future which completes with the webhook by the given name in the given channel or null if no permissions.
-
getHighestRole
public static net.dv8tion.jda.api.entities.Role getHighestRole(JDADiscordService jda, net.dv8tion.jda.api.entities.Member member, Predicate<net.dv8tion.jda.api.entities.Role> fail) -
getRoleFormat
public static String getRoleFormat(JDADiscordService jda, net.dv8tion.jda.api.entities.Member member) Gets the highest role of a given member or an empty string if the member has no roles.- Parameters:
member
- The target member.- Returns:
- The highest role or blank string.
-
getRoleColorFormat
public static String getRoleColorFormat(JDADiscordService jda, net.dv8tion.jda.api.entities.Member member) Gets the uppermost bukkit color code of a given member or an empty string if the server version is < 1.16.- Parameters:
member
- The target member.- Returns:
- The bukkit color code or blank string.
-
hasRoles
public static boolean hasRoles(net.dv8tion.jda.api.entities.Member member, List<String> roleDefinitions) Checks is the supplied user has at least one of the supplied roles.- Parameters:
member
- The member to check.roleDefinitions
- A list with either the name or id of roles.- Returns:
- true if member has role.
-
matchesRole
Checks if the provided role matches the provided role definition (string representation of id or the role's name)- Returns:
- true if the provided definition matches the provided role.
-
getAvatarUrl
-
dispatchDiscordMessage
public static void dispatchDiscordMessage(JDADiscordService jda, MessageType messageType, String message, boolean allowPing, String avatarUrl, String name, UUID uuid)
-