Merge branch 'main' into hashes-bigints

This commit is contained in:
Skillz4Killz
2021-05-07 09:02:36 -04:00
committed by GitHub
6 changed files with 31 additions and 19 deletions

View File

@@ -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";

5
mod.ts
View File

@@ -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";

View File

@@ -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) {

View File

@@ -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,

View File

@@ -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;
}

View File

@@ -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";