mirror of
https://github.com/discordeno/discordeno.git
synced 2026-06-03 01:10:07 +00:00
feat(plugins/validations): sendMessage at least one prop + support stickers (#2467)
When creating a message, apps must provide a value for **at least one of** `content`, `embeds`, `sticker_ids`, `components`, or `files[n]`. https://discord.com/developers/docs/resources/channel#create-message-jsonform-params
This commit is contained in:
@@ -117,6 +117,7 @@ export async function sendMessage(bot: Bot, channelId: bigint, options: CreateMe
|
||||
},
|
||||
}
|
||||
: {}),
|
||||
sticker_ids: options.stickerIds?.map((sticker) => sticker.toString()),
|
||||
},
|
||||
);
|
||||
|
||||
@@ -152,4 +153,6 @@ export interface CreateMessage {
|
||||
file?: FileContent | FileContent[];
|
||||
/** The components you would like to have sent in this message */
|
||||
components?: MessageComponents;
|
||||
/** IDs of up to 3 stickers in the server to send in the message */
|
||||
stickerIds?: [bigint] | [bigint, bigint] | [bigint, bigint, bigint];
|
||||
}
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
import { AllowedMentionsTypes, Bot } from "../../deps.ts";
|
||||
import { validateComponents } from "../components.ts";
|
||||
import { messages } from "./mod.ts";
|
||||
|
||||
export function sendMessage(bot: Bot) {
|
||||
const sendMessage = bot.helpers.sendMessage;
|
||||
@@ -54,6 +55,12 @@ export function sendMessage(bot: Bot) {
|
||||
|
||||
if (content.components) validateComponents(bot, content.components);
|
||||
|
||||
if (content.content || content.embeds || content.components || content.file || content.stickerIds) {
|
||||
throw new Error(
|
||||
"When sending a message, you must provide a value for at least one of content, embeds, stickerIds, components, or file.",
|
||||
);
|
||||
}
|
||||
|
||||
return sendMessage(channelId, content);
|
||||
};
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user