Skip to content

Commit

Permalink
Implement GuildChannel#getJumpUrl (#2204)
Browse files Browse the repository at this point in the history
  • Loading branch information
jasonlessenich committed Aug 13, 2022
1 parent 6d849dd commit ed816ac
Showing 1 changed file with 16 additions and 0 deletions.
16 changes: 16 additions & 0 deletions src/main/java/net/dv8tion/jda/api/entities/GuildChannel.java
Expand Up @@ -3,6 +3,7 @@
import net.dv8tion.jda.api.JDA;
import net.dv8tion.jda.api.managers.channel.ChannelManager;
import net.dv8tion.jda.api.requests.restaction.AuditableRestAction;
import net.dv8tion.jda.internal.utils.Helpers;

import javax.annotation.CheckReturnValue;
import javax.annotation.Nonnull;
Expand All @@ -18,6 +19,9 @@
*/
public interface GuildChannel extends Channel, Comparable<GuildChannel>
{
/** Template for {@link #getJumpUrl()}.*/
String JUMP_URL = "https://discord.com/channels/%s/%s";

/**
* Returns the {@link net.dv8tion.jda.api.entities.Guild Guild} that this GuildChannel is part of.
*
Expand Down Expand Up @@ -72,4 +76,16 @@ public interface GuildChannel extends Channel, Comparable<GuildChannel>

//TODO-v5: Docs
IPermissionContainer getPermissionContainer();

/**
* Returns the jump-to URL for this channel. Clicking this URL in the Discord client will cause the client to
* jump to the specified channel.
*
* @return A String representing the jump-to URL for the channel.
*/
@Nonnull
default String getJumpUrl()
{
return Helpers.format(JUMP_URL, getGuild().getId(), getId());
}
}

0 comments on commit ed816ac

Please sign in to comment.