mirror of
https://github.com/discordeno/discordeno.git
synced 2026-06-04 09:50:07 +00:00
* p1 of bigints change * shtuff fixes and bits * Commit from GitHub Actions (Lint) * finish bigint structs * typings fixes * Commit from GitHub Actions (Lint) * more fixes * Commit from GitHub Actions (Lint) * more fixes * Commit from GitHub Actions (Lint) * blame wolf * Commit from GitHub Actions (Lint) * foxed * Commit from GitHub Actions (Lint) * fix unit tests * Commit from GitHub Actions (Lint) * change: guildUpdate guild ID can't change * delete server has been renamed to delete guild * fixes Co-authored-by: Skillz4Killz <Skillz4Killz@users.noreply.github.com> Co-authored-by: ITOH <72305210+itohatweb@users.noreply.github.com>
71 lines
2.0 KiB
TypeScript
71 lines
2.0 KiB
TypeScript
import { rest } from "../../rest/rest.ts";
|
|
import { structures } from "../../structures/mod.ts";
|
|
import { DiscordAllowedMentionsTypes } from "../../types/messages/allowed_mentions_types.ts";
|
|
import { Message } from "../../types/messages/message.ts";
|
|
import { Errors } from "../../types/misc/errors.ts";
|
|
import { EditWebhookMessage } from "../../types/webhooks/edit_webhook_message.ts";
|
|
import { endpoints } from "../../util/constants.ts";
|
|
|
|
export async function editWebhookMessage(
|
|
webhookId: bigint,
|
|
webhookToken: string,
|
|
messageId: bigint,
|
|
options: EditWebhookMessage,
|
|
) {
|
|
if (options.content && options.content.length > 2000) {
|
|
throw Error(Errors.MESSAGE_MAX_LENGTH);
|
|
}
|
|
|
|
if (options.embeds && options.embeds.length > 10) {
|
|
options.embeds.splice(10);
|
|
}
|
|
|
|
if (options.allowedMentions) {
|
|
if (options.allowedMentions.users?.length) {
|
|
if (
|
|
options.allowedMentions.parse?.includes(
|
|
DiscordAllowedMentionsTypes.UserMentions,
|
|
)
|
|
) {
|
|
options.allowedMentions.parse = options.allowedMentions.parse.filter(
|
|
(p) => p !== "users",
|
|
);
|
|
}
|
|
|
|
if (options.allowedMentions.users.length > 100) {
|
|
options.allowedMentions.users = options.allowedMentions.users.slice(
|
|
0,
|
|
100,
|
|
);
|
|
}
|
|
}
|
|
|
|
if (options.allowedMentions.roles?.length) {
|
|
if (
|
|
options.allowedMentions.parse?.includes(
|
|
DiscordAllowedMentionsTypes.RoleMentions,
|
|
)
|
|
) {
|
|
options.allowedMentions.parse = options.allowedMentions.parse.filter(
|
|
(p) => p !== "roles",
|
|
);
|
|
}
|
|
|
|
if (options.allowedMentions.roles.length > 100) {
|
|
options.allowedMentions.roles = options.allowedMentions.roles.slice(
|
|
0,
|
|
100,
|
|
);
|
|
}
|
|
}
|
|
}
|
|
|
|
const result = await rest.runMethod<Message>(
|
|
"patch",
|
|
endpoints.WEBHOOK_MESSAGE(webhookId, webhookToken, messageId),
|
|
{ ...options, allowedMentions: options.allowedMentions },
|
|
);
|
|
|
|
return await structures.createDiscordenoMessage(result);
|
|
}
|