@notenoughupdates/discord-akairo
Advanced tools
Comparing version 9.0.10-dev.1640720924.492e948 to 9.0.10-dev.1640800669.b25799e
{ | ||
"name": "@notenoughupdates/discord-akairo", | ||
"version": "9.0.10-dev.1640720924.492e948", | ||
"version": "9.0.10-dev.1640800669.b25799e", | ||
"description": "A highly customizable bot framework for Discord.js.", | ||
@@ -31,2 +31,3 @@ "main": "./dist/src/index.js", | ||
"test": "yarn build && cd ./test && yarn && yarn test && cd ../", | ||
"test:run": "yarn build && cd ./test && yarn && yarn start && cd ../", | ||
"test:all": "yarn lint && yarn test", | ||
@@ -33,0 +34,0 @@ "format": "yarn prettier . --write", |
@@ -185,4 +185,4 @@ "use strict"; | ||
name, | ||
description: description, | ||
options: options, | ||
description: description ?? "", | ||
options: options ?? [], | ||
defaultPermission, | ||
@@ -208,3 +208,3 @@ type | ||
else { | ||
this.client.emit("akairoDebug", "[registerInteractionCommands]Global interaction commands are up to date."); | ||
this.client.emit("akairoDebug", "[registerInteractionCommands] Global interaction commands are up to date."); | ||
} | ||
@@ -295,3 +295,3 @@ /* Guilds */ | ||
catch (e) { | ||
this.client.emit("akairoDebug", "Error updating interaction permissions, here are the promises, globalCommands, and fullPermissions", promises, globalCommands, fullPermissions); | ||
this.client.emit("akairoDebug", "[updateInteractionPermissions] Error updating interaction permissions, here are the promises, globalCommands, and fullPermissions", promises, globalCommands, fullPermissions); | ||
throw e; | ||
@@ -508,3 +508,3 @@ } | ||
if (!usedSubcommandOrGroup) { | ||
this.client.emit("akairoDebug", `Unable to find subcommand`); | ||
this.client.emit("akairoDebug", "[handleSlash] Unable to find subcommand"); | ||
return; | ||
@@ -514,3 +514,3 @@ } | ||
if (!usedSubcommandOrGroup.options) { | ||
this.client.emit("akairoDebug", `Unable to find subcommand options`); | ||
this.client.emit("akairoDebug", "[handleSlash] Unable to find subcommand options"); | ||
return; | ||
@@ -523,7 +523,7 @@ } | ||
if (!usedSubCommand) { | ||
this.client.emit("akairoDebug", `Unable to find subcommand`); | ||
this.client.emit("akairoDebug", "[handleSlash] Unable to find subcommand"); | ||
return; | ||
} | ||
else if (!usedSubCommand.options) { | ||
this.client.emit("akairoDebug", `Unable to find subcommand options`); | ||
this.client.emit("akairoDebug", "[handleSlash] Unable to find subcommand options"); | ||
return; | ||
@@ -534,3 +534,3 @@ } | ||
else { | ||
throw new Error(`Unexpected command type ${usedSubcommandOrGroup.type}`); | ||
throw new AkairoError_js_1.default("UNEXPECTED_SLASH_COMMAND_TYPE", usedSubcommandOrGroup.type); | ||
} | ||
@@ -543,18 +543,16 @@ } | ||
for (const option of options) { | ||
if (!Reflect.has(convertedOptions, option.name) || convertedOptions[option.name] === undefined) { | ||
switch (option.type) { | ||
case "BOOLEAN" || 5 /* BOOLEAN */: | ||
convertedOptions[option.name] = false; | ||
break; | ||
case "CHANNEL" || 7 /* CHANNEL */: | ||
case "INTEGER" || 4 /* INTEGER */: | ||
case "MENTIONABLE" || 9 /* MENTIONABLE */: | ||
case "NUMBER" || 10 /* NUMBER */: | ||
case "ROLE" || 8 /* ROLE */: | ||
case "STRING" || 3 /* STRING */: | ||
case "USER" || 6 /* USER */: | ||
default: | ||
convertedOptions[option.name] = null; | ||
break; | ||
} | ||
switch (option.type) { | ||
case "BOOLEAN" || 5 /* BOOLEAN */: | ||
convertedOptions[option.name] ??= false; | ||
break; | ||
case "CHANNEL" || 7 /* CHANNEL */: | ||
case "INTEGER" || 4 /* INTEGER */: | ||
case "MENTIONABLE" || 9 /* MENTIONABLE */: | ||
case "NUMBER" || 10 /* NUMBER */: | ||
case "ROLE" || 8 /* ROLE */: | ||
case "STRING" || 3 /* STRING */: | ||
case "USER" || 6 /* USER */: | ||
default: | ||
convertedOptions[option.name] ??= null; | ||
break; | ||
} | ||
@@ -617,3 +615,3 @@ } | ||
} | ||
this.client.emit("akairoDebug", `Autocomplete started for ${interaction.commandName}`); | ||
this.client.emit("akairoDebug", `[handleAutocomplete] Autocomplete started for ${interaction.commandName}`); | ||
commandModule.autocomplete(interaction); | ||
@@ -620,0 +618,0 @@ } |
@@ -0,1 +1,2 @@ | ||
import { SlashOption } from "../struct/commands/Command"; | ||
declare const Messages: { | ||
@@ -8,2 +9,3 @@ FILE_NOT_FOUND: (filename: string) => string; | ||
ALIAS_CONFLICT: (alias: string, id: string, conflict: string) => string; | ||
UNEXPECTED_SLASH_COMMAND_TYPE: (type: SlashOption["type"]) => string; | ||
COMMAND_UTIL_EXPLICIT: string; | ||
@@ -22,2 +24,3 @@ UNKNOWN_MATCH_TYPE: (match: string) => string; | ||
ALIAS_CONFLICT: [alias: string, id: string, conflict: string]; | ||
UNEXPECTED_SLASH_COMMAND_TYPE: [type: SlashOption["type"]]; | ||
COMMAND_UTIL_EXPLICIT: []; | ||
@@ -24,0 +27,0 @@ UNKNOWN_MATCH_TYPE: [match: string]; |
@@ -12,2 +12,3 @@ "use strict"; | ||
ALIAS_CONFLICT: (alias, id, conflict) => `Alias '${alias}' of '${id}' already exists on '${conflict}'`, | ||
UNEXPECTED_SLASH_COMMAND_TYPE: (type) => `Unexpected slash command type '${type}', where there is a subcommand and or subcommandGroup.`, | ||
// Options-related | ||
@@ -14,0 +15,0 @@ COMMAND_UTIL_EXPLICIT: "The command handler options `handleEdits` and `storeMessages` require the `commandUtil` option to be true", |
@@ -40,3 +40,3 @@ /// <reference types="node" /> | ||
*/ | ||
static isPromise(value: any): value is Promise<any>; | ||
static isPromise<T>(value: T | Promise<T>): value is Promise<T>; | ||
/** | ||
@@ -52,5 +52,6 @@ * Compares two prefixes. | ||
* @param b - Second value. | ||
* @param ignoreUndefined - Whether to ignore undefined properties. | ||
* @returns Whether the two values are equal. | ||
*/ | ||
static deepEquals<T>(a: unknown, b: T): a is T; | ||
static deepEquals<T>(a: unknown, b: T, ignoreUndefined?: boolean): a is T; | ||
/** | ||
@@ -57,0 +58,0 @@ * Converts a string in snake_case to camelCase. |
@@ -68,6 +68,2 @@ "use strict"; | ||
} | ||
/** | ||
* Checks if the supplied value is a promise. | ||
* @param value - Value to check. | ||
*/ | ||
static isPromise(value) { | ||
@@ -96,18 +92,28 @@ return value && typeof value.then === "function" && typeof value.catch === "function"; | ||
} | ||
static deepEquals(a, b) { | ||
if (a === b) | ||
return true; | ||
if (typeof a !== "object" || typeof b !== "object") | ||
throw new TypeError("Not objects"); | ||
for (const key in a) { | ||
if (!(key in b)) | ||
return false; | ||
if (typeof a[key] === "object" && typeof b[key] === "object") { | ||
if (!Util.deepEquals(a[key], b[key])) | ||
static deepEquals(_a, _b, _ignoreUndefined = true) { | ||
function deepEquals(a, b, ignoreUndefined) { | ||
if (a === b) | ||
return true; | ||
if (typeof a !== "object" || typeof b !== "object") | ||
throw new TypeError("Not objects"); | ||
for (const key in a) { | ||
if (ignoreUndefined && a[key] === undefined && b[key] === undefined) | ||
continue; | ||
if (!(key in b)) | ||
return false; | ||
if (typeof a[key] === "object" && typeof b[key] === "object") { | ||
if (!( /* this. */deepEquals(a[key], b[key], ignoreUndefined))) | ||
return false; | ||
} | ||
else if (a[key] !== b[key]) | ||
return false; | ||
} | ||
else if (a[key] !== b[key]) | ||
return false; | ||
return true; | ||
} | ||
return true; | ||
const result = deepEquals(_a, _b, _ignoreUndefined); | ||
if (result === false) { | ||
console.dir(_a, { depth: 3 }); | ||
console.dir(_b, { depth: 3 }); | ||
} | ||
return result; | ||
} | ||
@@ -114,0 +120,0 @@ /** |
{ | ||
"name": "@notenoughupdates/discord-akairo", | ||
"version": "9.0.10-dev.1640720924.492e948", | ||
"version": "9.0.10-dev.1640800669.b25799e", | ||
"description": "A highly customizable bot framework for Discord.js.", | ||
@@ -31,2 +31,3 @@ "main": "./dist/src/index.js", | ||
"test": "yarn build && cd ./test && yarn && yarn test && cd ../", | ||
"test:run": "yarn build && cd ./test && yarn && yarn start && cd ../", | ||
"test:all": "yarn lint && yarn test", | ||
@@ -33,0 +34,0 @@ "format": "yarn prettier . --write", |
@@ -429,4 +429,4 @@ import { | ||
name, | ||
description: description!, | ||
options: options!, | ||
description: description ?? "", | ||
options: options ?? [], | ||
defaultPermission, | ||
@@ -450,3 +450,3 @@ type | ||
} else { | ||
this.client.emit("akairoDebug", "[registerInteractionCommands]Global interaction commands are up to date."); | ||
this.client.emit("akairoDebug", "[registerInteractionCommands] Global interaction commands are up to date."); | ||
} | ||
@@ -545,3 +545,3 @@ | ||
"akairoDebug", | ||
"Error updating interaction permissions, here are the promises, globalCommands, and fullPermissions", | ||
"[updateInteractionPermissions] Error updating interaction permissions, here are the promises, globalCommands, and fullPermissions", | ||
promises, | ||
@@ -792,3 +792,3 @@ globalCommands, | ||
if (!usedSubcommandOrGroup) { | ||
this.client.emit("akairoDebug", `Unable to find subcommand`); | ||
this.client.emit("akairoDebug", "[handleSlash] Unable to find subcommand"); | ||
return; | ||
@@ -798,3 +798,3 @@ } | ||
if (!(usedSubcommandOrGroup as SubCommand).options) { | ||
this.client.emit("akairoDebug", `Unable to find subcommand options`); | ||
this.client.emit("akairoDebug", "[handleSlash] Unable to find subcommand options"); | ||
return; | ||
@@ -810,6 +810,6 @@ } | ||
if (!usedSubCommand) { | ||
this.client.emit("akairoDebug", `Unable to find subcommand`); | ||
this.client.emit("akairoDebug", "[handleSlash] Unable to find subcommand"); | ||
return; | ||
} else if (!usedSubCommand.options) { | ||
this.client.emit("akairoDebug", `Unable to find subcommand options`); | ||
this.client.emit("akairoDebug", "[handleSlash] Unable to find subcommand options"); | ||
return; | ||
@@ -820,3 +820,3 @@ } | ||
} else { | ||
throw new Error(`Unexpected command type ${usedSubcommandOrGroup.type}`); | ||
throw new AkairoError("UNEXPECTED_SLASH_COMMAND_TYPE", usedSubcommandOrGroup.type); | ||
} | ||
@@ -829,18 +829,16 @@ } else { | ||
for (const option of options) { | ||
if (!Reflect.has(convertedOptions, option.name) || convertedOptions[option.name] === undefined) { | ||
switch (option.type) { | ||
case "BOOLEAN" || ApplicationCommandOptionTypes.BOOLEAN: | ||
convertedOptions[option.name] = false; | ||
break; | ||
case "CHANNEL" || ApplicationCommandOptionTypes.CHANNEL: | ||
case "INTEGER" || ApplicationCommandOptionTypes.INTEGER: | ||
case "MENTIONABLE" || ApplicationCommandOptionTypes.MENTIONABLE: | ||
case "NUMBER" || ApplicationCommandOptionTypes.NUMBER: | ||
case "ROLE" || ApplicationCommandOptionTypes.ROLE: | ||
case "STRING" || ApplicationCommandOptionTypes.STRING: | ||
case "USER" || ApplicationCommandOptionTypes.USER: | ||
default: | ||
convertedOptions[option.name] = null; | ||
break; | ||
} | ||
switch (option.type) { | ||
case "BOOLEAN" || ApplicationCommandOptionTypes.BOOLEAN: | ||
convertedOptions[option.name] ??= false; | ||
break; | ||
case "CHANNEL" || ApplicationCommandOptionTypes.CHANNEL: | ||
case "INTEGER" || ApplicationCommandOptionTypes.INTEGER: | ||
case "MENTIONABLE" || ApplicationCommandOptionTypes.MENTIONABLE: | ||
case "NUMBER" || ApplicationCommandOptionTypes.NUMBER: | ||
case "ROLE" || ApplicationCommandOptionTypes.ROLE: | ||
case "STRING" || ApplicationCommandOptionTypes.STRING: | ||
case "USER" || ApplicationCommandOptionTypes.USER: | ||
default: | ||
convertedOptions[option.name] ??= null; | ||
break; | ||
} | ||
@@ -903,3 +901,3 @@ } | ||
this.client.emit("akairoDebug", `Autocomplete started for ${interaction.commandName}`); | ||
this.client.emit("akairoDebug", `[handleAutocomplete] Autocomplete started for ${interaction.commandName}`); | ||
commandModule.autocomplete(interaction); | ||
@@ -906,0 +904,0 @@ } |
@@ -0,1 +1,3 @@ | ||
import { SlashOption } from "../struct/commands/Command"; | ||
const Messages = { | ||
@@ -11,2 +13,4 @@ // Module-related | ||
ALIAS_CONFLICT: (alias: string, id: string, conflict: string) => `Alias '${alias}' of '${id}' already exists on '${conflict}'`, | ||
UNEXPECTED_SLASH_COMMAND_TYPE: (type: SlashOption["type"]) => | ||
`Unexpected slash command type '${type}', where there is a subcommand and or subcommandGroup.`, | ||
@@ -31,2 +35,3 @@ // Options-related | ||
ALIAS_CONFLICT: [alias: string, id: string, conflict: string]; | ||
UNEXPECTED_SLASH_COMMAND_TYPE: [type: SlashOption["type"]]; | ||
COMMAND_UTIL_EXPLICIT: []; | ||
@@ -33,0 +38,0 @@ UNKNOWN_MATCH_TYPE: [match: string]; |
@@ -85,2 +85,3 @@ /* eslint-disable @typescript-eslint/ban-types */ | ||
*/ | ||
public static isPromise<T>(value: T | Promise<T>): value is Promise<T>; | ||
public static isPromise(value: any): value is Promise<any> { | ||
@@ -109,15 +110,26 @@ return value && typeof value.then === "function" && typeof value.catch === "function"; | ||
* @param b - Second value. | ||
* @param ignoreUndefined - Whether to ignore undefined properties. | ||
* @returns Whether the two values are equal. | ||
*/ | ||
public static deepEquals<T>(a: unknown, b: T): a is T; | ||
public static deepEquals(a: any, b: any): boolean { | ||
if (a === b) return true; | ||
if (typeof a !== "object" || typeof b !== "object") throw new TypeError("Not objects"); | ||
for (const key in a) { | ||
if (!(key in b)) return false; | ||
if (typeof a[key] === "object" && typeof b[key] === "object") { | ||
if (!Util.deepEquals(a[key], b[key])) return false; | ||
} else if (a[key] !== b[key]) return false; | ||
public static deepEquals<T>(a: unknown, b: T, ignoreUndefined?: boolean): a is T; | ||
public static deepEquals(_a: any, _b: any, _ignoreUndefined = true): boolean { | ||
function deepEquals(a: any, b: any, ignoreUndefined?: boolean) { | ||
if (a === b) return true; | ||
if (typeof a !== "object" || typeof b !== "object") throw new TypeError("Not objects"); | ||
for (const key in a) { | ||
if (ignoreUndefined && a[key] === undefined && b[key] === undefined) continue; | ||
if (!(key in b)) return false; | ||
if (typeof a[key] === "object" && typeof b[key] === "object") { | ||
if (!(/* this. */ deepEquals(a[key], b[key], ignoreUndefined))) return false; | ||
} else if (a[key] !== b[key]) return false; | ||
} | ||
return true; | ||
} | ||
return true; | ||
const result = deepEquals(_a, _b, _ignoreUndefined); | ||
if (result === false) { | ||
console.dir(_a, { depth: 3 }); | ||
console.dir(_b, { depth: 3 }); | ||
} | ||
return result; | ||
} | ||
@@ -124,0 +136,0 @@ |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
909317
16306