Package net.dv8tion.jda.api.utils
Class WidgetUtil
java.lang.Object
net.dv8tion.jda.api.utils.WidgetUtil
The WidgetUtil is a class for interacting with various facets of Discord's
guild widgets
- Since:
- 3.0
- Author:
- John A. Grosh
-
Nested Class Summary
Modifier and TypeClassDescriptionstatic enum
Represents the available banner types
Each of these has a different appearance:static enum
Represents the color scheme of the widget
These color themes match Discord's dark and light themes -
Field Summary
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionstatic String
getPremadeWidgetHtml
(String guildId, WidgetUtil.WidgetTheme theme, int width, int height) Gets the pre-made HTML Widget for the specified guild using the specified settings.static String
getPremadeWidgetHtml
(Guild guild, WidgetUtil.WidgetTheme theme, int width, int height) Gets the pre-made HTML Widget for the specified guild using the specified settings.static Widget
getWidget
(long guildId) Makes a GET request to get the information for a Guild's widget.static Widget
Makes a GET request to get the information for a Guild's widget.static String
getWidgetBanner
(String guildId, WidgetUtil.BannerType type) Gets the banner image for the specified guild of the specified type.static String
getWidgetBanner
(Guild guild, WidgetUtil.BannerType type) Gets the banner image for the specified guild of the specified type.
-
Field Details
-
WIDGET_PNG
- See Also:
-
WIDGET_URL
- See Also:
-
WIDGET_HTML
- See Also:
-
-
Constructor Details
-
WidgetUtil
public WidgetUtil()
-
-
Method Details
-
getWidgetBanner
@Nonnull public static String getWidgetBanner(@Nonnull Guild guild, @Nonnull WidgetUtil.BannerType type) Gets the banner image for the specified guild of the specified type.
This banner will only be available if the guild in question has the Widget enabled.- Parameters:
guild
- The guildtype
- The type (visual style) of the banner- Returns:
- A String containing the URL of the banner image
-
getWidgetBanner
@Nonnull public static String getWidgetBanner(@Nonnull String guildId, @Nonnull WidgetUtil.BannerType type) Gets the banner image for the specified guild of the specified type.
This banner will only be available if the guild in question has the Widget enabled. Additionally, this method can be used independently of being on the guild in question.- Parameters:
guildId
- the guild IDtype
- The type (visual style) of the banner- Returns:
- A String containing the URL of the banner image
-
getPremadeWidgetHtml
@Nonnull public static String getPremadeWidgetHtml(@Nonnull Guild guild, @Nonnull WidgetUtil.WidgetTheme theme, int width, int height) Gets the pre-made HTML Widget for the specified guild using the specified settings. The widget will only display correctly if the guild in question has the Widget enabled.- Parameters:
guild
- the guildtheme
- the theme, light or darkwidth
- the width of the widgetheight
- the height of the widget- Returns:
- a String containing the pre-made widget with the supplied settings
-
getPremadeWidgetHtml
@Nonnull public static String getPremadeWidgetHtml(@Nonnull String guildId, @Nonnull WidgetUtil.WidgetTheme theme, int width, int height) Gets the pre-made HTML Widget for the specified guild using the specified settings. The widget will only display correctly if the guild in question has the Widget enabled. Additionally, this method can be used independently of being on the guild in question.- Parameters:
guildId
- the guild IDtheme
- the theme, light or darkwidth
- the width of the widgetheight
- the height of the widget- Returns:
- a String containing the pre-made widget with the supplied settings
-
getWidget
Makes a GET request to get the information for a Guild's widget. This widget (if available) contains information about the guild, including the Guild's name, an invite code (if set), a list of voice channels, and a list of online members (plus the voice states of any members in voice channels).This Widget can be obtained from any valid guild ID that has it enabled; no accounts need to be on the server to access this information.
- Parameters:
guildId
- The id of the Guild- Returns:
null
if the provided guild ID is not a valid Discord guild ID
a Widget object with null fields and isAvailable() returning false if the guild ID is valid but the guild in question does not have the widget enabled
a filled-in Widget object if the guild ID is valid and the guild in question has the widget enabled.- Throws:
RateLimitedException
- If the request was rate limited, respect the timeout!NumberFormatException
- If the providedguildId
cannot be parsed byLong.parseLong(String)
-
getWidget
Makes a GET request to get the information for a Guild's widget. This widget (if available) contains information about the guild, including the Guild's name, an invite code (if set), a list of voice channels, and a list of online members (plus the voice states of any members in voice channels).This Widget can be obtained from any valid guild ID that has it enabled; no accounts need to be on the server to access this information.
- Parameters:
guildId
- The id of the Guild- Returns:
null
if the provided guild ID is not a valid Discord guild ID
a Widget object with null fields and isAvailable() returning false if the guild ID is valid but the guild in question does not have the widget enabled
a filled-in Widget object if the guild ID is valid and the guild in question has the widget enabled.- Throws:
UncheckedIOException
- If an I/O error occursRateLimitedException
- If the request was rate limited, respect the timeout!
-