@notenoughupdates/discord-akairo
Advanced tools
Comparing version 9.0.10-dev.1640804630.61aa536 to 9.0.10-dev.1642556098.bebde2e
{ | ||
"name": "@notenoughupdates/discord-akairo", | ||
"version": "9.0.10-dev.1640804630.61aa536", | ||
"version": "9.0.10-dev.1642556098.bebde2e", | ||
"description": "A highly customizable bot framework for Discord.js.", | ||
@@ -45,9 +45,10 @@ "main": "./dist/src/index.js", | ||
"@favware/npm-deprecate": "^1.0.4", | ||
"@types/node": "^16.11.13", | ||
"@types/node": "^17.0.10", | ||
"@types/source-map-support": "^0.5.4", | ||
"@typescript-eslint/eslint-plugin": "^5.7.0", | ||
"@typescript-eslint/parser": "^5.7.0", | ||
"discord-api-types": "0.25.2", | ||
"@typescript-eslint/eslint-plugin": "^5.10.0", | ||
"@typescript-eslint/parser": "^5.10.0", | ||
"copyfiles": "^2.4.1", | ||
"discord-api-types": "0.26.1", | ||
"discord.js": "npm:@notenoughupdates/discord.js@dev", | ||
"eslint": "^8.4.1", | ||
"eslint": "^8.7.0", | ||
"eslint-config-prettier": "^8.3.0", | ||
@@ -57,3 +58,3 @@ "eslint-plugin-deprecation": "^1.3.2", | ||
"rimraf": "^3.0.2", | ||
"typedoc": "^0.22.10", | ||
"typedoc": "^0.22.11", | ||
"typescript": "^4.5.4" | ||
@@ -60,0 +61,0 @@ }, |
@@ -165,4 +165,4 @@ "use strict"; | ||
compareStreaming(oldMember, newMember) { | ||
const s1 = oldMember.presence?.activities.find(c => c.type === "STREAMING"); | ||
const s2 = newMember.presence?.activities.find(c => c.type === "STREAMING"); | ||
const s1 = oldMember.presence?.activities.find(c => c.type === "Streaming"); | ||
const s2 = newMember.presence?.activities.find(c => c.type === "Streaming"); | ||
if (s1 === s2) | ||
@@ -169,0 +169,0 @@ return 0; |
@@ -329,3 +329,3 @@ /// <reference types="node" /> | ||
*/ | ||
failure: void | (Flag & { | ||
failure: null | (Flag & { | ||
value: any; | ||
@@ -332,0 +332,0 @@ }); |
@@ -193,5 +193,5 @@ "use strict"; | ||
const handlerDefs = this.handler.argumentDefaults; | ||
const optional = (typeof this.prompt === "object" && this.prompt && this.prompt.optional) ?? | ||
(commandDefs.prompt && commandDefs.prompt.optional) ?? | ||
(handlerDefs.prompt && handlerDefs.prompt.optional) ?? | ||
const optional = (typeof this.prompt === "object" && this.prompt?.optional) ?? | ||
commandDefs.prompt?.optional ?? | ||
handlerDefs.prompt?.optional ?? | ||
null; | ||
@@ -198,0 +198,0 @@ const doOtherwise = async (failure) => { |
@@ -174,3 +174,3 @@ "use strict"; | ||
const channel = this.client.util.resolveChannel(phrase, message.guild.channels.cache); | ||
if (!channel || channel.type !== "GUILD_TEXT") | ||
if (!channel || !channel.isText()) | ||
return null; | ||
@@ -187,3 +187,3 @@ return channel; | ||
return null; | ||
const textChannels = channels.filter(c => c.type === "GUILD_TEXT"); | ||
const textChannels = channels.filter(c => c.isText()); | ||
return textChannels.size ? textChannels : null; | ||
@@ -197,3 +197,3 @@ }, | ||
const channel = this.client.util.resolveChannel(phrase, message.guild.channels.cache); | ||
if (!channel || channel.type !== "GUILD_VOICE") | ||
if (!channel || !channel.isVoice()) | ||
return null; | ||
@@ -210,3 +210,3 @@ return channel; | ||
return null; | ||
const voiceChannels = channels.filter(c => c.type === "GUILD_VOICE"); | ||
const voiceChannels = channels.filter(c => c.isVoice()); | ||
return voiceChannels.size ? voiceChannels : null; | ||
@@ -220,3 +220,3 @@ }, | ||
const channel = this.client.util.resolveChannel(phrase, message.guild.channels.cache); | ||
if (channel?.type !== "GUILD_CATEGORY") | ||
if (!channel || !channel.isCategory()) | ||
return null; | ||
@@ -233,3 +233,3 @@ return channel; | ||
return null; | ||
const categoryChannels = channels.filter(c => c.type === "GUILD_CATEGORY"); | ||
const categoryChannels = channels.filter(c => c.isCategory()); | ||
return categoryChannels.size ? categoryChannels : null; | ||
@@ -243,3 +243,3 @@ }, | ||
const channel = this.client.util.resolveChannel(phrase, message.guild.channels.cache); | ||
if (channel?.type !== "GUILD_NEWS") | ||
if (!channel || !channel.isNews()) | ||
return null; | ||
@@ -256,3 +256,3 @@ return channel; | ||
return null; | ||
const newsChannels = channels.filter(c => c.type === "GUILD_NEWS"); | ||
const newsChannels = channels.filter(c => c.isNews()); | ||
return newsChannels.size ? newsChannels : null; | ||
@@ -266,3 +266,3 @@ }, | ||
const channel = this.client.util.resolveChannel(phrase, message.guild.channels.cache); | ||
if (channel?.type !== "GUILD_STORE") | ||
if (!channel || !channel.isStore()) | ||
return null; | ||
@@ -279,4 +279,4 @@ return channel; | ||
return null; | ||
const storeChannels = channels.filter(c => c.type === "GUILD_STORE"); | ||
// eslint-disable-next-line deprecation/deprecation | ||
const storeChannels = channels.filter(c => c.isStore()); | ||
return storeChannels.size ? storeChannels : null; | ||
@@ -290,3 +290,3 @@ }, | ||
const channel = this.client.util.resolveChannel(phrase, message.guild.channels.cache); | ||
if (channel?.type !== "GUILD_STAGE_VOICE") | ||
if (!channel || !channel.isStage()) | ||
return null; | ||
@@ -303,3 +303,3 @@ return channel; | ||
return null; | ||
const storeChannels = channels.filter(c => c.type === "GUILD_STAGE_VOICE"); | ||
const storeChannels = channels.filter(c => c.isStage()); | ||
return storeChannels.size ? storeChannels : null; | ||
@@ -385,3 +385,3 @@ }, | ||
for (const channel of message.guild.channels.cache.values()) { | ||
if (!channel.isText()) | ||
if (!channel.isTextBased()) | ||
continue; | ||
@@ -407,3 +407,3 @@ try { | ||
for (const channel of message.guild.channels.cache.values()) { | ||
if (!channel.isText()) | ||
if (!channel.isTextBased()) | ||
continue; | ||
@@ -410,0 +410,0 @@ try { |
/// <reference types="node" /> | ||
import { ApplicationCommandOptionData, AutocompleteInteraction, Awaitable, Collection, CommandInteraction, DiscordAPIError, Guild, Message, Snowflake, TextBasedChannel, User } from "discord.js"; | ||
import { ApplicationCommandOptionData, AutocompleteInteraction, Awaitable, ChatInputCommandInteraction, Collection, DiscordAPIError, Guild, Message, Snowflake, TextBasedChannel, User } from "discord.js"; | ||
import type { CommandHandlerEvents as CommandHandlerEventsType } from "../../typings/events"; | ||
@@ -196,3 +196,3 @@ import AkairoMessage from "../../util/AkairoMessage.js"; | ||
*/ | ||
handleSlash(interaction: CommandInteraction): Promise<boolean | null>; | ||
handleSlash(interaction: ChatInputCommandInteraction): Promise<boolean | null>; | ||
/** | ||
@@ -383,3 +383,3 @@ * Handles autocomplete interactions. | ||
defaultPermission: boolean; | ||
type: "CHAT_INPUT" | "MESSAGE" | "USER"; | ||
type: "ChatInput" | "Message" | "User"; | ||
}[]; | ||
@@ -563,3 +563,3 @@ export declare class RegisterInteractionCommandError extends Error { | ||
*/ | ||
export declare type SlashResolveTypes = "boolean" | "channel" | "string" | "integer" | "number" | "user" | "member" | "role" | "mentionable" | "message"; | ||
export declare type SlashResolveTypes = "Boolean" | "Channel" | "String" | "Integer" | "Number" | "User" | "Member" | "Role" | "Mentionable" | "Message"; | ||
export {}; | ||
@@ -566,0 +566,0 @@ /** |
@@ -117,3 +117,3 @@ "use strict"; | ||
this.client.on("interactionCreate", i => { | ||
if (i.isCommand()) | ||
if (i.isChatInputCommand()) | ||
this.handleSlash(i); | ||
@@ -161,3 +161,3 @@ if (i.isAutocomplete()) | ||
defaultPermission: data.slashDefaultPermission, | ||
type: "CHAT_INPUT" | ||
type: "ChatInput" | ||
}); | ||
@@ -293,3 +293,3 @@ } | ||
id: u, | ||
type: "USER", | ||
type: "User", | ||
permission: true | ||
@@ -528,6 +528,7 @@ })) | ||
for (const option of interaction.options["_hoistedOptions"]) { | ||
if (["SUB_COMMAND", "SUB_COMMAND_GROUP"].includes(option.type)) | ||
if (option.type === "Subcommand" || option.type === "SubcommandGroup") | ||
continue; | ||
const originalOption = commandModule.slashOptions?.find(o => o.name === option.name); | ||
convertedOptions[option.name] = interaction.options[Util_js_1.default.snakeToCamelCase(`GET_${originalOption?.resolve ?? option.type}`)](option.name, false); | ||
const func = Util_js_1.default.pascalToCamelCase(`Get${originalOption?.resolve ?? option.type}`); | ||
convertedOptions[option.name] = interaction.options[func](option.name, false); | ||
} | ||
@@ -542,3 +543,4 @@ // Makes options that are not found to be null so that it matches the behavior normal commands. | ||
} | ||
if ([1 /* SUB_COMMAND */, "SUB_COMMAND"].includes(usedSubcommandOrGroup.type)) { | ||
if (usedSubcommandOrGroup.type === 1 /* Subcommand */ || | ||
usedSubcommandOrGroup.type === "Subcommand") { | ||
if (!usedSubcommandOrGroup.options) { | ||
@@ -550,3 +552,4 @@ this.client.emit("akairoDebug", "[handleSlash] Unable to find subcommand options"); | ||
} | ||
else if ([2 /* SUB_COMMAND_GROUP */, "SUB_COMMAND_GROUP"].includes(usedSubcommandOrGroup.type)) { | ||
else if (usedSubcommandOrGroup.type === 2 /* SubcommandGroup */ || | ||
usedSubcommandOrGroup.type === "SubcommandGroup") { | ||
const usedSubCommand = usedSubcommandOrGroup.options?.find(subcommand => subcommand.name === convertedOptions.subcommand); | ||
@@ -573,12 +576,12 @@ if (!usedSubCommand) { | ||
switch (option.type) { | ||
case "BOOLEAN" || 5 /* BOOLEAN */: | ||
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 */: | ||
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: | ||
@@ -585,0 +588,0 @@ convertedOptions[option.name] ??= null; |
@@ -1,2 +0,2 @@ | ||
import type { ContextMenuInteraction, Snowflake } from "discord.js"; | ||
import type { ContextMenuCommandInteraction, Snowflake } from "discord.js"; | ||
import type Category from "../../util/Category.js"; | ||
@@ -29,3 +29,3 @@ import type AkairoClient from "../AkairoClient.js"; | ||
*/ | ||
type: "USER" | "MESSAGE"; | ||
type: "User" | "Message"; | ||
/** | ||
@@ -56,3 +56,3 @@ * The category of this context menu command. | ||
*/ | ||
exec(interaction: ContextMenuInteraction): any; | ||
exec(interaction: ContextMenuCommandInteraction): any; | ||
} | ||
@@ -92,4 +92,4 @@ export default interface ContextMenuCommand extends AkairoModule { | ||
*/ | ||
type: "USER" | "MESSAGE"; | ||
type: "User" | "Message"; | ||
} | ||
//# sourceMappingURL=ContextMenuCommand.d.ts.map |
@@ -1,2 +0,2 @@ | ||
import type { Awaitable, Collection, ContextMenuInteraction } from "discord.js"; | ||
import type { Awaitable, Collection, ContextMenuCommandInteraction } from "discord.js"; | ||
import type { ContextMenuCommandHandlerEvents } from "../../typings/events"; | ||
@@ -50,3 +50,3 @@ import type Category from "../../util/Category.js"; | ||
*/ | ||
handle(interaction: ContextMenuInteraction): Promise<boolean | null>; | ||
handle(interaction: ContextMenuCommandInteraction): Promise<boolean | null>; | ||
/** | ||
@@ -58,3 +58,3 @@ * Handles errors from the handling. | ||
*/ | ||
emitError(err: Error, interaction: ContextMenuInteraction, command: ContextMenuCommand | AkairoModule): void; | ||
emitError(err: Error, interaction: ContextMenuCommandInteraction, command: ContextMenuCommand | AkairoModule): void; | ||
} | ||
@@ -61,0 +61,0 @@ declare type Events = ContextMenuCommandHandlerEvents; |
@@ -38,3 +38,3 @@ "use strict"; | ||
this.client.on("interactionCreate", i => { | ||
if (!i.isContextMenu()) | ||
if (!i.isUserContextMenuCommand()) | ||
return; | ||
@@ -41,0 +41,0 @@ this.handle(i); |
@@ -1,2 +0,2 @@ | ||
import type { ClientEvents, CommandInteraction, ContextMenuInteraction, Message } from "discord.js"; | ||
import type { ChatInputCommandInteraction, ClientEvents, ContextMenuCommandInteraction, Message } from "discord.js"; | ||
import type AkairoModule from "../struct/AkairoModule.js"; | ||
@@ -156,3 +156,3 @@ import type Command from "../struct/commands/Command.js"; | ||
*/ | ||
slashNotFound: [interaction: CommandInteraction]; | ||
slashNotFound: [interaction: ChatInputCommandInteraction]; | ||
/** | ||
@@ -229,3 +229,3 @@ * Emitted when a slash command starts execution. | ||
*/ | ||
error: [error: Error, interaction: ContextMenuInteraction, command: ContextMenuCommand]; | ||
error: [error: Error, interaction: ContextMenuCommandInteraction, command: ContextMenuCommand]; | ||
/** | ||
@@ -237,3 +237,3 @@ * Emitted when a context menu command finishes execution. | ||
*/ | ||
finished: [interaction: ContextMenuInteraction, command: ContextMenuCommand, returnValue: any]; | ||
finished: [interaction: ContextMenuCommandInteraction, command: ContextMenuCommand, returnValue: any]; | ||
/** | ||
@@ -243,3 +243,3 @@ * Emitted when a an incoming interaction command cannot be matched with a command. | ||
*/ | ||
notFound: [interaction: ContextMenuInteraction]; | ||
notFound: [interaction: ContextMenuCommandInteraction]; | ||
/** | ||
@@ -251,3 +251,3 @@ * Emitted when a command starts execution. | ||
*/ | ||
started: [interaction: ContextMenuInteraction, command: ContextMenuCommand]; | ||
started: [interaction: ContextMenuCommandInteraction, command: ContextMenuCommand]; | ||
/** | ||
@@ -260,3 +260,3 @@ * Emitted when a command is blocked. | ||
blocked: [ | ||
interaction: ContextMenuInteraction, | ||
interaction: ContextMenuCommandInteraction, | ||
command: Command, | ||
@@ -263,0 +263,0 @@ reason: typeof BuiltInReasons.OWNER | typeof BuiltInReasons.SUPER_USER |
import type { APIInteractionGuildMember, APIMessage } from "discord-api-types/v9"; | ||
import { Base, CommandInteraction, Guild, GuildMember, InteractionReplyOptions, Message, MessagePayload, Snowflake, TextBasedChannel, User } from "discord.js"; | ||
import { Base, ChatInputCommandInteraction, ContextMenuCommandInteraction, Guild, GuildMember, InteractionReplyOptions, Message, MessagePayload, Snowflake, TextBasedChannel, User } from "discord.js"; | ||
import type AkairoClient from "../struct/AkairoClient.js"; | ||
@@ -40,3 +40,3 @@ import type CommandUtil from "../struct/commands/CommandUtil.js"; | ||
*/ | ||
interaction: CommandInteraction; | ||
interaction: ChatInputCommandInteraction | ContextMenuCommandInteraction; | ||
/** | ||
@@ -59,3 +59,3 @@ * Represents the author of the interaction as a guild member. | ||
*/ | ||
constructor(client: AkairoClient, interaction: CommandInteraction); | ||
constructor(client: AkairoClient, interaction: ChatInputCommandInteraction | ContextMenuCommandInteraction); | ||
/** | ||
@@ -62,0 +62,0 @@ * The channel that the interaction was sent in. |
@@ -17,3 +17,3 @@ "use strict"; | ||
this.channelId = interaction.channelId; | ||
this.content = `${!interaction.command || interaction.command.type === "CHAT_INPUT" ? "/" : ""}${interaction.commandName}`; | ||
this.content = interaction.isChatInputCommand() ? interaction.toString() : interaction.commandName; | ||
this.createdTimestamp = interaction.createdTimestamp; | ||
@@ -26,19 +26,8 @@ this.guildId = interaction.guildId; | ||
const options = interaction.options; | ||
if (interaction.command?.type === "CHAT_INPUT") { | ||
if (options["_group"]) | ||
this.content += `group: ${options["_group"]}`; | ||
if (options["_subcommand"]) | ||
this.content += `subcommand: ${options["_subcommand"]}`; | ||
for (const option of options["_hoistedOptions"]) { | ||
if (["SUB_COMMAND", "SUB_COMMAND_GROUP"].includes(option.type)) | ||
continue; | ||
this.content += ` ${option.name}: ${options.get(option.name, false)?.value}`; | ||
} | ||
if (interaction.isMessageContextMenuCommand()) { | ||
this.content += `${options.getMessage("message").id}`; | ||
} | ||
else if (interaction.command?.type === "MESSAGE") { | ||
this.content += ` message: ${options.getMessage("message").id}`; | ||
else if (interaction.isUserContextMenuCommand()) { | ||
this.content += `${options.getUser("user").id}`; | ||
} | ||
else if (interaction.command?.type === "USER") { | ||
this.content += ` message: ${options.getUser("user").id}`; | ||
} | ||
} | ||
@@ -45,0 +34,0 @@ /** |
@@ -60,2 +60,7 @@ /// <reference types="node" /> | ||
static snakeToCamelCase(str: string): string; | ||
/** | ||
* Converts a string in PascalCase to camelCase. | ||
* @param str The string to convert. | ||
*/ | ||
static pascalToCamelCase(str: string): string; | ||
} | ||
@@ -62,0 +67,0 @@ export interface DeepEqualsOptions { |
@@ -131,4 +131,11 @@ "use strict"; | ||
} | ||
/** | ||
* Converts a string in PascalCase to camelCase. | ||
* @param str The string to convert. | ||
*/ | ||
static pascalToCamelCase(str) { | ||
return str.charAt(0).toLowerCase() + str.slice(1); | ||
} | ||
} | ||
exports.default = Util; | ||
//# sourceMappingURL=Util.js.map |
{ | ||
"name": "@notenoughupdates/discord-akairo", | ||
"version": "9.0.10-dev.1640804630.61aa536", | ||
"version": "9.0.10-dev.1642556098.bebde2e", | ||
"description": "A highly customizable bot framework for Discord.js.", | ||
@@ -45,9 +45,10 @@ "main": "./dist/src/index.js", | ||
"@favware/npm-deprecate": "^1.0.4", | ||
"@types/node": "^16.11.13", | ||
"@types/node": "^17.0.10", | ||
"@types/source-map-support": "^0.5.4", | ||
"@typescript-eslint/eslint-plugin": "^5.7.0", | ||
"@typescript-eslint/parser": "^5.7.0", | ||
"discord-api-types": "0.25.2", | ||
"@typescript-eslint/eslint-plugin": "^5.10.0", | ||
"@typescript-eslint/parser": "^5.10.0", | ||
"copyfiles": "^2.4.1", | ||
"discord-api-types": "0.26.1", | ||
"discord.js": "npm:@notenoughupdates/discord.js@dev", | ||
"eslint": "^8.4.1", | ||
"eslint": "^8.7.0", | ||
"eslint-config-prettier": "^8.3.0", | ||
@@ -57,3 +58,3 @@ "eslint-plugin-deprecation": "^1.3.2", | ||
"rimraf": "^3.0.2", | ||
"typedoc": "^0.22.10", | ||
"typedoc": "^0.22.11", | ||
"typescript": "^4.5.4" | ||
@@ -60,0 +61,0 @@ }, |
@@ -220,4 +220,4 @@ import { | ||
public compareStreaming(oldMember: GuildMember, newMember: GuildMember): 0 | 1 | 2 { | ||
const s1 = oldMember.presence?.activities.find(c => c.type === "STREAMING"); | ||
const s2 = newMember.presence?.activities.find(c => c.type === "STREAMING"); | ||
const s1 = oldMember.presence?.activities.find(c => c.type === "Streaming"); | ||
const s2 = newMember.presence?.activities.find(c => c.type === "Streaming"); | ||
if (s1 === s2) return 0; | ||
@@ -224,0 +224,0 @@ if (s1) return 1; |
@@ -364,5 +364,5 @@ import type { | ||
const optional = | ||
(typeof this.prompt === "object" && this.prompt && this.prompt.optional) ?? | ||
(commandDefs.prompt && commandDefs.prompt.optional) ?? | ||
(handlerDefs.prompt && handlerDefs.prompt.optional) ?? | ||
(typeof this.prompt === "object" && this.prompt?.optional) ?? | ||
commandDefs.prompt?.optional ?? | ||
handlerDefs.prompt?.optional ?? | ||
null; | ||
@@ -810,3 +810,3 @@ | ||
*/ | ||
failure: void | (Flag & { value: any }); | ||
failure: null | (Flag & { value: any }); | ||
} | ||
@@ -813,0 +813,0 @@ |
@@ -233,3 +233,3 @@ import { | ||
const channel = this.client.util.resolveChannel(phrase, message.guild.channels.cache); | ||
if (!channel || channel.type !== "GUILD_TEXT") return null; | ||
if (!channel || !channel.isText()) return null; | ||
@@ -245,4 +245,4 @@ return channel; | ||
const textChannels = channels.filter(c => c.type === "GUILD_TEXT"); | ||
return textChannels.size ? (textChannels as Collection<string, TextChannel>) : null; | ||
const textChannels = <Collection<string, TextChannel>>channels.filter(c => c.isText()); | ||
return textChannels.size ? textChannels : null; | ||
}, | ||
@@ -254,3 +254,3 @@ | ||
const channel = this.client.util.resolveChannel(phrase, message.guild.channels.cache); | ||
if (!channel || channel.type !== "GUILD_VOICE") return null; | ||
if (!channel || !channel.isVoice()) return null; | ||
return channel; | ||
@@ -265,4 +265,4 @@ }, | ||
const voiceChannels = channels.filter(c => c.type === "GUILD_VOICE"); | ||
return voiceChannels.size ? (voiceChannels as Collection<string, VoiceChannel>) : null; | ||
const voiceChannels = <Collection<string, VoiceChannel>>channels.filter(c => c.isVoice()); | ||
return voiceChannels.size ? voiceChannels : null; | ||
}, | ||
@@ -274,3 +274,3 @@ | ||
const channel = this.client.util.resolveChannel(phrase, message.guild.channels.cache); | ||
if (channel?.type !== "GUILD_CATEGORY") return null; | ||
if (!channel || !channel.isCategory()) return null; | ||
@@ -286,4 +286,4 @@ return channel; | ||
const categoryChannels = channels.filter(c => c.type === "GUILD_CATEGORY"); | ||
return categoryChannels.size ? (categoryChannels as Collection<string, CategoryChannel>) : null; | ||
const categoryChannels = <Collection<string, CategoryChannel>>channels.filter(c => c.isCategory()); | ||
return categoryChannels.size ? categoryChannels : null; | ||
}, | ||
@@ -295,3 +295,3 @@ | ||
const channel = this.client.util.resolveChannel(phrase, message.guild.channels.cache); | ||
if (channel?.type !== "GUILD_NEWS") return null; | ||
if (!channel || !channel.isNews()) return null; | ||
@@ -307,4 +307,4 @@ return channel; | ||
const newsChannels = channels.filter(c => c.type === "GUILD_NEWS"); | ||
return newsChannels.size ? (newsChannels as Collection<string, NewsChannel>) : null; | ||
const newsChannels = <Collection<string, NewsChannel>>channels.filter(c => c.isNews()); | ||
return newsChannels.size ? newsChannels : null; | ||
}, | ||
@@ -316,3 +316,3 @@ | ||
const channel = this.client.util.resolveChannel(phrase, message.guild.channels.cache); | ||
if (channel?.type !== "GUILD_STORE") return null; | ||
if (!channel || !channel.isStore()) return null; | ||
@@ -328,5 +328,5 @@ return channel; | ||
const storeChannels = channels.filter(c => c.type === "GUILD_STORE"); | ||
// eslint-disable-next-line deprecation/deprecation | ||
return storeChannels.size ? (storeChannels as Collection<string, StoreChannel>) : null; | ||
const storeChannels = <Collection<string, StoreChannel>>channels.filter(c => c.isStore()); | ||
return storeChannels.size ? storeChannels : null; | ||
}, | ||
@@ -338,3 +338,3 @@ | ||
const channel = this.client.util.resolveChannel(phrase, message.guild.channels.cache); | ||
if (channel?.type !== "GUILD_STAGE_VOICE") return null; | ||
if (!channel || !channel.isStage()) return null; | ||
@@ -350,4 +350,4 @@ return channel; | ||
const storeChannels = channels.filter(c => c.type === "GUILD_STAGE_VOICE"); | ||
return storeChannels.size ? (storeChannels as Collection<string, StageChannel>) : null; | ||
const storeChannels = <Collection<string, StageChannel>>channels.filter(c => c.isStage()); | ||
return storeChannels.size ? storeChannels : null; | ||
}, | ||
@@ -370,4 +370,4 @@ | ||
const storeChannels = channels.filter(c => c.isThread()); | ||
return storeChannels.size ? (storeChannels as Collection<string, ThreadChannel>) : null; | ||
const storeChannels = <Collection<string, ThreadChannel>>channels.filter(c => c.isThread()); | ||
return storeChannels.size ? storeChannels : null; | ||
}, | ||
@@ -425,3 +425,3 @@ | ||
for (const channel of message.guild.channels.cache.values()) { | ||
if (!channel.isText()) continue; | ||
if (!channel.isTextBased()) continue; | ||
try { | ||
@@ -446,3 +446,3 @@ return await channel.messages.fetch(phrase); | ||
for (const channel of message.guild.channels.cache.values()) { | ||
if (!channel.isText()) continue; | ||
if (!channel.isTextBased()) continue; | ||
try { | ||
@@ -449,0 +449,0 @@ return await channel.messages.fetch(phrase); |
import { | ||
ApplicationCommand, | ||
ApplicationCommandOptionData, | ||
ApplicationCommandOptionType, | ||
AutocompleteInteraction, | ||
Awaitable, | ||
ChatInputCommandInteraction, | ||
Collection, | ||
CommandInteraction, | ||
CommandInteractionOption, | ||
@@ -20,3 +21,2 @@ CommandInteractionOptionResolver, | ||
} from "discord.js"; | ||
import { ApplicationCommandOptionTypes } from "discord.js/typings/enums"; | ||
import type { CommandHandlerEvents as CommandHandlerEventsType } from "../../typings/events"; | ||
@@ -346,3 +346,3 @@ import AkairoError from "../../util/AkairoError.js"; | ||
this.client.on("interactionCreate", i => { | ||
if (i.isCommand()) this.handleSlash(i); | ||
if (i.isChatInputCommand()) this.handleSlash(i); | ||
if (i.isAutocomplete()) this.handleAutocomplete(i); | ||
@@ -371,3 +371,3 @@ }); | ||
defaultPermission: boolean; | ||
type: "CHAT_INPUT" | "MESSAGE" | "USER"; | ||
type: "ChatInput" | "Message" | "User"; | ||
}[] = []; | ||
@@ -381,3 +381,3 @@ const guildSlashCommandsParsed: Collection< | ||
defaultPermission: boolean; | ||
type: "CHAT_INPUT" | "MESSAGE" | "USER"; | ||
type: "ChatInput" | "Message" | "User"; | ||
}[] | ||
@@ -406,3 +406,3 @@ > = new Collection(); | ||
defaultPermission: data.slashDefaultPermission, | ||
type: "CHAT_INPUT" | ||
type: "ChatInput" | ||
}); | ||
@@ -541,3 +541,3 @@ } | ||
id: u, | ||
type: "USER", | ||
type: "User", | ||
permission: true | ||
@@ -750,3 +750,3 @@ })) | ||
// eslint-disable-next-line complexity | ||
public async handleSlash(interaction: CommandInteraction): Promise<boolean | null> { | ||
public async handleSlash(interaction: ChatInputCommandInteraction): Promise<boolean | null> { | ||
const commandModule = this.findCommand(interaction.commandName); | ||
@@ -805,8 +805,8 @@ | ||
for (const option of (interaction.options as CommandInteractionOptionResolver)["_hoistedOptions"]) { | ||
if (["SUB_COMMAND", "SUB_COMMAND_GROUP"].includes(option.type)) continue; | ||
if (option.type === "Subcommand" || option.type === "SubcommandGroup") continue; | ||
const originalOption = commandModule.slashOptions?.find(o => o.name === option.name); | ||
convertedOptions[option.name] = interaction.options[ | ||
Util.snakeToCamelCase(`GET_${originalOption?.resolve ?? option.type}`) as GetFunctions | ||
](option.name, false); | ||
const func = Util.pascalToCamelCase(`Get${originalOption?.resolve ?? option.type}`) as GetFunctions; | ||
convertedOptions[option.name] = interaction.options[func](option.name, false); | ||
} | ||
@@ -829,12 +829,16 @@ | ||
} | ||
if ([ApplicationCommandOptionTypes.SUB_COMMAND, "SUB_COMMAND"].includes(usedSubcommandOrGroup.type)) { | ||
if (!(usedSubcommandOrGroup as SubCommand).options) { | ||
if ( | ||
usedSubcommandOrGroup.type === ApplicationCommandOptionType.Subcommand || | ||
usedSubcommandOrGroup.type === "Subcommand" | ||
) { | ||
if (!(<SubCommand>usedSubcommandOrGroup).options) { | ||
this.client.emit("akairoDebug", "[handleSlash] Unable to find subcommand options"); | ||
return; | ||
} | ||
handleOptions((usedSubcommandOrGroup as SubCommand).options!); | ||
handleOptions((<SubCommand>usedSubcommandOrGroup).options!); | ||
} else if ( | ||
[ApplicationCommandOptionTypes.SUB_COMMAND_GROUP, "SUB_COMMAND_GROUP"].includes(usedSubcommandOrGroup.type) | ||
usedSubcommandOrGroup.type === ApplicationCommandOptionType.SubcommandGroup || | ||
usedSubcommandOrGroup.type === "SubcommandGroup" | ||
) { | ||
const usedSubCommand = (usedSubcommandOrGroup as SubCommandGroup).options?.find( | ||
const usedSubCommand = (<SubCommandGroup>usedSubcommandOrGroup).options?.find( | ||
subcommand => subcommand.name === convertedOptions.subcommand | ||
@@ -861,12 +865,12 @@ ); | ||
switch (option.type) { | ||
case "BOOLEAN" || ApplicationCommandOptionTypes.BOOLEAN: | ||
case "Boolean" || ApplicationCommandOptionType.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: | ||
case "Channel" || ApplicationCommandOptionType.Channel: | ||
case "Integer" || ApplicationCommandOptionType.Integer: | ||
case "Mentionable" || ApplicationCommandOptionType.Mentionable: | ||
case "Number" || ApplicationCommandOptionType.Number: | ||
case "Role" || ApplicationCommandOptionType.Role: | ||
case "String" || ApplicationCommandOptionType.String: | ||
case "User" || ApplicationCommandOptionType.User: | ||
default: | ||
@@ -1620,3 +1624,3 @@ convertedOptions[option.name] ??= null; | ||
defaultPermission: boolean; | ||
type: "CHAT_INPUT" | "MESSAGE" | "USER"; | ||
type: "ChatInput" | "Message" | "User"; | ||
}[]; | ||
@@ -1842,12 +1846,12 @@ | ||
export type SlashResolveTypes = | ||
| "boolean" | ||
| "channel" | ||
| "string" | ||
| "integer" | ||
| "number" | ||
| "user" | ||
| "member" | ||
| "role" | ||
| "mentionable" | ||
| "message"; | ||
| "Boolean" | ||
| "Channel" | ||
| "String" | ||
| "Integer" | ||
| "Number" | ||
| "User" | ||
| "Member" | ||
| "Role" | ||
| "Mentionable" | ||
| "Message"; | ||
@@ -1854,0 +1858,0 @@ type GetFunctions = |
/* eslint-disable func-names, @typescript-eslint/no-unused-vars */ | ||
import type { ContextMenuInteraction, Snowflake } from "discord.js"; | ||
import type { ContextMenuCommandInteraction, Snowflake } from "discord.js"; | ||
import AkairoError from "../../util/AkairoError.js"; | ||
@@ -36,3 +36,3 @@ import type Category from "../../util/Category.js"; | ||
*/ | ||
public declare type: "USER" | "MESSAGE"; | ||
public declare type: "User" | "Message"; | ||
@@ -78,3 +78,3 @@ /** | ||
*/ | ||
public exec(interaction: ContextMenuInteraction): any { | ||
public exec(interaction: ContextMenuCommandInteraction): any { | ||
throw new AkairoError("NOT_IMPLEMENTED", this.constructor.name, "exec"); | ||
@@ -123,3 +123,3 @@ } | ||
*/ | ||
type: "USER" | "MESSAGE"; | ||
type: "User" | "Message"; | ||
} |
@@ -1,2 +0,2 @@ | ||
import type { Awaitable, Collection, ContextMenuInteraction } from "discord.js"; | ||
import type { Awaitable, Collection, ContextMenuCommandInteraction } from "discord.js"; | ||
import type { ContextMenuCommandHandlerEvents } from "../../typings/events"; | ||
@@ -80,3 +80,3 @@ import AkairoError from "../../util/AkairoError.js"; | ||
this.client.on("interactionCreate", i => { | ||
if (!i.isContextMenu()) return; | ||
if (!i.isUserContextMenuCommand()) return; | ||
@@ -92,3 +92,3 @@ this.handle(i); | ||
*/ | ||
public async handle(interaction: ContextMenuInteraction): Promise<boolean | null> { | ||
public async handle(interaction: ContextMenuCommandInteraction): Promise<boolean | null> { | ||
const command = this.modules.find(module => module.name === interaction.commandName); | ||
@@ -125,3 +125,3 @@ | ||
*/ | ||
public emitError(err: Error, interaction: ContextMenuInteraction, command: ContextMenuCommand | AkairoModule): void { | ||
public emitError(err: Error, interaction: ContextMenuCommandInteraction, command: ContextMenuCommand | AkairoModule): void { | ||
if (this.listenerCount(ContextCommandHandlerEvents.ERROR)) { | ||
@@ -128,0 +128,0 @@ this.emit(ContextCommandHandlerEvents.ERROR, err, interaction, command); |
@@ -1,2 +0,2 @@ | ||
import type { ClientEvents, CommandInteraction, ContextMenuInteraction, Message } from "discord.js"; | ||
import type { ChatInputCommandInteraction, ClientEvents, ContextMenuCommandInteraction, Message } from "discord.js"; | ||
import type AkairoModule from "../struct/AkairoModule.js"; | ||
@@ -178,3 +178,3 @@ import type Command from "../struct/commands/Command.js"; | ||
*/ | ||
slashNotFound: [interaction: CommandInteraction]; | ||
slashNotFound: [interaction: ChatInputCommandInteraction]; | ||
@@ -262,3 +262,3 @@ /** | ||
*/ | ||
error: [error: Error, interaction: ContextMenuInteraction, command: ContextMenuCommand]; | ||
error: [error: Error, interaction: ContextMenuCommandInteraction, command: ContextMenuCommand]; | ||
@@ -271,3 +271,3 @@ /** | ||
*/ | ||
finished: [interaction: ContextMenuInteraction, command: ContextMenuCommand, returnValue: any]; | ||
finished: [interaction: ContextMenuCommandInteraction, command: ContextMenuCommand, returnValue: any]; | ||
@@ -278,3 +278,3 @@ /** | ||
*/ | ||
notFound: [interaction: ContextMenuInteraction]; | ||
notFound: [interaction: ContextMenuCommandInteraction]; | ||
@@ -287,3 +287,3 @@ /** | ||
*/ | ||
started: [interaction: ContextMenuInteraction, command: ContextMenuCommand]; | ||
started: [interaction: ContextMenuCommandInteraction, command: ContextMenuCommand]; | ||
@@ -297,3 +297,3 @@ /** | ||
blocked: [ | ||
interaction: ContextMenuInteraction, | ||
interaction: ContextMenuCommandInteraction, | ||
command: Command, | ||
@@ -300,0 +300,0 @@ reason: typeof BuiltInReasons.OWNER | typeof BuiltInReasons.SUPER_USER |
import type { APIInteractionGuildMember, APIMessage } from "discord-api-types/v9"; | ||
import { | ||
Base, | ||
CommandInteraction, | ||
ChatInputCommandInteraction, | ||
CommandInteractionOptionResolver, | ||
ContextMenuCommandInteraction, | ||
Guild, | ||
@@ -61,3 +62,3 @@ GuildMember, | ||
*/ | ||
public declare interaction: CommandInteraction; | ||
public declare interaction: ChatInputCommandInteraction | ContextMenuCommandInteraction; | ||
@@ -84,3 +85,3 @@ /** | ||
*/ | ||
public constructor(client: AkairoClient, interaction: CommandInteraction) { | ||
public constructor(client: AkairoClient, interaction: ChatInputCommandInteraction | ContextMenuCommandInteraction) { | ||
super(client); | ||
@@ -91,3 +92,3 @@ | ||
this.channelId = interaction.channelId; | ||
this.content = `${!interaction.command || interaction.command.type === "CHAT_INPUT" ? "/" : ""}${interaction.commandName}`; | ||
this.content = interaction.isChatInputCommand() ? interaction.toString() : interaction.commandName; | ||
this.createdTimestamp = interaction.createdTimestamp; | ||
@@ -101,13 +102,6 @@ this.guildId = interaction.guildId; | ||
const options = interaction.options as CommandInteractionOptionResolver; | ||
if (interaction.command?.type === "CHAT_INPUT") { | ||
if (options["_group"]) this.content += `group: ${options["_group"]}`; | ||
if (options["_subcommand"]) this.content += `subcommand: ${options["_subcommand"]}`; | ||
for (const option of options["_hoistedOptions"]) { | ||
if (["SUB_COMMAND", "SUB_COMMAND_GROUP"].includes(option.type)) continue; | ||
this.content += ` ${option.name}: ${options.get(option.name, false)?.value}`; | ||
} | ||
} else if (interaction.command?.type === "MESSAGE") { | ||
this.content += ` message: ${options.getMessage("message")!.id}`; | ||
} else if (interaction.command?.type === "USER") { | ||
this.content += ` message: ${options.getUser("user")!.id}`; | ||
if (interaction.isMessageContextMenuCommand()) { | ||
this.content += `${options.getMessage("message")!.id}`; | ||
} else if (interaction.isUserContextMenuCommand()) { | ||
this.content += `${options.getUser("user")!.id}`; | ||
} | ||
@@ -114,0 +108,0 @@ } |
@@ -146,2 +146,10 @@ /* eslint-disable @typescript-eslint/ban-types */ | ||
} | ||
/** | ||
* Converts a string in PascalCase to camelCase. | ||
* @param str The string to convert. | ||
*/ | ||
public static pascalToCamelCase(str: string): string { | ||
return str.charAt(0).toLowerCase() + str.slice(1); | ||
} | ||
} | ||
@@ -148,0 +156,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
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
16390
912697
16