mirror of
https://github.com/discordeno/discordeno.git
synced 2026-06-16 11:28:15 +00:00
follow and cross post endpoints support
This commit is contained in:
@@ -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;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user