feat(GuildChannelManager): add .addFollower() method (#8567)

* feat(GuildChannelManager): add `.addFollower()` method

* docs: dpply suggestions

Co-authored-by: Jiralite <33201955+Jiralite@users.noreply.github.com>

* fix: resolve from `GuildChannelManager`

Co-authored-by: Jiralite <33201955+Jiralite@users.noreply.github.com>

* types: correct channel type

* docs: update description

Co-authored-by: A. Román <kyradiscord@gmail.com>

* docs: update description

Co-authored-by: A. Román <kyradiscord@gmail.com>

Co-authored-by: Jiralite <33201955+Jiralite@users.noreply.github.com>
Co-authored-by: A. Román <kyradiscord@gmail.com>
Co-authored-by: kodiakhq[bot] <49736102+kodiakhq[bot]@users.noreply.github.com>
This commit is contained in:
Synbulat Biishev
2022-10-16 19:04:30 +03:00
committed by GitHub
parent 4f3c13628e
commit caeb1cbfdb
2 changed files with 23 additions and 0 deletions

View File

@@ -98,6 +98,24 @@ class GuildChannelManager extends CachedManager {
return super.resolveId(channel);
}
/**
* 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(ErrorCodes.GuildChannelResolve);
const { webhook_id } = await this.client.rest.post(Routes.channelFollowers(channelId), {
body: { webhook_channel_id: targetChannelId },
reason,
});
return webhook_id;
}
/**
* Options used to create a new channel in a guild.
* @typedef {CategoryCreateChannelOptions} GuildChannelCreateOptions

View File

@@ -3457,6 +3457,11 @@ export class GuildChannelManager extends CachedManager<Snowflake, GuildBasedChan
public get channelCountWithoutThreads(): number;
public guild: Guild;
public addFollower(
channel: NewsChannel | Snowflake,
targetChannel: TextChannelResolvable,
reason?: string,
): Promise<Snowflake>;
public create<T extends GuildChannelTypes>(
options: GuildChannelCreateOptions & { type: T },
): Promise<MappedGuildChannelTypes[T]>;