@notenoughupdates/discord-akairo
Advanced tools
Comparing version 10.0.0-dev.1661396495.d2761d1 to 10.0.0-dev.1663615008.878749e
{ | ||
"name": "@notenoughupdates/discord-akairo", | ||
"version": "10.0.0-dev.1661396495.d2761d1", | ||
"version": "10.0.0-dev.1663615008.878749e", | ||
"description": "A highly customizable bot framework for Discord.js.", | ||
@@ -50,8 +50,8 @@ "main": "./dist/src/index.js", | ||
"@favware/npm-deprecate": "^1.0.5", | ||
"@types/node": "^18.6.5", | ||
"@typescript-eslint/eslint-plugin": "^5.33.0", | ||
"@typescript-eslint/parser": "^5.33.0", | ||
"@types/node": "^18.7.18", | ||
"@typescript-eslint/eslint-plugin": "^5.37.0", | ||
"@typescript-eslint/parser": "^5.37.0", | ||
"cp-cli": "^2.0.0", | ||
"discord.js": "^14.1.2", | ||
"eslint": "^8.21.0", | ||
"discord.js": "^14.3.0", | ||
"eslint": "^8.23.1", | ||
"eslint-config-prettier": "^8.5.0", | ||
@@ -63,11 +63,14 @@ "eslint-plugin-deprecation": "^1.3.2", | ||
"rimraf": "^3.0.2", | ||
"ts-essentials": "^9.2.0", | ||
"typedoc": "^0.23.10", | ||
"typescript": "^4.7.4", | ||
"vitest": "^0.21.0" | ||
"ts-essentials": "^9.3.0", | ||
"typedoc": "^0.23.14", | ||
"typescript": "^4.8.3", | ||
"vitest": "^0.23.2" | ||
}, | ||
"packageManager": "yarn@3.2.2", | ||
"dependencies": { | ||
"zod": "^3.17.10" | ||
"zod": "^3.19.1" | ||
}, | ||
"resolutions": { | ||
"@sapphire/shapeshift": "^3.6.0" | ||
} | ||
} |
import type { CommandUtil } from "./struct/commands/CommandUtil.js"; | ||
declare module "discord.js" { | ||
interface Message<Cached extends boolean = boolean> extends Base { | ||
util?: CommandUtil<Message>; | ||
interface Message<InGuild extends boolean = boolean> extends Base { | ||
util?: CommandUtil<Message<InGuild>>; | ||
} | ||
@@ -6,0 +6,0 @@ } |
@@ -418,3 +418,5 @@ "use strict"; | ||
const originalOption = commandModule.slashOptions?.find(o => o.name === option.name); | ||
const func = `get${originalOption?.resolve ?? discord_js_1.ApplicationCommandOptionType[option.type]}`; | ||
const func = `get${originalOption && "resolve" in originalOption && originalOption.resolve | ||
? originalOption.resolve | ||
: discord_js_1.ApplicationCommandOptionType[option.type]}`; | ||
convertedOptions[option.name] = interaction.options[func](option.name, false); | ||
@@ -471,5 +473,7 @@ } | ||
break; | ||
default: | ||
default: { | ||
const exhaustiveCheck = option; | ||
convertedOptions[option.name] ??= null; | ||
break; | ||
} | ||
} | ||
@@ -476,0 +480,0 @@ } |
@@ -56,3 +56,3 @@ "use strict"; | ||
async send(options) { | ||
const hasFiles = typeof options === "string" || !options.files?.length ? false : options.files?.length > 0; | ||
const hasFiles = typeof options === "string" || !options.files?.length ? false : options.files.length > 0; | ||
const newOptions = typeof options === "string" ? { content: options } : options; | ||
@@ -59,0 +59,0 @@ if (!this.isSlashMessage(this.message)) { |
import EventEmitter from "node:events"; | ||
import type { PrefixSupplier } from "../struct/commands/CommandHandler.js"; | ||
import { SyncOrAsync } from "../typings/Util.js"; | ||
export declare function deepAssign<A, B>(target: A, ...os: B[]): A & B; | ||
export declare function deepAssign<A extends Record<string, any>, B extends Record<string, any>>(target: A, ...os: B[]): A & B; | ||
export declare function intoArray<T>(x: T | T[]): T[]; | ||
@@ -6,0 +6,0 @@ export declare function intoCallable<T>(thing: T | ((...args: any[]) => T)): (...args: any[]) => T; |
{ | ||
"name": "@notenoughupdates/discord-akairo", | ||
"version": "10.0.0-dev.1661396495.d2761d1", | ||
"version": "10.0.0-dev.1663615008.878749e", | ||
"description": "A highly customizable bot framework for Discord.js.", | ||
@@ -50,8 +50,8 @@ "main": "./dist/src/index.js", | ||
"@favware/npm-deprecate": "^1.0.5", | ||
"@types/node": "^18.6.5", | ||
"@typescript-eslint/eslint-plugin": "^5.33.0", | ||
"@typescript-eslint/parser": "^5.33.0", | ||
"@types/node": "^18.7.18", | ||
"@typescript-eslint/eslint-plugin": "^5.37.0", | ||
"@typescript-eslint/parser": "^5.37.0", | ||
"cp-cli": "^2.0.0", | ||
"discord.js": "^14.1.2", | ||
"eslint": "^8.21.0", | ||
"discord.js": "^14.3.0", | ||
"eslint": "^8.23.1", | ||
"eslint-config-prettier": "^8.5.0", | ||
@@ -63,11 +63,14 @@ "eslint-plugin-deprecation": "^1.3.2", | ||
"rimraf": "^3.0.2", | ||
"ts-essentials": "^9.2.0", | ||
"typedoc": "^0.23.10", | ||
"typescript": "^4.7.4", | ||
"vitest": "^0.21.0" | ||
"ts-essentials": "^9.3.0", | ||
"typedoc": "^0.23.14", | ||
"typescript": "^4.8.3", | ||
"vitest": "^0.23.2" | ||
}, | ||
"packageManager": "yarn@3.2.2", | ||
"dependencies": { | ||
"zod": "^3.17.10" | ||
"zod": "^3.19.1" | ||
}, | ||
"resolutions": { | ||
"@sapphire/shapeshift": "^3.6.0" | ||
} | ||
} |
@@ -5,3 +5,3 @@ /* eslint-disable @typescript-eslint/no-unused-vars */ | ||
declare module "discord.js" { | ||
export interface Message<Cached extends boolean = boolean> extends Base { | ||
export interface Message<InGuild extends boolean = boolean> extends Base { | ||
/** | ||
@@ -13,3 +13,3 @@ * Extra properties applied to the Discord.js message object. | ||
* */ | ||
util?: CommandUtil<Message>; | ||
util?: CommandUtil<Message<InGuild>>; | ||
} | ||
@@ -16,0 +16,0 @@ } |
/* eslint-disable @typescript-eslint/no-unused-vars */ | ||
import type { | ||
ApplicationCommandAutocompleteOption, | ||
ApplicationCommandChannelOptionData, | ||
ApplicationCommandChoicesData, | ||
ApplicationCommandNonOptionsData, | ||
ApplicationCommandNumericOptionData, | ||
ApplicationCommandOptionData, | ||
ApplicationCommandOptionType, | ||
@@ -665,15 +661,3 @@ ApplicationCommandSubCommandData, | ||
export interface AkairoApplicationCommandSubGroupData extends ApplicationCommandSubGroupData { | ||
options?: AkairoApplicationCommandSubCommandData[]; | ||
} | ||
export interface AkairoApplicationCommandSubCommandData extends ApplicationCommandSubCommandData { | ||
options?: ( | ||
| AkairoApplicationCommandChoicesData | ||
| AkairoApplicationCommandNonOptionsData | ||
| AkairoApplicationCommandChannelOptionData | ||
)[]; | ||
} | ||
export interface AkairoApplicationCommandChoicesData extends ApplicationCommandChoicesData { | ||
export interface SlashExt { | ||
/** | ||
@@ -687,55 +671,19 @@ * Allows you to get a discord resolved object | ||
export interface AkairoApplicationCommandAutocompleteOption extends ApplicationCommandAutocompleteOption { | ||
/** | ||
* Allows you to get a discord resolved object | ||
* | ||
* ex. get the resolved member object when the type is {@link ApplicationCommandOptionType.User} | ||
*/ | ||
resolve?: SlashResolveType; | ||
} | ||
type Sub = Pick<ApplicationCommandSubGroupData, "options"> | Pick<ApplicationCommandSubCommandData, "options">; | ||
export interface AkairoApplicationCommandNumericOptionData extends ApplicationCommandNumericOptionData { | ||
/** | ||
* Allows you to get a discord resolved object | ||
* | ||
* ex. get the resolved member object when the type is {@link ApplicationCommandOptionType.User} | ||
*/ | ||
resolve?: SlashResolveType; | ||
} | ||
type GetNonSub<T> = T extends Sub ? never : T & SlashExt; | ||
export interface AkairoApplicationCommandNonOptionsData extends ApplicationCommandNonOptionsData { | ||
/** | ||
* Allows you to get a discord resolved object | ||
* | ||
* ex. get the resolved member object when the type is {@link ApplicationCommandOptionType.User} | ||
*/ | ||
resolve?: SlashResolveType; | ||
export type SlashNonSub = GetNonSub<ApplicationCommandOptionData>; | ||
export interface ExtGroup extends ApplicationCommandSubGroupData { | ||
options?: ExtSub[]; | ||
} | ||
export interface AkairoApplicationCommandChannelOptionData extends ApplicationCommandChannelOptionData { | ||
/** | ||
* Allows you to get a discord resolved object | ||
* | ||
* ex. get the resolved member object when the type is {@link ApplicationCommandOptionType.User} | ||
*/ | ||
resolve?: SlashResolveType; | ||
export interface ExtSub extends ApplicationCommandSubCommandData { | ||
options?: SlashNonSub[]; | ||
} | ||
export type AkairoApplicationCommandOptionData = | ||
| AkairoApplicationCommandSubGroupData | ||
| AkairoApplicationCommandNonOptionsData | ||
| AkairoApplicationCommandChannelOptionData | ||
| AkairoApplicationCommandChoicesData | ||
| AkairoApplicationCommandAutocompleteOption | ||
| AkairoApplicationCommandNumericOptionData | ||
| AkairoApplicationCommandSubCommandData; | ||
export type SlashSub = ExtGroup | ExtSub; | ||
export type SlashOption = AkairoApplicationCommandOptionData & { | ||
/** | ||
* Allows you to get a discord resolved object | ||
* | ||
* ex. get the resolved member object when the type is {@link ApplicationCommandOptionType.User} | ||
*/ | ||
resolve?: SlashResolveType; | ||
}; | ||
export type SlashOption = SlashNonSub | SlashSub; | ||
@@ -742,0 +690,0 @@ /** |
import { | ||
ApplicationCommand, | ||
ApplicationCommandOptionType, | ||
ApplicationCommandSubCommandData, | ||
ApplicationCommandSubGroupData, | ||
ApplicationCommandType, | ||
@@ -36,12 +38,3 @@ Collection, | ||
import { TypeResolver } from "./arguments/TypeResolver.js"; | ||
import { | ||
Command, | ||
CommandInstance, | ||
type AkairoApplicationCommandChannelOptionData, | ||
type AkairoApplicationCommandChoicesData, | ||
type AkairoApplicationCommandNonOptionsData, | ||
type AkairoApplicationCommandSubCommandData, | ||
type AkairoApplicationCommandSubGroupData, | ||
type KeySupplier | ||
} from "./Command.js"; | ||
import { Command, CommandInstance, SlashNonSub, type KeySupplier } from "./Command.js"; | ||
import { CommandUtil } from "./CommandUtil.js"; | ||
@@ -690,3 +683,9 @@ import { Flag, FlagType } from "./Flag.js"; | ||
const func = `get${originalOption?.resolve ?? (ApplicationCommandOptionType[option.type] as SlashResolveType)}` as const; | ||
const func = `get${ | ||
// fuck u typescript | ||
originalOption && "resolve" in originalOption && originalOption.resolve | ||
? originalOption.resolve | ||
: (ApplicationCommandOptionType[option.type] as SlashResolveType) | ||
}` as const; | ||
convertedOptions[option.name] = interaction.options[func](option.name, false); | ||
@@ -697,8 +696,4 @@ } | ||
out: { | ||
type SubCommand = AkairoApplicationCommandSubCommandData; | ||
type SubCommandGroup = AkairoApplicationCommandSubGroupData; | ||
type NonSubSlashOptions = | ||
| AkairoApplicationCommandChoicesData | ||
| AkairoApplicationCommandNonOptionsData | ||
| AkairoApplicationCommandChannelOptionData; | ||
type SubCommand = ApplicationCommandSubCommandData; | ||
type SubCommandGroup = ApplicationCommandSubGroupData; | ||
@@ -734,7 +729,7 @@ if (convertedOptions.subcommand || convertedOptions.subcommandGroup) { | ||
} else { | ||
handleOptions((commandModule.slashOptions ?? []) as NonSubSlashOptions[]); | ||
handleOptions((commandModule.slashOptions ?? []) as SlashNonSub[]); | ||
} | ||
// eslint-disable-next-line no-inner-declarations | ||
function handleOptions(options: NonSubSlashOptions[]) { | ||
function handleOptions(options: SlashNonSub[]) { | ||
for (const option of options) { | ||
@@ -755,6 +750,10 @@ switch (option.type) { | ||
break; | ||
default: | ||
// @ts-expect-error: | ||
default: { | ||
// eslint-disable-next-line @typescript-eslint/no-unused-vars | ||
const exhaustiveCheck: never = option; | ||
// @ts-expect-error | ||
convertedOptions[option.name] ??= null; | ||
break; | ||
} | ||
} | ||
@@ -761,0 +760,0 @@ } |
@@ -150,3 +150,3 @@ import { | ||
public async send(options: string | MessagePayload | MessageOptions | InteractionReplyOptions): Promise<Message> { | ||
const hasFiles = typeof options === "string" || !options.files?.length ? false : options.files?.length > 0; | ||
const hasFiles = typeof options === "string" || !options.files?.length ? false : options.files.length > 0; | ||
const newOptions = typeof options === "string" ? { content: options } : options; | ||
@@ -153,0 +153,0 @@ if (!this.isSlashMessage(this.message)) { |
@@ -12,3 +12,3 @@ import EventEmitter from "node:events"; | ||
*/ | ||
export function deepAssign<A, B>(target: A, ...os: B[]): A & B { | ||
export function deepAssign<A extends Record<string, any>, B extends Record<string, any>>(target: A, ...os: B[]): A & B { | ||
for (const o of os) { | ||
@@ -15,0 +15,0 @@ for (const [key, value] of Object.entries(o)) { |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is too big to display
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
1080618
17162
Updatedzod@^3.19.1