Skip to content

Commit

Permalink
Support for the Guild Resource Navigation (#1197)
Browse files Browse the repository at this point in the history
* Support for the Guild Resource Navigation

* Avoid depend on the enum declaration for name

* feat: add Guild#getResourceNavigationMention method

* fix: fix rebase issue

* fix: re-add missing format due to rebase conflicts

* fix: fix misunderstanding of discord's format

---------

Co-authored-by: Axel Joly <azn9.pro@gmail.com>
  • Loading branch information
Doc94 and Azn9 committed May 19, 2024
1 parent e9ddfb4 commit fd2cfd3
Showing 1 changed file with 55 additions and 0 deletions.
55 changes: 55 additions & 0 deletions core/src/main/java/discord4j/core/object/entity/Guild.java
Original file line number Diff line number Diff line change
Expand Up @@ -1042,6 +1042,16 @@ public int getMaxPresences() {
return Possible.flatOpt(data.maxPresences()).orElse(DEFAULT_MAX_PRESENCES);
}

/**
* Gets the mention for the given {@link ResourceNavigation} channel.
*
* @param resourceNavigation The {@link ResourceNavigation} to get the mention for.
* @return The mention for the given {@link ResourceNavigation} channel.
*/
public String getResourceNavigationMention(ResourceNavigation resourceNavigation) {
return resourceNavigation.getMention();
}

/**
* Gets the maximum amount of members of the guild, if present.
*
Expand Down Expand Up @@ -2487,6 +2497,51 @@ public static GuildFeature of(final String value) {

}

/**
* Describes guild navigation types.
*
* @see <a href="https://discord.com/developers/docs/reference#message-formatting-guild-navigation-types">Discord Docs</a>
*/
public enum ResourceNavigation {
/** Customize tab with the server's onboarding prompts */
CUSTOMIZE("customize"),
/** Browse Channels tab */
BROWSE("browse"),
/** Server Guide */
GUIDE("guide"),
;

/** The underlying value as represented by Discord. */
private final String value;

/**
* Constructs an {@code Guild.ResourceNavigation}.
*
* @param value The underlying value as represented by Discord.
*/
ResourceNavigation(final String value) {
this.value = value;
}

/**
* Gets the underlying value as represented by Discord.
*
* @return The underlying value as represented by Discord.
*/
public String getValue() {
return value;
}

/**
* Gets the <i>raw</i> mention. This is the format utilized to directly mention guild resource.
*
* @return The <i>raw</i> mention.
*/
public String getMention() {
return "<id:" + this.value + ">";
}
}

@Override
public String toString() {
return "Guild{" +
Expand Down

0 comments on commit fd2cfd3

Please sign in to comment.