tris lovely typos

This commit is contained in:
Skillz4Killz
2021-10-25 18:35:39 +00:00
committed by GitHub
parent 4d33e1f68b
commit a42ca52c06
102 changed files with 331 additions and 277 deletions
@@ -14,7 +14,7 @@ import type { Bot } from "../../../bot.ts";
* 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(bot: Bot, options: CreateGlobalApplicationCommand, guildId?: bigint) {
[options] = bot.utils.validateSlashCommands([options], true) as CreateGlobalApplicationCommand[];
[options] = bot.utils.validateSlashCommands(bot, [options], true) as CreateGlobalApplicationCommand[];
return await bot.rest.runMethod<ApplicationCommand>(
bot.rest,
@@ -3,7 +3,7 @@ import type { Bot } from "../../../bot.ts";
/** 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<ApplicationCommand>(
const result = await bot.rest.runMethod<ApplicationCommand>(bot.rest,
"get",
guildId
? bot.constants.endpoints.COMMANDS_GUILD_ID(bot.applicationId, guildId, commandId)
@@ -13,6 +13,6 @@ export async function getSlashCommand(bot: Bot, commandId: bigint, guildId?: big
return {
...result,
id: bot.transformers.snowflake(result.id),
applicationId: bot.transformers.snowflake(result.applicationId),
applicationId: bot.transformers.snowflake(result.application_id),
};
}
@@ -18,7 +18,7 @@ export async function getSlashCommands(bot: Bot, guildId?: bigint) {
{
...command,
id: bot.transformers.snowflake(command.id),
applicationId: bot.transformers.snowflake(command.applicationId),
applicationId: bot.transformers.snowflake(command.application_id),
},
])
);
@@ -11,7 +11,7 @@ export async function upsertSlashCommand(
options: EditGlobalApplicationCommand,
guildId?: bigint
) {
[options] = bot.utils.validateSlashCommands([options]);
[options] = bot.utils.validateSlashCommands(bot, [options]);
return await bot.rest.runMethod<ApplicationCommand>(
bot.rest,
@@ -13,7 +13,7 @@ export async function upsertSlashCommands(
options: MakeRequired<EditGlobalApplicationCommand, "name">[],
guildId?: bigint
) {
options = bot.utils.validateSlashCommands(options) as MakeRequired<EditGlobalApplicationCommand, "name">[];
options = bot.utils.validateSlashCommands(bot, options) as MakeRequired<EditGlobalApplicationCommand, "name">[];
return await bot.rest.runMethod<ApplicationCommand[]>(
bot.rest,
@@ -4,7 +4,7 @@ import type { SnakeCasedPropertiesDeep } from "../../types/util.ts";
/** 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<SnakeCasedPropertiesDeep<Message>>(
const result = await bot.rest.runMethod<Message>(
bot.rest,
"get",
bot.constants.endpoints.INTERACTION_ORIGINAL_ID_TOKEN(bot.applicationId, token)
@@ -32,28 +32,20 @@ export async function sendInteractionResponse(
options.data = { ...options.data, allowedMentions: { parse: [] } };
}
const allowedMentions: AllowedMentions = options.data?.allowedMentions || { parse: [] };
// If its already been executed, we need to send a followup response
if (bot.cache.executedSlashCommands.has(token)) {
return await bot.rest.runMethod(bot.rest, "post", bot.cosntants.endpoints.WEBHOOK(bot.applicationId, token), {
return await bot.rest.runMethod(bot.rest, "post", bot.constants.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,
parse: allowedMentions.parse,
roles: allowedMentions.roles,
users: allowedMentions.users,
replied_user: 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,
@@ -62,10 +54,10 @@ export async function sendInteractionResponse(
}
// Expire in 15 minutes
cache.executedSlashCommands.add(token);
bot.cache.executedSlashCommands.add(token);
setTimeout(() => {
eventHandlers.debug?.("loop", `Running setTimeout in send_interaction_response file.`);
cache.executedSlashCommands.delete(token);
bot.events.debug(`Running setTimeout in send_interaction_response file.`);
bot.cache.executedSlashCommands.delete(token);
}, 900000);
return await bot.rest.runMethod(
@@ -77,21 +69,11 @@ export async function sendInteractionResponse(
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,
parse: allowedMentions.parse,
roles: allowedMentions.roles,
users: allowedMentions.users,
replied_user: 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,