diff --git a/deps.ts b/deps.ts index 842c7c13b..c6ca70f87 100644 --- a/deps.ts +++ b/deps.ts @@ -1 +1 @@ -export { encode } from "https://deno.land/std@0.90.0/encoding/base64.ts"; +export { encode } from "https://deno.land/std@0.95.0/encoding/base64.ts"; diff --git a/mod.ts b/mod.ts index 152fd637a..131b9e0e1 100644 --- a/mod.ts +++ b/mod.ts @@ -3,12 +3,7 @@ export * from "./src/cache.ts"; export * from "./src/handlers/mod.ts"; export * from "./src/helpers/mod.ts"; export * from "./src/rest/mod.ts"; -export * from "./src/structures/channel.ts"; -export * from "./src/structures/guild.ts"; -export * from "./src/structures/member.ts"; -export * from "./src/structures/message.ts"; export * from "./src/structures/mod.ts"; -export * from "./src/structures/role.ts"; export * from "./src/types/mod.ts"; export * from "./src/util/mod.ts"; export * from "./src/ws/mod.ts"; diff --git a/src/helpers/interactions/send_interaction_response.ts b/src/helpers/interactions/send_interaction_response.ts index dae5c23bd..9c873cd7d 100644 --- a/src/helpers/interactions/send_interaction_response.ts +++ b/src/helpers/interactions/send_interaction_response.ts @@ -3,6 +3,7 @@ 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 { validateComponents } from "../../util/utils.ts"; /** * Send a response to a users slash command. The command data will have the id and token necessary to respond. @@ -15,6 +16,8 @@ export async function sendInteractionResponse( token: string, options: DiscordenoInteractionResponse, ) { + // TODO: add more options validations + if (options.data?.components) validateComponents(options.data?.components); // If its already been executed, we need to send a followup response if (cache.executedSlashCommands.has(token)) { return await rest.runMethod( @@ -28,16 +31,13 @@ export async function sendInteractionResponse( // Expire in 15 minutes cache.executedSlashCommands.add(token); - setTimeout( - () => { - eventHandlers.debug?.( - "loop", - `Running setTimeout in send_interaction_response file.`, - ); - cache.executedSlashCommands.delete(token); - }, - 900000, - ); + setTimeout(() => { + eventHandlers.debug?.( + "loop", + `Running setTimeout in send_interaction_response file.`, + ); + cache.executedSlashCommands.delete(token); + }, 900000); // If the user wants this as a private message mark it ephemeral if (options.private) { diff --git a/src/structures/mod.ts b/src/structures/mod.ts index b5e55bbc4..220d793b8 100644 --- a/src/structures/mod.ts +++ b/src/structures/mod.ts @@ -5,6 +5,13 @@ import { createDiscordenoMessage } from "./message.ts"; import { createDiscordenoRole } from "./role.ts"; import { createDiscordenoVoiceState } from "./voice_state.ts"; +import type { DiscordenoChannel } from "./channel.ts"; +import type { DiscordenoGuild } from "./guild.ts"; +import type { DiscordenoMember } from "./member.ts"; +import type { DiscordenoMessage } from "./message.ts"; +import type { DiscordenoRole } from "./role.ts"; +import type { DiscordenoVoiceState } from "./voice_state.ts"; + /** This is the placeholder where the structure creation functions are kept. */ export let structures = { createDiscordenoChannel, @@ -15,7 +22,14 @@ export let structures = { createDiscordenoVoiceState, }; -// export type { Channel, Guild, Member, Message, Role, Template }; +export type { + DiscordenoChannel, + DiscordenoGuild, + DiscordenoMember, + DiscordenoMessage, + DiscordenoRole, + DiscordenoVoiceState, +}; export type Structures = typeof structures; @@ -23,7 +37,7 @@ export type Structures = typeof structures; * * ⚠️ **ADVANCED USE ONLY: If you customize this incorrectly, you could potentially create many new errors/bugs. * Please take caution when using this.** -*/ + */ export function updateStructures(newStructures: Structures) { structures = { ...structures, diff --git a/src/types/interactions/commands/application_command_callback_data.ts b/src/types/interactions/commands/application_command_callback_data.ts index 6857815af..b14415e5c 100644 --- a/src/types/interactions/commands/application_command_callback_data.ts +++ b/src/types/interactions/commands/application_command_callback_data.ts @@ -1,5 +1,6 @@ import { Embed } from "../../embeds/embed.ts"; import { AllowedMentions } from "../../messages/allowed_mentions.ts"; +import { MessageComponents } from "../../messages/components/message_components.ts"; /** https://discord.com/developers/docs/interactions/slash-commands#interaction-response-interactionapplicationcommandcallbackdata */ export interface InteractionApplicationCommandCallbackData { @@ -13,4 +14,6 @@ export interface InteractionApplicationCommandCallbackData { allowedMentions?: AllowedMentions; /** Set to `64` to make your response ephemeral */ flags?: number; + /** The components you would like to have sent in this message */ + components?: MessageComponents; } diff --git a/tests/deps.ts b/tests/deps.ts index 8ecc89d22..c5c708cdd 100644 --- a/tests/deps.ts +++ b/tests/deps.ts @@ -3,4 +3,4 @@ export { assertEquals, assertExists, assertThrows, -} from "https://deno.land/std@0.90.0/testing/asserts.ts"; +} from "https://deno.land/std@0.95.0/testing/asserts.ts";