diff --git a/src/helpers/interactions/commands/batch_edit_slash_command_permissions.ts b/src/helpers/interactions/commands/batch_edit_slash_command_permissions.ts index 5671947d5..502a45933 100644 --- a/src/helpers/interactions/commands/batch_edit_slash_command_permissions.ts +++ b/src/helpers/interactions/commands/batch_edit_slash_command_permissions.ts @@ -1,13 +1,11 @@ -import { applicationId } from "../../../bot.ts"; -import { rest } from "../../../rest/rest.ts"; +import type {Bot} from "../../../bot.ts"; import type { ApplicationCommandPermissions } from "../../../types/interactions/commands/application_command_permissions.ts"; -import { endpoints } from "../../../util/constants.ts"; -import { snakelize } from "../../../util/utils.ts"; /** Batch edits permissions for all commands in a guild. Takes an array of partial GuildApplicationCommandPermissions objects including `id` and `permissions`. */ export async function batchEditSlashCommandPermissions( + bot: Bot, guildId: bigint, options: { id: string; permissions: ApplicationCommandPermissions[] }[] ) { - return await rest.runMethod("put", endpoints.COMMANDS_PERMISSIONS(applicationId, guildId), snakelize(options)); + return await bot.rest.runMethod(bot.rest,"put", bot.constants.endpoints.COMMANDS_PERMISSIONS(bot.applicationId, guildId), options); } diff --git a/src/helpers/interactions/commands/create_slash_command.ts b/src/helpers/interactions/commands/create_slash_command.ts index 26a989827..6448fc6e7 100644 --- a/src/helpers/interactions/commands/create_slash_command.ts +++ b/src/helpers/interactions/commands/create_slash_command.ts @@ -1,9 +1,6 @@ -import { applicationId } from "../../../bot.ts"; -import { rest } from "../../../rest/rest.ts"; import type { ApplicationCommand } from "../../../types/interactions/commands/application_command.ts"; import type { CreateGlobalApplicationCommand } from "../../../types/interactions/commands/create_global_application_command.ts"; -import { endpoints } from "../../../util/constants.ts"; -import { snakelize, validateSlashCommands } from "../../../util/utils.ts"; +import type {Bot} from "../../../bot.ts"; /** * There are two kinds of Slash Commands: global commands and guild commands. Global commands are available for every guild that adds your app; guild commands are specific to the guild you specify when making them. Command names are unique per application within each scope (global and guild). That means: @@ -16,12 +13,13 @@ import { snakelize, validateSlashCommands } from "../../../util/utils.ts"; * Global commands are cached for **1 hour**. That means that new global commands will fan out slowly across all guilds, and will be guaranteed to be updated in an hour. * Guild commands update **instantly**. We recommend you use guild commands for quick testing, and global commands when they're ready for public use. */ -export async function createSlashCommand(options: CreateGlobalApplicationCommand, guildId?: bigint) { - [options] = validateSlashCommands([options], true) as CreateGlobalApplicationCommand[]; +export async function createSlashCommand(bot: Bot, options: CreateGlobalApplicationCommand, guildId?: bigint) { + [options] = bot.utils.validateSlashCommands([options], true) as CreateGlobalApplicationCommand[]; - return await rest.runMethod( + return await bot.rest.runMethod( + bot.rest, "post", - guildId ? endpoints.COMMANDS_GUILD(applicationId, guildId) : endpoints.COMMANDS(applicationId), - snakelize(options) + guildId ? bot.constants.endpoints.COMMANDS_GUILD(bot.applicationId, guildId) : bot.constants.endpoints.COMMANDS(bot.applicationId), + options ); } diff --git a/src/helpers/interactions/commands/delete_slash_command.ts b/src/helpers/interactions/commands/delete_slash_command.ts index d4e8c71b2..5fb105ecc 100644 --- a/src/helpers/interactions/commands/delete_slash_command.ts +++ b/src/helpers/interactions/commands/delete_slash_command.ts @@ -1,11 +1,10 @@ -import { applicationId } from "../../../bot.ts"; -import { rest } from "../../../rest/rest.ts"; -import { endpoints } from "../../../util/constants.ts"; +import type { Bot} from "../../../bot.ts"; /** Deletes a slash command. */ -export async function deleteSlashCommand(id: bigint, guildId?: bigint) { - return await rest.runMethod( +export async function deleteSlashCommand(bot: Bot, id: bigint, guildId?: bigint) { + return await bot.rest.runMethod( + bot.rest, "delete", - guildId ? endpoints.COMMANDS_GUILD_ID(applicationId, guildId, id) : endpoints.COMMANDS_ID(applicationId, id) + guildId ? bot.constants.endpoints.COMMANDS_GUILD_ID(bot.applicationId, guildId, id) : bot.constants.endpoints.COMMANDS_ID(bot.applicationId, id) ); } diff --git a/src/helpers/interactions/commands/delete_slash_response.ts b/src/helpers/interactions/commands/delete_slash_response.ts index 25f1a1c59..70b26c320 100644 --- a/src/helpers/interactions/commands/delete_slash_response.ts +++ b/src/helpers/interactions/commands/delete_slash_response.ts @@ -1,13 +1,12 @@ -import { applicationId } from "../../../bot.ts"; -import { rest } from "../../../rest/rest.ts"; -import { endpoints } from "../../../util/constants.ts"; +import type {Bot} from "../../../bot.ts"; /** To delete your response to a slash command. If a message id is not provided, it will default to deleting the original response. */ -export async function deleteSlashResponse(token: string, messageId?: bigint) { - return await rest.runMethod( +export async function deleteSlashResponse(bot: Bot, token: string, messageId?: bigint) { + return await bot.rest.runMethod( + bot.rest, "delete", messageId - ? endpoints.INTERACTION_ID_TOKEN_MESSAGE_ID(applicationId, token, messageId) - : endpoints.INTERACTION_ORIGINAL_ID_TOKEN(applicationId, token) + ? bot.constants.endpoints.INTERACTION_ID_TOKEN_MESSAGE_ID(bot.applicationId, token, messageId) + : bot.constants.endpoints.INTERACTION_ORIGINAL_ID_TOKEN(bot.applicationId, token) ); } diff --git a/src/helpers/interactions/commands/edit_slash_command_permissions.ts b/src/helpers/interactions/commands/edit_slash_command_permissions.ts index d633d7080..3ccdb9e4d 100644 --- a/src/helpers/interactions/commands/edit_slash_command_permissions.ts +++ b/src/helpers/interactions/commands/edit_slash_command_permissions.ts @@ -1,16 +1,14 @@ -import { applicationId } from "../../../bot.ts"; -import { rest } from "../../../rest/rest.ts"; import type { ApplicationCommandPermissions } from "../../../types/interactions/commands/application_command_permissions.ts"; -import { endpoints } from "../../../util/constants.ts"; -import { snakelize } from "../../../util/utils.ts"; +import type {Bot} from "../../../bot.ts"; /** Edits command permissions for a specific command for your application in a guild. */ export async function editSlashCommandPermissions( + bot: Bot, guildId: bigint, commandId: bigint, options: ApplicationCommandPermissions[] ) { - return await rest.runMethod("put", endpoints.COMMANDS_PERMISSION(applicationId, guildId, commandId), { - permissions: snakelize(options), + return await bot.rest.runMethod(bot.rest,"put", bot.constants.endpoints.COMMANDS_PERMISSION(bot.applicationId, guildId, commandId), { + permissions: options, }); } diff --git a/src/helpers/interactions/commands/edit_slash_response.ts b/src/helpers/interactions/commands/edit_slash_response.ts index 22b058875..4cf36ffa6 100644 --- a/src/helpers/interactions/commands/edit_slash_response.ts +++ b/src/helpers/interactions/commands/edit_slash_response.ts @@ -1,20 +1,15 @@ -import { applicationId } from "../../../bot.ts"; -import { rest } from "../../../rest/rest.ts"; -import { structures } from "../../../structures/mod.ts"; import type { DiscordenoEditWebhookMessage } from "../../../types/discordeno/edit_webhook_message.ts"; -import { Errors } from "../../../types/discordeno/errors.ts"; -import { DiscordAllowedMentionsTypes } from "../../../types/messages/allowed_mentions_types.ts"; -import { endpoints } from "../../../util/constants.ts"; -import { snakelize, validateComponents } from "../../../util/utils.ts"; +import type {Bot} from "../../../bot.ts"; +import {DiscordAllowedMentionsTypes} from "../../../types/messages/allowed_mentions_types.ts"; /** To edit your response to a slash command. If a messageId is not provided it will default to editing the original response. */ -export async function editSlashResponse(token: string, options: DiscordenoEditWebhookMessage) { +export async function editSlashResponse(bot: Bot, token: string, options: DiscordenoEditWebhookMessage) { if (options.content && options.content.length > 2000) { - throw Error(Errors.MESSAGE_MAX_LENGTH); + throw Error(bot.constants.Errors.MESSAGE_MAX_LENGTH); } if (options.components?.length) { - validateComponents(options.components); + bot.utils.validateComponents(bot, options.components); } if (options.embeds && options.embeds.length > 10) { @@ -43,17 +38,31 @@ export async function editSlashResponse(token: string, options: DiscordenoEditWe } } - const result = await rest.runMethod( + const result = await bot.rest.runMethod( + bot.rest, "patch", options.messageId - ? endpoints.WEBHOOK_MESSAGE(applicationId, token, options.messageId) - : endpoints.INTERACTION_ORIGINAL_ID_TOKEN(applicationId, token), - snakelize(options) + ? bot.constants.endpoints.WEBHOOK_MESSAGE(bot.applicationId, token, options.messageId) + : bot.constants.endpoints.INTERACTION_ORIGINAL_ID_TOKEN(bot.applicationId, token), + { + content: options.content, + embeds: options.embeds, + file: options.file, + allowed_mentions: options.allowedMentions ? { + parse: options.allowedMentions.parse, + roles: options.allowedMentions.roles, + users: options.allowedMentions.users, + replied_user: options.allowedMentions.repliedUser + } : undefined, + attachments: options.attachments, + // TODO: Snakelize components?? + components: options.components, + message_id: options.messageId, + } ); // If the original message was edited, this will not return a message if (!options.messageId) return result as undefined; - const message = await structures.createDiscordenoMessage(result); - return message; + return bot.transformers.message(result); } diff --git a/src/helpers/interactions/commands/get_slash_command.ts b/src/helpers/interactions/commands/get_slash_command.ts index 80b5fc3d6..8e0acdebf 100644 --- a/src/helpers/interactions/commands/get_slash_command.ts +++ b/src/helpers/interactions/commands/get_slash_command.ts @@ -1,21 +1,18 @@ -import { applicationId } from "../../../bot.ts"; -import { rest } from "../../../rest/rest.ts"; import type { ApplicationCommand } from "../../../types/interactions/commands/application_command.ts"; -import { snowflakeToBigint } from "../../../util/bigint.ts"; -import { endpoints } from "../../../util/constants.ts"; +import type {Bot} from "../../../bot.ts"; -/** Fetchs the global command for the given Id. If a guildId is provided, the guild command will be fetched. */ -export async function getSlashCommand(commandId: bigint, guildId?: bigint) { - const result = await rest.runMethod( +/** Fetches the global command for the given Id. If a guildId is provided, the guild command will be fetched. */ +export async function getSlashCommand(bot: Bot, commandId: bigint, guildId?: bigint) { + const result = await bot.rest.runMethod( "get", guildId - ? endpoints.COMMANDS_GUILD_ID(applicationId, guildId, commandId) - : endpoints.COMMANDS_ID(applicationId, commandId) + ? bot.constants.endpoints.COMMANDS_GUILD_ID(bot.applicationId, guildId, commandId) + : bot.constants.endpoints.COMMANDS_ID(bot.applicationId, commandId) ); return { ...result, - id: snowflakeToBigint(result.id), - applicationId: snowflakeToBigint(result.applicationId), + id: bot.transformers.snowflake(result.id), + applicationId: bot.transformers.snowflake(result.applicationId), }; } diff --git a/src/helpers/interactions/commands/get_slash_command_permission.ts b/src/helpers/interactions/commands/get_slash_command_permission.ts index 55bc8a7a7..86fafe5a9 100644 --- a/src/helpers/interactions/commands/get_slash_command_permission.ts +++ b/src/helpers/interactions/commands/get_slash_command_permission.ts @@ -1,12 +1,11 @@ -import { applicationId } from "../../../bot.ts"; -import { rest } from "../../../rest/rest.ts"; import type { GuildApplicationCommandPermissions } from "../../../types/interactions/commands/guild_application_command_permissions.ts"; -import { endpoints } from "../../../util/constants.ts"; +import type {Bot} from "../../../bot.ts"; /** Fetches command permissions for a specific command for your application in a guild. Returns a GuildApplicationCommandPermissions object. */ -export async function getSlashCommandPermission(guildId: bigint, commandId: bigint) { - return await rest.runMethod( +export async function getSlashCommandPermission(bot: Bot, guildId: bigint, commandId: bigint) { + return await bot.rest.runMethod( + bot.rest, "get", - endpoints.COMMANDS_PERMISSION(applicationId, guildId, commandId) + bot.constants.endpoints.COMMANDS_PERMISSION(bot.applicationId, guildId, commandId) ); } diff --git a/src/helpers/interactions/commands/get_slash_command_permissions.ts b/src/helpers/interactions/commands/get_slash_command_permissions.ts index 1206371e2..6f7a54df1 100644 --- a/src/helpers/interactions/commands/get_slash_command_permissions.ts +++ b/src/helpers/interactions/commands/get_slash_command_permissions.ts @@ -1,12 +1,11 @@ -import { applicationId } from "../../../bot.ts"; -import { rest } from "../../../rest/rest.ts"; +import type {Bot} from "../../../bot.ts"; import type { GuildApplicationCommandPermissions } from "../../../types/interactions/commands/guild_application_command_permissions.ts"; -import { endpoints } from "../../../util/constants.ts"; /** Fetches command permissions for all commands for your application in a guild. Returns an array of GuildApplicationCommandPermissions objects. */ -export async function getSlashCommandPermissions(guildId: bigint) { - return await rest.runMethod( +export async function getSlashCommandPermissions(bot: Bot, guildId: bigint) { + return await bot.rest.runMethod( + bot.rest, "get", - endpoints.COMMANDS_PERMISSIONS(applicationId, guildId) + bot.constants.endpoints.COMMANDS_PERMISSIONS(bot.applicationId, guildId) ); } diff --git a/src/helpers/interactions/commands/get_slash_commands.ts b/src/helpers/interactions/commands/get_slash_commands.ts index 11cf8f6d4..cbba87954 100644 --- a/src/helpers/interactions/commands/get_slash_commands.ts +++ b/src/helpers/interactions/commands/get_slash_commands.ts @@ -1,21 +1,19 @@ -import { applicationId } from "../../../bot.ts"; -import { rest } from "../../../rest/rest.ts"; import type { ApplicationCommand } from "../../../types/interactions/commands/application_command.ts"; -import { snowflakeToBigint } from "../../../util/bigint.ts"; import { Collection } from "../../../util/collection.ts"; -import { endpoints } from "../../../util/constants.ts"; +import type {Bot} from "../../../bot.ts"; -/** Fetch all of the global commands for your application. */ -export async function getSlashCommands(guildId?: bigint) { - const result = await rest.runMethod( +/** Fetch all the global commands for your application. */ +export async function getSlashCommands(bot: Bot, guildId?: bigint) { + const result = await bot.rest.runMethod( + bot.rest, "get", - guildId ? endpoints.COMMANDS_GUILD(applicationId, guildId) : endpoints.COMMANDS(applicationId) + guildId ? bot.constants.endpoints.COMMANDS_GUILD(bot.applicationId, guildId) : bot.constants.endpoints.COMMANDS(bot.applicationId) ); return new Collection( result.map((command) => [ command.name, - { ...command, id: snowflakeToBigint(command.id), applicationId: snowflakeToBigint(command.applicationId) }, + { ...command, id: bot.transformers.snowflake(command.id), applicationId: bot.transformers.snowflake(command.applicationId) }, ]) ); } diff --git a/src/helpers/interactions/commands/upsert_slash_command.ts b/src/helpers/interactions/commands/upsert_slash_command.ts index 9b6c40e7e..765209862 100644 --- a/src/helpers/interactions/commands/upsert_slash_command.ts +++ b/src/helpers/interactions/commands/upsert_slash_command.ts @@ -1,21 +1,19 @@ -import { applicationId } from "../../../bot.ts"; -import { rest } from "../../../rest/rest.ts"; import type { ApplicationCommand } from "../../../types/interactions/commands/application_command.ts"; import type { EditGlobalApplicationCommand } from "../../../types/interactions/commands/edit_global_application_command.ts"; -import { endpoints } from "../../../util/constants.ts"; -import { validateSlashCommands } from "../../../util/utils.ts"; +import type {Bot} from "../../../bot.ts"; /** * Edit an existing slash command. If this command did not exist, it will create it. */ -export async function upsertSlashCommand(commandId: bigint, options: EditGlobalApplicationCommand, guildId?: bigint) { - [options] = validateSlashCommands([options]); +export async function upsertSlashCommand(bot: Bot, commandId: bigint, options: EditGlobalApplicationCommand, guildId?: bigint) { + [options] = bot.utils.validateSlashCommands([options]); - return await rest.runMethod( + return await bot.rest.runMethod( + bot.rest, "patch", guildId - ? endpoints.COMMANDS_GUILD_ID(applicationId, guildId, commandId) - : endpoints.COMMANDS_ID(applicationId, commandId), + ? bot.constants.endpoints.COMMANDS_GUILD_ID(bot.applicationId, guildId, commandId) + : bot.constants.endpoints.COMMANDS_ID(bot.applicationId, commandId), options ); } diff --git a/src/helpers/interactions/commands/upsert_slash_commands.ts b/src/helpers/interactions/commands/upsert_slash_commands.ts index a3604c7cd..99e32c571 100644 --- a/src/helpers/interactions/commands/upsert_slash_commands.ts +++ b/src/helpers/interactions/commands/upsert_slash_commands.ts @@ -1,10 +1,7 @@ -import { applicationId } from "../../../bot.ts"; -import { rest } from "../../../rest/rest.ts"; import type { ApplicationCommand } from "../../../types/interactions/commands/application_command.ts"; import type { EditGlobalApplicationCommand } from "../../../types/interactions/commands/edit_global_application_command.ts"; -import { MakeRequired } from "../../../types/util.ts"; -import { endpoints } from "../../../util/constants.ts"; -import { validateSlashCommands } from "../../../util/utils.ts"; +import type { MakeRequired } from "../../../types/util.ts"; +import type {Bot} from "../../../bot.ts"; /** * Bulk edit existing slash commands. If a command does not exist, it will create it. @@ -12,14 +9,16 @@ import { validateSlashCommands } from "../../../util/utils.ts"; * **NOTE:** Any slash commands that are not specified in this function will be **deleted**. If you don't provide the commandId and rename your command, the command gets a new Id. */ export async function upsertSlashCommands( + bot: Bot, options: MakeRequired[], guildId?: bigint ) { - options = validateSlashCommands(options) as MakeRequired[]; + options = bot.utils.validateSlashCommands(options) as MakeRequired[]; - return await rest.runMethod( + return await bot.rest.runMethod( + bot.rest, "put", - guildId ? endpoints.COMMANDS_GUILD(applicationId, guildId) : endpoints.COMMANDS(applicationId), + guildId ? bot.constants.endpoints.COMMANDS_GUILD(bot.applicationId, guildId) : bot.constants.endpoints.COMMANDS(bot.applicationId), options ); } diff --git a/src/helpers/interactions/get_original_interaction_response.ts b/src/helpers/interactions/get_original_interaction_response.ts index 51a72d268..d2a0ee7e3 100644 --- a/src/helpers/interactions/get_original_interaction_response.ts +++ b/src/helpers/interactions/get_original_interaction_response.ts @@ -1,12 +1,10 @@ -import { applicationId } from "../../bot.ts"; -import { rest } from "../../rest/rest.ts"; -import { structures } from "../../structures/mod.ts"; +import type {Bot} from "../../bot.ts"; import type { Message } from "../../types/messages/message.ts"; -import { endpoints } from "../../util/constants.ts"; +import type {SnakeCasedPropertiesDeep} from "../../types/util.ts"; -/** Returns the initial Interactio response. Functions the same as Get Webhook Message */ -export async function getOriginalInteractionResponse(token: string) { - const result = await rest.runMethod("get", endpoints.INTERACTION_ORIGINAL_ID_TOKEN(applicationId, token)); +/** Returns the initial Interaction response. Functions the same as Get Webhook Message */ +export async function getOriginalInteractionResponse(bot: Bot, token: string) { + const result = await bot.rest.runMethod>(bot.rest,"get", bot.constants.endpoints.INTERACTION_ORIGINAL_ID_TOKEN(bot.applicationId, token)); - return await structures.createDiscordenoMessage(result); + return bot.transformers.message(result); } diff --git a/src/helpers/interactions/send_interaction_response.ts b/src/helpers/interactions/send_interaction_response.ts index ebf995ee6..006f96ea7 100644 --- a/src/helpers/interactions/send_interaction_response.ts +++ b/src/helpers/interactions/send_interaction_response.ts @@ -1,9 +1,10 @@ -import { applicationId, eventHandlers } from "../../bot.ts"; -import { cache } from "../../cache.ts"; -import { rest } from "../../rest/rest.ts"; import type { DiscordenoInteractionResponse } from "../../types/discordeno/interaction_response.ts"; -import { endpoints } from "../../util/constants.ts"; -import { snakelize, validateComponents } from "../../util/utils.ts"; +import type {Bot} from "../../bot.ts"; +import {Embed} from "../../types/embeds/embed.ts"; +import {AllowedMentions} from "../../types/messages/allowed_mentions.ts"; +import {MessageReference} from "../../types/messages/message_reference.ts"; +import {FileContent} from "../../types/discordeno/file_content.ts"; +import {MessageComponents} from "../../types/messages/components/message_components.ts"; // TODO: v12 remove | string /** @@ -13,12 +14,13 @@ import { snakelize, validateComponents } from "../../util/utils.ts"; * NOTE: By default we will suppress mentions. To enable mentions, just pass any mentions object. */ export async function sendInteractionResponse( - id: bigint | string, - token: string, - options: DiscordenoInteractionResponse + bot: Bot, + id: bigint | string, + token: string, + options: DiscordenoInteractionResponse ) { // TODO: add more options validations - if (options.data?.components) validateComponents(options.data?.components); + if (options.data?.components) bot.utils.validateComponents(bot, options.data?.components); // If the user wants this as a private message mark it ephemeral if (options.private) { @@ -31,8 +33,32 @@ export async function sendInteractionResponse( } // If its already been executed, we need to send a followup response - if (cache.executedSlashCommands.has(token)) { - return await rest.runMethod("post", endpoints.WEBHOOK(applicationId, token), snakelize(options.data)); + if (bot.cache.executedSlashCommands.has(token)) { + return await bot.rest.runMethod(bot.rest,"post", bot.cosntants.endpoints.WEBHOOK(bot.applicationId, token), { + content: options.data.content, + tts: options.data.tts, + embeds: options.data.embeds, + allowed_mentions: { + parse: options.data.allowedMentions.parse, + roles: options.data.allowedMentions.roles, + users: options.data.allowedMentions.users, + replied_user: options.data.allowedMentions.repliedUser + }, + ...(options.data.messageReference?.messageId + ? { + message_reference: { + message_id: options.data.messageReference.messageId, + channel_id: options.data.messageReference.channelId, + guild_id: options.data.messageReference.guildId, + fail_if_not_exists: options.data.messageReference.failIfNotExists === true, + }, + } + : {}), + file: options.data.file, + // TODO: Snakelize components?? + components: options.data.components, + flags: options.data.flags + }); } // Expire in 15 minutes @@ -42,9 +68,34 @@ export async function sendInteractionResponse( cache.executedSlashCommands.delete(token); }, 900000); - return await rest.runMethod( - "post", - endpoints.INTERACTION_ID_TOKEN(typeof id === "bigint" ? id : BigInt(id), token), - snakelize(options) + return await bot.rest.runMethod( + bot.rest, + "post", + bot.constants.endpoints.INTERACTION_ID_TOKEN(typeof id === "bigint" ? id : bot.transformers.snowflake(id), token), + { + content: options.data.content, + tts: options.data.tts, + embeds: options.data.embeds, + allowed_mentions: { + parse: options.data.allowedMentions.parse, + roles: options.data.allowedMentions.roles, + users: options.data.allowedMentions.users, + replied_user: options.data.allowedMentions.repliedUser + }, + ...(options.data.messageReference?.messageId + ? { + message_reference: { + message_id: options.data.messageReference.messageId, + channel_id: options.data.messageReference.channelId, + guild_id: options.data.messageReference.guildId, + fail_if_not_exists: options.data.messageReference.failIfNotExists === true, + }, + } + : {}), + file: options.data.file, + // TODO: Snakelize components?? + components: options.data.components, + flags: options.data.flags + } ); } diff --git a/src/helpers/interactions/verify_signature.ts b/src/helpers/interactions/verify_signature.ts index 18fe8febe..f6f4a1806 100644 --- a/src/helpers/interactions/verify_signature.ts +++ b/src/helpers/interactions/verify_signature.ts @@ -1,5 +1,4 @@ -export { verify } from "https://unpkg.com/@evan/wasm@0.0.65/target/ed25519/deno.js"; -import { verify } from "./deps.ts"; +import { verify } from "https://unpkg.com/@evan/wasm@0.0.87/target/ed25519/deno.js"; export function verifySignature({ publicKey, signature, timestamp, body }: VerifySignatureOptions): { isValid: boolean; diff --git a/src/helpers/messages/send_message.ts b/src/helpers/messages/send_message.ts index e3ac7c724..fcde4b26b 100644 --- a/src/helpers/messages/send_message.ts +++ b/src/helpers/messages/send_message.ts @@ -78,12 +78,25 @@ export async function sendMessage(bot: Bot, channelId: bigint, content: string | "post", bot.constants.endpoints.CHANNEL_MESSAGES(channelId), bot.utils.snakelize({ - ...content, + content: content.content, + tts: content.tts, + embeds: content.embeds, + allowed_mentions: { + parse: content.allowedMentions.parse, + roles: content.allowedMentions.roles, + users: content.allowedMentions.users, + replied_user: content.allowedMentions.repliedUser + }, + file: content.file, + // TODO: Snakelize components?? + components: content.components, ...(content.messageReference?.messageId ? { - messageReference: { - ...content.messageReference, - failIfNotExists: content.messageReference.failIfNotExists === true, + message_reference: { + message_id: content.messageReference.messageId, + channel_id: content.messageReference.channelId, + guild_id: content.messageReference.guildId, + fail_if_not_exists: content.messageReference.failIfNotExists === true, }, } : {}), diff --git a/src/helpers/webhooks/edit_webhook_message.ts b/src/helpers/webhooks/edit_webhook_message.ts index 0e6a0b26f..4ffd8e84e 100644 --- a/src/helpers/webhooks/edit_webhook_message.ts +++ b/src/helpers/webhooks/edit_webhook_message.ts @@ -54,8 +54,14 @@ export async function editWebhookMessage( content: options.content, embeds: options.embeds, file: options.file, - allowedMentions: options.allowed_mentions, + allowed_mentions: { + parse: content.allowedMentions.parse, + roles: content.allowedMentions.roles, + users: content.allowedMentions.users, + replied_user: content.allowedMentions.repliedUser + }, attachments: options.attachments, + // TODO: Snakelize components?? components: options.components, message_id: options.messageId, }