@notenoughupdates/discord-akairo
Advanced tools
Comparing version 9.0.10-dev.1644713232.c9ed7b6 to 9.0.10-dev.1644714370.AmusedGrape
{ | ||
"name": "@notenoughupdates/discord-akairo", | ||
"version": "9.0.10-dev.1644713232.c9ed7b6", | ||
"version": "9.0.10-dev.1644714370.AmusedGrape", | ||
"description": "A highly customizable bot framework for Discord.js.", | ||
@@ -5,0 +5,0 @@ "main": "./dist/src/index.js", |
@@ -254,2 +254,4 @@ "use strict"; | ||
}); | ||
console.dir(currentGlobalCommands); | ||
console.dir(slashCommandsApp); | ||
if (!Util_js_1.Util.deepEquals(currentGlobalCommands, slashCommandsApp)) { | ||
@@ -309,2 +311,4 @@ this.client.emit("akairoDebug", "[registerInteractionCommands] Updating global interaction commands.", slashCommandsApp); | ||
}); | ||
console.dir(currentGuildCommands); | ||
console.dir(sortedCommands); | ||
if (!Util_js_1.Util.deepEquals(currentGuildCommands, sortedCommands)) { | ||
@@ -1116,3 +1120,3 @@ this.client.emit("akairoDebug", `[registerInteractionCommands] Updating guild commands for ${guild.name}.`, sortedCommands); | ||
}); | ||
const pairs = (await Promise.all(promises)).flat(1); | ||
const pairs = (await Promise.all(promises)).flatMap(x => x, 1); | ||
pairs.sort(([a], [b]) => Util_js_1.Util.prefixCompare(a, b)); | ||
@@ -1119,0 +1123,0 @@ return this.parseMultiplePrefixes(message, pairs); |
@@ -15,3 +15,3 @@ import type { Message } from "discord.js"; | ||
*/ | ||
message: T extends FlagType.Retry ? Message : unknown; | ||
message: T extends FlagType.Retry ? Message : never; | ||
/** | ||
@@ -22,3 +22,3 @@ * The extra data for the failure. | ||
*/ | ||
value: T extends FlagType.Fail ? any : unknown; | ||
value: T extends FlagType.Fail ? any : never; | ||
/** | ||
@@ -25,0 +25,0 @@ * Command ID. |
@@ -31,3 +31,3 @@ "use strict"; | ||
removeAll() { | ||
for (const m of Array.from(this.values())) { | ||
for (const m of this.values()) { | ||
if (m.filepath) | ||
@@ -34,0 +34,0 @@ m.remove(); |
/// <reference types="node" /> | ||
import type EventEmitter from "events"; | ||
import EventEmitter from "events"; | ||
import type { PrefixSupplier } from "../struct/commands/CommandHandler"; | ||
/** | ||
@@ -14,10 +15,2 @@ * Akairo Utilities. | ||
/** | ||
* Map an iterable object and then flatten it it into an array | ||
* @param iterable - the object to map and flatten | ||
* @param filter - the filter to map with | ||
*/ | ||
static flatMap<Type, Ret extends { | ||
[Symbol.iterator](): Iterator<unknown>; | ||
}, Func extends (...args: any[]) => Ret>(iterable: Iterable<Type>, filter: Func): Type; | ||
/** | ||
* Converts the supplied value into an array if it is not already one. | ||
@@ -30,2 +23,3 @@ * @param x - Value to convert. | ||
* @param thing - What to turn into a callable. | ||
* @returns - The callable. | ||
*/ | ||
@@ -36,7 +30,9 @@ static intoCallable<T>(thing: T | ((...args: any[]) => T)): (...args: any[]) => T; | ||
* @param value - Value to check. | ||
* @returns - Whether the value is an event emitter. | ||
*/ | ||
static isEventEmitter(value: any): value is EventEmitter; | ||
static isEventEmitter(value: unknown): value is EventEmitter; | ||
/** | ||
* Checks if the supplied value is a promise. | ||
* @param value - Value to check. | ||
* @returns - Whether the value is a promise. | ||
*/ | ||
@@ -48,4 +44,5 @@ static isPromise<T>(value: T | Promise<T>): value is Promise<T>; | ||
* @param bKey - Second prefix. | ||
* @returns - Comparison result. | ||
*/ | ||
static prefixCompare(aKey: string | ((...args: any[]) => any), bKey: string | ((...args: any[]) => any)): number; | ||
static prefixCompare(aKey: string | PrefixSupplier, bKey: string | PrefixSupplier): number; | ||
/** | ||
@@ -52,0 +49,0 @@ * Compares each property of two objects to determine if they are equal. |
"use strict"; | ||
var __importDefault = (this && this.__importDefault) || function (mod) { | ||
return (mod && mod.__esModule) ? mod : { "default": mod }; | ||
}; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.isStringArrayStringOrFunc = exports.Util = void 0; | ||
const events_1 = __importDefault(require("events")); | ||
/** | ||
@@ -31,14 +35,2 @@ * Akairo Utilities. | ||
/** | ||
* Map an iterable object and then flatten it it into an array | ||
* @param iterable - the object to map and flatten | ||
* @param filter - the filter to map with | ||
*/ | ||
static flatMap(iterable, filter) { | ||
const result = []; | ||
for (const x of iterable) { | ||
result.push(...filter(x)); | ||
} | ||
return result; | ||
} | ||
/** | ||
* Converts the supplied value into an array if it is not already one. | ||
@@ -56,2 +48,3 @@ * @param x - Value to convert. | ||
* @param thing - What to turn into a callable. | ||
* @returns - The callable. | ||
*/ | ||
@@ -67,8 +60,14 @@ static intoCallable(thing) { | ||
* @param value - Value to check. | ||
* @returns - Whether the value is an event emitter. | ||
*/ | ||
static isEventEmitter(value) { | ||
return value && typeof value.on === "function" && typeof value.emit === "function"; | ||
return value instanceof events_1.default; | ||
} | ||
/** | ||
* Checks if the supplied value is a promise. | ||
* @param value - Value to check. | ||
* @returns - Whether the value is a promise. | ||
*/ | ||
static isPromise(value) { | ||
return value && typeof value.then === "function" && typeof value.catch === "function"; | ||
return value instanceof Promise; | ||
} | ||
@@ -79,2 +78,3 @@ /** | ||
* @param bKey - Second prefix. | ||
* @returns - Comparison result. | ||
*/ | ||
@@ -81,0 +81,0 @@ static prefixCompare(aKey, bKey) { |
{ | ||
"name": "@notenoughupdates/discord-akairo", | ||
"version": "9.0.10-dev.1644713232.c9ed7b6", | ||
"version": "9.0.10-dev.1644714370.AmusedGrape", | ||
"description": "A highly customizable bot framework for Discord.js.", | ||
@@ -5,0 +5,0 @@ "main": "./dist/src/index.js", |
@@ -472,2 +472,5 @@ import { | ||
console.dir(currentGlobalCommands); | ||
console.dir(slashCommandsApp); | ||
if (!Util.deepEquals(currentGlobalCommands, slashCommandsApp)) { | ||
@@ -524,2 +527,5 @@ this.client.emit("akairoDebug", "[registerInteractionCommands] Updating global interaction commands.", slashCommandsApp); | ||
console.dir(currentGuildCommands); | ||
console.dir(sortedCommands); | ||
if (!Util.deepEquals(currentGuildCommands, sortedCommands)) { | ||
@@ -1427,3 +1433,3 @@ this.client.emit( | ||
const pairs = (await Promise.all(promises)).flat(1); | ||
const pairs = (await Promise.all(promises)).flatMap(x => x, 1); | ||
pairs.sort(([a]: any, [b]: any) => Util.prefixCompare(a, b)); | ||
@@ -1430,0 +1436,0 @@ return this.parseMultiplePrefixes(message, pairs as [string, Set<string>][]); |
@@ -17,3 +17,3 @@ import type { Message } from "discord.js"; | ||
*/ | ||
public declare message: T extends FlagType.Retry ? Message : unknown; | ||
public declare message: T extends FlagType.Retry ? Message : never; | ||
@@ -25,3 +25,3 @@ /** | ||
*/ | ||
public declare value: T extends FlagType.Fail ? any : unknown; | ||
public declare value: T extends FlagType.Fail ? any : never; | ||
@@ -28,0 +28,0 @@ /** |
@@ -37,3 +37,3 @@ import { Collection } from "discord.js"; | ||
public removeAll(): this { | ||
for (const m of Array.from(this.values())) { | ||
for (const m of this.values()) { | ||
if (m.filepath) m.remove(); | ||
@@ -40,0 +40,0 @@ } |
@@ -1,3 +0,3 @@ | ||
/* eslint-disable @typescript-eslint/ban-types */ | ||
import type EventEmitter from "events"; | ||
import EventEmitter from "events"; | ||
import type { PrefixSupplier } from "../struct/commands/CommandHandler"; | ||
@@ -13,3 +13,3 @@ /** | ||
*/ | ||
public static deepAssign<A, B>(target: A, ...os: B[]) { | ||
public static deepAssign<A, B>(target: A, ...os: B[]): A { | ||
for (const o of os) { | ||
@@ -34,19 +34,2 @@ for (const [key, value] of Object.entries(o)) { | ||
/** | ||
* Map an iterable object and then flatten it it into an array | ||
* @param iterable - the object to map and flatten | ||
* @param filter - the filter to map with | ||
*/ | ||
public static flatMap<Type, Ret extends { [Symbol.iterator](): Iterator<unknown> }, Func extends (...args: any[]) => Ret>( | ||
iterable: Iterable<Type>, | ||
filter: Func | ||
): Type { | ||
const result = []; | ||
for (const x of iterable) { | ||
result.push(...filter(x)); | ||
} | ||
return result as unknown as Type; | ||
} | ||
/** | ||
* Converts the supplied value into an array if it is not already one. | ||
@@ -66,2 +49,3 @@ * @param x - Value to convert. | ||
* @param thing - What to turn into a callable. | ||
* @returns - The callable. | ||
*/ | ||
@@ -79,5 +63,6 @@ public static intoCallable<T>(thing: T | ((...args: any[]) => T)): (...args: any[]) => T { | ||
* @param value - Value to check. | ||
* @returns - Whether the value is an event emitter. | ||
*/ | ||
public static isEventEmitter(value: any): value is EventEmitter { | ||
return value && typeof value.on === "function" && typeof value.emit === "function"; | ||
public static isEventEmitter(value: unknown): value is EventEmitter { | ||
return value instanceof EventEmitter; | ||
} | ||
@@ -88,6 +73,6 @@ | ||
* @param value - Value to check. | ||
* @returns - Whether the value is a promise. | ||
*/ | ||
public static isPromise<T>(value: T | Promise<T>): value is Promise<T>; | ||
public static isPromise(value: any): value is Promise<any> { | ||
return value && typeof value.then === "function" && typeof value.catch === "function"; | ||
public static isPromise<T>(value: T | Promise<T>): value is Promise<T> { | ||
return value instanceof Promise; | ||
} | ||
@@ -99,4 +84,5 @@ | ||
* @param bKey - Second prefix. | ||
* @returns - Comparison result. | ||
*/ | ||
public static prefixCompare(aKey: string | ((...args: any[]) => any), bKey: string | ((...args: any[]) => any)): number { | ||
public static prefixCompare(aKey: string | PrefixSupplier, bKey: string | PrefixSupplier): number { | ||
if (aKey === "" && bKey === "") return 0; | ||
@@ -103,0 +89,0 @@ if (aKey === "") return 1; |
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
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
956354
16802