From f59d6305cb0cd0d154a909f18be76407c4d452d3 Mon Sep 17 00:00:00 2001 From: Milo <50248166+Milo123459@users.noreply.github.com> Date: Wed, 9 Feb 2022 08:18:30 +0000 Subject: [PATCH] feat(channel): add .url getter (#7402) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: Rodry <38259440+ImRodry@users.noreply.github.com> Co-authored-by: Almeida Co-authored-by: Antonio Román --- packages/discord.js/src/structures/Channel.js | 9 +++++++++ packages/discord.js/typings/index.d.ts | 1 + 2 files changed, 10 insertions(+) diff --git a/packages/discord.js/src/structures/Channel.js b/packages/discord.js/src/structures/Channel.js index e460e9821..b5d85be8a 100644 --- a/packages/discord.js/src/structures/Channel.js +++ b/packages/discord.js/src/structures/Channel.js @@ -57,6 +57,15 @@ class Channel extends Base { return new Date(this.createdTimestamp); } + /** + * The URL to the channel + * @type {string} + * @readonly + */ + get url() { + return `https://discord.com/channels/${this.isDMBased() ? '@me' : this.guildId}/${this.id}`; + } + /** * Whether this Channel is a partial * This is always false outside of DM channels. diff --git a/packages/discord.js/typings/index.d.ts b/packages/discord.js/typings/index.d.ts index d5bec6404..c83568496 100644 --- a/packages/discord.js/typings/index.d.ts +++ b/packages/discord.js/typings/index.d.ts @@ -494,6 +494,7 @@ export abstract class Channel extends Base { public id: Snowflake; public readonly partial: false; public type: ChannelType; + public readonly url: string; public delete(): Promise; public fetch(force?: boolean): Promise; public isText(): this is TextChannel;