mirror of
https://github.com/discordeno/discordeno.git
synced 2026-06-02 17:00:08 +00:00
follow and cross post endpoints support
This commit is contained in:
@@ -45,6 +45,10 @@ export const endpoints = {
|
||||
`${baseEndpoints.BASE_URL}/channels/${id}/messages/${messageID}/reactions`,
|
||||
CHANNEL_MESSAGE_REACTION: (id: string, messageID: string, emoji: string) =>
|
||||
`${baseEndpoints.BASE_URL}/channels/${id}/messages/${messageID}/reactions/${emoji}`,
|
||||
CHANNEL_FOLLOW: (id: string) =>
|
||||
`${baseEndpoints.BASE_URL}/channels/${id}/followers`,
|
||||
CHANNEL_MESSAGE_CROSSPOST: (id: string, messageID: string) =>
|
||||
`${baseEndpoints.BASE_URL}/channels/${id}/messages/${messageID}/crosspost`,
|
||||
|
||||
// Guild Endpoints
|
||||
GUILD: (id: string) => `${GUILDS_BASE(id)}`,
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
@@ -223,3 +223,11 @@ export async function editMessage(
|
||||
);
|
||||
return createMessage(result as MessageCreateOptions);
|
||||
}
|
||||
|
||||
export async function publishMessage(channelID: string, messageID: string) {
|
||||
const data = await RequestManager.post(
|
||||
endpoints.CHANNEL_MESSAGE_CROSSPOST(channelID, messageID),
|
||||
) as MessageCreateOptions;
|
||||
|
||||
return createMessage(data);
|
||||
}
|
||||
|
||||
@@ -146,3 +146,10 @@ export interface CreateInviteOptions {
|
||||
/** If true, don't try to reuse a similar invite (useful for creating many unique one time use invites.) */
|
||||
unique: boolean;
|
||||
}
|
||||
|
||||
export interface FollowedChannelPayload {
|
||||
/** The source channel id */
|
||||
channel_id: string;
|
||||
/** The webhook id */
|
||||
webhook_id: string;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user