follow and cross post endpoints support

This commit is contained in:
Skillz
2020-08-31 15:59:31 -04:00
parent 090921b9e6
commit 7a09d9989e
4 changed files with 41 additions and 0 deletions
+22
View File
@@ -17,6 +17,7 @@ import {
MessageContent,
CreateInviteOptions,
ChannelEditOptions,
FollowedChannelPayload,
} from "../types/channel.ts";
import { logYellow } from "../utils/logger.ts";
@@ -340,3 +341,24 @@ export function editChannel(channel: Channel, options: ChannelEditOptions) {
payload,
);
}
/** Follow a News Channel to send messages to a target channel. Requires the `MANAGE_WEBHOOKS` permission in the target channel. Returns the webhook id. */
export async function followChannel(
sourceChannelID: string,
targetChannelID: string,
) {
if (
!botHasChannelPermissions(targetChannelID, [Permissions.MANAGE_WEBHOOKS])
) {
throw new Error(Errors.MISSING_MANAGE_CHANNELS);
}
const data = await RequestManager.post(
endpoints.CHANNEL_FOLLOW(sourceChannelID),
{
webhook_channel_id: targetChannelID,
},
) as FollowedChannelPayload;
return data.webhook_id;
}