Class DiscordUtil

java.lang.Object
net.essentialsx.discord.util.DiscordUtil

public final class DiscordUtil extends Object
  • Field Details

    • ADVANCED_RELAY_NAME

      public static final String ADVANCED_RELAY_NAME
      See Also:
    • CONSOLE_RELAY_NAME

      public static final String CONSOLE_RELAY_NAME
      See Also:
    • NO_GROUP_MENTIONS

      public static final List<net.dv8tion.jda.api.entities.Message.MentionType> 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

      public static final CopyOnWriteArrayList<String> ACTIVE_WEBHOOKS
  • Method Details

    • getWebhookClient

      public static WrappedWebhookClient getWebhookClient(long id, String token, okhttp3.OkHttpClient client)
      Creates a WebhookClient.
      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

      public 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)
      Returns:
      true if the provided definition matches the provided role.
    • getAvatarUrl

      public static String getAvatarUrl(JDADiscordService jda, Player player)
    • dispatchDiscordMessage

      public static void dispatchDiscordMessage(JDADiscordService jda, MessageType messageType, String message, boolean allowPing, String avatarUrl, String name, UUID uuid)