Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat v13: add addFollower on GuildChannelManager #9050

Merged
merged 2 commits into from
Feb 17, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
18 changes: 18 additions & 0 deletions src/managers/GuildChannelManager.js
Original file line number Diff line number Diff line change
Expand Up @@ -229,6 +229,24 @@ class GuildChannelManager extends CachedManager {
return new Webhook(this.client, data);
}

/**
* Adds the target channel to a channel's followers.
* @param {NewsChannel|Snowflake} channel The channel to follow
* @param {TextChannelResolvable} targetChannel The channel where published announcements will be posted at
* @param {string} [reason] Reason for creating the webhook
* @returns {Promise<Snowflake>} Returns created target webhook id.
*/
async addFollower(channel, targetChannel, reason) {
const channelId = this.resolveId(channel);
const targetChannelId = this.resolveId(targetChannel);
if (!channelId || !targetChannelId) throw new Error('GUILD_CHANNEL_RESOLVE');
const { webhook_id } = await this.client.api.channels[channelId].followers.post({
data: { webhook_channel_id: targetChannelId },
reason,
});
return webhook_id;
}

/**
* The data for a guild channel.
* @typedef {Object} ChannelData
Expand Down
1 change: 1 addition & 0 deletions src/structures/NewsChannel.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ const { Error } = require('../errors');
class NewsChannel extends BaseGuildTextChannel {
/**
* Adds the target to this channel's followers.
* <info>If you need the created webhook id, use {@link GuildChannelManager#addFollower}.</info>
SpaceEEC marked this conversation as resolved.
Show resolved Hide resolved
* @param {TextChannelResolvable} channel The channel where the webhook should be created
* @param {string} [reason] Reason for creating the webhook
* @returns {Promise<NewsChannel>}
Expand Down
5 changes: 5 additions & 0 deletions typings/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3316,6 +3316,11 @@ export class GuildChannelManager extends CachedManager<Snowflake, GuildBasedChan
name: string,
options?: TextChannel | NewsChannel | VoiceChannel | Snowflake,
): Promise<Webhook>;
public addFollower(
channel: NewsChannel | Snowflake,
targetChannel: TextChannelResolvable,
reason?: string,
): Promise<Snowflake>;
public edit(channel: GuildChannelResolvable, data: ChannelData, reason?: string): Promise<GuildChannel>;
public fetch(id: Snowflake, options?: BaseFetchOptions): Promise<GuildBasedChannel | null>;
public fetch(
Expand Down