feat: add nonce to sendMessage options (#2459)

* add nonce to sendMessage options

* add nonce to (Discordeno)Message
This commit is contained in:
LTS20050703
2022-09-12 20:48:38 +07:00
committed by GitHub
parent 08c9f2395b
commit 82653ec0d8
2 changed files with 5 additions and 1 deletions

View File

@@ -39,6 +39,7 @@ export async function sendMessage(bot: Bot, channelId: bigint, options: CreateMe
bot.constants.routes.CHANNEL_MESSAGES(channelId),
{
content: options.content,
nonce: options.nonce,
tts: options.tts,
embeds: options.embeds?.map((embed) => bot.transformers.reverse.embed(bot, embed)),
allowed_mentions: options.allowedMentions
@@ -125,6 +126,8 @@ export async function sendMessage(bot: Bot, channelId: bigint, options: CreateMe
export interface CreateMessage {
/** The message contents (up to 2000 characters) */
content?: string;
/** Can be used to verify a message was sent (up to 25 characters). Value will appear in the Message Create event. */
nonce?: string | number;
/** true if this is a TTS message */
tts?: boolean;
/** Embedded `rich` content (up to 6000 characters) */

View File

@@ -1,8 +1,8 @@
import { Bot } from "../bot.ts";
import { DiscordMessage } from "../types/discord.ts";
import { Optionalize } from "../types/shared.ts";
import { CHANNEL_MENTION_REGEX } from "../util/constants.ts";
import { MemberToggles } from "./toggles/member.ts";
import { Optionalize } from "../types/shared.ts";
export function transformMessage(bot: Bot, payload: DiscordMessage) {
const guildId = payload.guild_id ? bot.transformers.snowflake(payload.guild_id) : undefined;
@@ -104,6 +104,7 @@ export function transformMessage(bot: Bot, payload: DiscordMessage) {
),
],
member: payload.member && guildId ? bot.transformers.member(bot, payload.member, guildId, userId) : undefined,
nonce: payload.nonce,
};
return message as Optionalize<typeof message>;