fix(bot,types)!: Remove editOriginalWebhookMessage (#4175)

(and fix editWebhookMessage options type as well)

Fixes: https://github.com/discordeno/discordeno/issues/4174
This commit is contained in:
LTS (Link)
2025-05-04 09:23:11 +02:00
committed by GitHub
parent 31dcf78ec5
commit 4b96d9fe02
6 changed files with 100 additions and 112 deletions
+2 -12
View File
@@ -64,6 +64,7 @@ import type {
EditOwnVoiceState,
EditScheduledEvent,
EditUserVoiceState,
EditWebhookMessageOptions,
ExecuteWebhook,
GetApplicationCommandPermissionOptions,
GetBans,
@@ -244,12 +245,6 @@ export function createBotHelpers<TProps extends TransformersDesiredProperties, T
editOriginalInteractionResponse: async (token, options) => {
return bot.transformers.message(bot, { message: snakelize(await bot.rest.editOriginalInteractionResponse(token, options)), shardId: 0 })
},
editOriginalWebhookMessage: async (webhookId, token, options) => {
return bot.transformers.message(bot, {
message: snakelize(await bot.rest.editOriginalWebhookMessage(webhookId, token, options)) as DiscordMessage,
shardId: 0,
})
},
editRole: async (guildId, roleId, options, reason) => {
return bot.transformers.role(bot, { role: snakelize(await bot.rest.editRole(guildId, roleId, options, reason)), guildId })
},
@@ -929,11 +924,6 @@ export type BotHelpers<TProps extends TransformersDesiredProperties, TBehavior e
editGuildTemplate: (guildId: BigString, templateCode: string, options: ModifyGuildTemplate) => Promise<Template>
editMessage: (channelId: BigString, messageId: BigString, options: EditMessage) => Promise<SetupDesiredProps<Message, TProps, TBehavior>>
editOriginalInteractionResponse: (token: string, options: InteractionCallbackData) => Promise<SetupDesiredProps<Message, TProps, TBehavior>>
editOriginalWebhookMessage: (
webhookId: BigString,
token: string,
options: InteractionCallbackData & { threadId?: BigString },
) => Promise<SetupDesiredProps<Message, TProps, TBehavior>>
editRole: (guildId: BigString, roleId: BigString, options: EditGuildRole, reason?: string) => Promise<SetupDesiredProps<Role, TProps, TBehavior>>
editRolePositions: (guildId: BigString, options: ModifyRolePositions[], reason?: string) => Promise<SetupDesiredProps<Role, TProps, TBehavior>[]>
editScheduledEvent: (
@@ -948,7 +938,7 @@ export type BotHelpers<TProps extends TransformersDesiredProperties, TBehavior e
webhookId: BigString,
token: string,
messageId: BigString,
options: InteractionCallbackData & { threadId?: BigString; withComponents?: boolean },
options: EditWebhookMessageOptions,
) => Promise<SetupDesiredProps<Message, TProps, TBehavior>>
editWebhookWithToken: (
webhookId: BigString,
+58 -70
View File
@@ -1,63 +1,62 @@
import { Buffer } from 'node:buffer'
import {
type BigString,
type Camelize,
type DiscordAccessTokenResponse,
type DiscordActivityInstance,
type DiscordApplication,
type DiscordApplicationCommand,
type DiscordApplicationRoleConnection,
type DiscordApplicationRoleConnectionMetadata,
type DiscordAuditLog,
type DiscordAutoModerationRule,
type DiscordBan,
type DiscordBulkBan,
type DiscordChannel,
type DiscordConnection,
type DiscordCurrentAuthorization,
type DiscordEmoji,
type DiscordEntitlement,
type DiscordFollowedChannel,
type DiscordGetAnswerVotesResponse,
type DiscordGetGatewayBot,
type DiscordGuild,
type DiscordGuildApplicationCommandPermissions,
type DiscordGuildOnboarding,
type DiscordGuildPreview,
type DiscordGuildWidget,
type DiscordGuildWidgetSettings,
type DiscordIncidentsData,
type DiscordIntegration,
type DiscordInteractionCallbackResponse,
type DiscordInvite,
type DiscordInviteMetadata,
type DiscordListActiveThreads,
type DiscordListArchivedThreads,
type DiscordLobby,
type DiscordLobbyMember,
type DiscordMember,
type DiscordMemberWithUser,
type DiscordMessage,
type DiscordPrunedCount,
type DiscordRole,
type DiscordScheduledEvent,
type DiscordSku,
type DiscordSoundboardSound,
type DiscordStageInstance,
type DiscordSticker,
type DiscordStickerPack,
type DiscordSubscription,
type DiscordTemplate,
type DiscordThreadMember,
type DiscordUser,
type DiscordVanityUrl,
type DiscordVoiceRegion,
type DiscordVoiceState,
type DiscordWebhook,
type DiscordWelcomeScreen,
InteractionResponseTypes,
type MfaLevels,
type ModifyGuildTemplate,
import type {
BigString,
Camelize,
DiscordAccessTokenResponse,
DiscordActivityInstance,
DiscordApplication,
DiscordApplicationCommand,
DiscordApplicationRoleConnection,
DiscordApplicationRoleConnectionMetadata,
DiscordAuditLog,
DiscordAutoModerationRule,
DiscordBan,
DiscordBulkBan,
DiscordChannel,
DiscordConnection,
DiscordCurrentAuthorization,
DiscordEmoji,
DiscordEntitlement,
DiscordFollowedChannel,
DiscordGetAnswerVotesResponse,
DiscordGetGatewayBot,
DiscordGuild,
DiscordGuildApplicationCommandPermissions,
DiscordGuildOnboarding,
DiscordGuildPreview,
DiscordGuildWidget,
DiscordGuildWidgetSettings,
DiscordIncidentsData,
DiscordIntegration,
DiscordInteractionCallbackResponse,
DiscordInvite,
DiscordInviteMetadata,
DiscordListActiveThreads,
DiscordListArchivedThreads,
DiscordLobby,
DiscordLobbyMember,
DiscordMember,
DiscordMemberWithUser,
DiscordMessage,
DiscordPrunedCount,
DiscordRole,
DiscordScheduledEvent,
DiscordSku,
DiscordSoundboardSound,
DiscordStageInstance,
DiscordSticker,
DiscordStickerPack,
DiscordSubscription,
DiscordTemplate,
DiscordThreadMember,
DiscordUser,
DiscordVanityUrl,
DiscordVoiceRegion,
DiscordVoiceState,
DiscordWebhook,
DiscordWelcomeScreen,
MfaLevels,
ModifyGuildTemplate,
} from '@discordeno/types'
import {
DISCORDENO_VERSION,
@@ -1000,17 +999,6 @@ export function createRestManager(options: CreateRestManagerOptions): RestManage
})
},
async editOriginalWebhookMessage(webhookId, token, options) {
return await rest.patch<DiscordMessage>(rest.routes.webhooks.original(webhookId, token, options), {
body: {
type: InteractionResponseTypes.UpdateMessage,
data: options,
},
files: options.files,
unauthorized: true,
})
},
async editOwnVoiceState(guildId, options) {
await rest.patch(rest.routes.guilds.voice(guildId), {
body: {
-9
View File
@@ -18,15 +18,6 @@ export function createRoutes(): RestRoutes {
return url
},
original: (webhookId, token, options) => {
let url = `/webhooks/${webhookId}/${token}/messages/@original?`
if (options) {
if (options.threadId) url += `thread_id=${options.threadId}`
}
return url
},
webhook: (webhookId, token, options) => {
let url = `/webhooks/${webhookId}/${token}?`
+2 -19
View File
@@ -98,6 +98,7 @@ import type {
EditOwnVoiceState,
EditScheduledEvent,
EditUserVoiceState,
EditWebhookMessageOptions,
ExecuteWebhook,
FileContent,
GetApplicationCommandPermissionOptions,
@@ -1308,24 +1309,6 @@ export interface RestManager {
* @see {@link https://discord.com/developers/docs/interactions/receiving-and-responding#edit-original-interaction-response}
*/
editOriginalInteractionResponse: (token: string, options: InteractionCallbackData) => Promise<Camelize<DiscordMessage>>
/**
* Edits the original webhook message.
*
* @param webhookId - The ID of the webhook to edit the original message of.
* @param token - The webhook token, used to edit the message.
* @param options - The parameters for the edit of the message.
* @returns An instance of the edited {@link DiscordMessage}.
*
* @remarks
* Fires a _Message Update_ gateway event.
*
* @see {@link https://discord.com/developers/docs/resources/webhook#edit-webhook-message}
*/
editOriginalWebhookMessage: (
webhookId: BigString,
token: string,
options: InteractionCallbackData & { threadId?: BigString },
) => Promise<Camelize<DiscordMessage>>
/**
* Edits the voice state of the bot user.
*
@@ -1483,7 +1466,7 @@ export interface RestManager {
webhookId: BigString,
token: string,
messageId: BigString,
options: InteractionCallbackData & { threadId?: BigString; withComponents?: boolean },
options: EditWebhookMessageOptions,
) => Promise<Camelize<DiscordMessage>>
/**
* Edits a webhook using the webhook token, thereby bypassing the need for authentication + permissions.
-2
View File
@@ -28,8 +28,6 @@ export interface RestRoutes {
stickerPack: (stickerPackId: BigString) => string
/** Routes for webhook related routes. */
webhooks: {
/** Route for managing the original message sent by a webhook. */
original: (webhookId: BigString, token: string, options?: { threadId?: BigString }) => string
/** Route for webhook with a id. */
id: (webhookId: BigString) => string
/** Route for handling a webhook with a token. */
+38
View File
@@ -1116,6 +1116,44 @@ export interface GetWebhookMessageOptions {
threadId: BigString
}
/** https://discord.com/developers/docs/resources/webhook#edit-webhook-message */
export interface EditWebhookMessageOptions {
/** Id of the thread the message is in */
threadId?: BigString
/**
* Whether to respect the `components` field of the request.
* When enabled, allows application-owned webhooks to use all components and non-owned webhooks to use non-interactive components.
*
* @default false
*/
withComponents?: boolean
/** The message contents (up to 2000 characters) */
content?: string
/** Embedded `rich` content */
embeds?: Camelize<DiscordEmbed>[]
/** Allowed mentions for the message */
allowedMentions?: AllowedMentions
/**
* The components to include with the message
*
* @remarks
* Application-owned webhooks can always send components.
* Non-application-owned webhooks cannot send interactive components, and the `components` field will be gnored unless they set the `with_components` query param.
*/
components?: MessageComponents
/** The contents of the files being sent */
files?: FileContent[]
/** Attached files to keep and possible descriptions for new files */
attachments?: (Pick<Camelize<DiscordAttachment>, 'id'> & Omit<Partial<Camelize<DiscordAttachment>>, 'id'>)[]
/**
* A poll!
*
* @remarks
* Polls can only be added when editing a deferred interaction response.
*/
poll?: CreatePoll
}
export interface DeleteWebhookMessageOptions {
/** id of the thread the message is in */
threadId: BigString