@notenoughupdates/discord-akairo
Advanced tools
Comparing version 9.1.2 to 9.1.3-dev.1644799330.8fbaf39
{ | ||
"name": "@notenoughupdates/discord-akairo", | ||
"version": "9.1.2", | ||
"version": "9.1.3-dev.1644799330.8fbaf39", | ||
"description": "A highly customizable bot framework for Discord.js.", | ||
@@ -48,3 +48,3 @@ "main": "./dist/src/index.js", | ||
"discord-api-types": "^0.26.1", | ||
"discord.js": "^13.6.0", | ||
"discord.js": "npm:@notenoughupdates/discord.js@dev", | ||
"eslint": "^8.7.0", | ||
@@ -51,0 +51,0 @@ "eslint-config-prettier": "^8.3.0", |
/// <reference types="node" /> | ||
import { APIEmbed } from "discord-api-types"; | ||
import { BufferResolvable, Collection, Emoji, Guild, GuildChannel, GuildMember, MessageAttachment, MessageEmbed, PermissionString, Role, Snowflake, ThreadChannel, User } from "discord.js"; | ||
import { BufferResolvable, Collection, Embed, Emoji, Guild, GuildChannel, GuildMember, MessageAttachment, PermissionsString, Role, Snowflake, ThreadChannel, User } from "discord.js"; | ||
import type { Stream } from "stream"; | ||
@@ -88,3 +88,3 @@ import type { AkairoClient } from "./AkairoClient.js"; | ||
*/ | ||
embed(data?: MessageEmbed | APIEmbed): MessageEmbed; | ||
embed(data?: Embed | APIEmbed): Embed; | ||
/** | ||
@@ -100,3 +100,3 @@ * Combination of `<Client>.fetchUser()` and `<Guild>.fetchMember()`. | ||
*/ | ||
permissionNames(): PermissionString[]; | ||
permissionNames(): PermissionsString[]; | ||
/** | ||
@@ -103,0 +103,0 @@ * Resolves a channel from a string, such as an ID, a name, or a mention. |
@@ -166,4 +166,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 === 1 /* Streaming */); | ||
const s2 = newMember.presence?.activities.find(c => c.type === 1 /* Streaming */); | ||
if (s1 === s2) | ||
@@ -182,3 +182,3 @@ return 0; | ||
embed(data) { | ||
return new discord_js_1.MessageEmbed(data); | ||
return new discord_js_1.Embed(data); | ||
} | ||
@@ -199,3 +199,3 @@ /** | ||
permissionNames() { | ||
return Object.keys(discord_js_1.Permissions.FLAGS); | ||
return Object.keys(discord_js_1.PermissionFlagsBits); | ||
} | ||
@@ -288,4 +288,4 @@ /** | ||
const resolved = []; | ||
for (const key of Object.keys(discord_js_1.Permissions.FLAGS)) { | ||
if (BigInt(number) & discord_js_1.Permissions.FLAGS[key]) | ||
for (const key of Object.keys(discord_js_1.PermissionFlagsBits)) { | ||
if (BigInt(number) & discord_js_1.PermissionFlagsBits[key]) | ||
resolved.push(key); | ||
@@ -292,0 +292,0 @@ } |
@@ -175,3 +175,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; | ||
@@ -197,3 +197,3 @@ return channel; | ||
const channel = this.client.util.resolveChannel(phrase, message.guild.channels.cache); | ||
if (!channel || channel.type !== "GUILD_VOICE") | ||
if (!channel || !channel.isVoice()) | ||
return null; | ||
@@ -219,3 +219,3 @@ return channel; | ||
const channel = this.client.util.resolveChannel(phrase, message.guild.channels.cache); | ||
if (!channel || channel.type !== "GUILD_CATEGORY") | ||
if (!channel || !channel.isCategory()) | ||
return null; | ||
@@ -232,3 +232,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; | ||
@@ -242,3 +242,3 @@ }, | ||
const channel = this.client.util.resolveChannel(phrase, message.guild.channels.cache); | ||
if (!channel || channel.type !== "GUILD_NEWS") | ||
if (!channel || !channel.isNews()) | ||
return null; | ||
@@ -255,3 +255,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; | ||
@@ -265,3 +265,3 @@ }, | ||
const channel = this.client.util.resolveChannel(phrase, message.guild.channels.cache); | ||
if (!channel || channel.type !== "GUILD_STORE") | ||
if (!channel || !channel.isStore()) | ||
return null; | ||
@@ -279,3 +279,3 @@ return channel; | ||
// eslint-disable-next-line deprecation/deprecation | ||
const storeChannels = channels.filter(c => c.type === "GUILD_STORE"); | ||
const storeChannels = channels.filter(c => c.isStore()); | ||
return storeChannels.size ? storeChannels : null; | ||
@@ -289,3 +289,3 @@ }, | ||
const channel = this.client.util.resolveChannel(phrase, message.guild.channels.cache); | ||
if (!channel || channel.type !== "GUILD_STAGE_VOICE") | ||
if (!channel || !channel.isStage()) | ||
return null; | ||
@@ -302,3 +302,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; | ||
@@ -384,3 +384,3 @@ }, | ||
for (const channel of message.guild.channels.cache.values()) { | ||
if (!channel.isText()) | ||
if (!channel.isTextBased()) | ||
continue; | ||
@@ -406,3 +406,3 @@ try { | ||
for (const channel of message.guild.channels.cache.values()) { | ||
if (!channel.isText()) | ||
if (!channel.isTextBased()) | ||
continue; | ||
@@ -409,0 +409,0 @@ try { |
/// <reference types="node" /> | ||
import { ApplicationCommandData, AutocompleteInteraction, Awaitable, Collection, CommandInteraction, DiscordAPIError, Guild, Message, Snowflake, TextBasedChannel, User } from "discord.js"; | ||
import { ApplicationCommandData, 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>; | ||
/** | ||
@@ -199,0 +199,0 @@ * Handles autocomplete interactions. |
@@ -160,3 +160,3 @@ "use strict"; | ||
this.client.on("interactionCreate", i => { | ||
if (i.isCommand()) | ||
if (i.isChatInputCommand()) | ||
this.handleSlash(i); | ||
@@ -203,3 +203,3 @@ if (i.isAutocomplete()) | ||
defaultPermission: data.slashDefaultPermission, | ||
type: 1 /* CHAT_INPUT */ | ||
type: 1 /* ChatInput */ | ||
}); | ||
@@ -229,8 +229,4 @@ } | ||
name: options.name, | ||
description: options.type === 1 /* CHAT_INPUT */ || options.type === "CHAT_INPUT" | ||
? options.description ?? "" | ||
: undefined, | ||
options: options.type === 1 /* CHAT_INPUT */ || options.type === "CHAT_INPUT" | ||
? options.options ?? [] | ||
: undefined, | ||
description: options.type === 1 /* ChatInput */ ? options.description ?? "" : undefined, | ||
options: options.type === 1 /* ChatInput */ ? options.options ?? [] : undefined, | ||
defaultPermission: options.defaultPermission, | ||
@@ -280,8 +276,4 @@ type: options.type | ||
name: options.name, | ||
description: options.type === 1 /* CHAT_INPUT */ || options.type === "CHAT_INPUT" | ||
? options.description ?? "" | ||
: undefined, | ||
options: options.type === 1 /* CHAT_INPUT */ || options.type === "CHAT_INPUT" | ||
? options.options ?? [] | ||
: undefined, | ||
description: options.type === 1 /* ChatInput */ ? options.description ?? "" : undefined, | ||
options: options.type === 1 /* ChatInput */ ? options.options ?? [] : undefined, | ||
defaultPermission: options.defaultPermission, | ||
@@ -351,3 +343,3 @@ type: options.type | ||
id: u, | ||
type: "USER", | ||
type: 2 /* User */, | ||
permission: true | ||
@@ -587,6 +579,7 @@ })) | ||
for (const option of interaction.options["_hoistedOptions"]) { | ||
if (option.type === "SUB_COMMAND" || option.type === "SUB_COMMAND_GROUP") | ||
if (option.type === 1 /* Subcommand */ || | ||
option.type === 2 /* SubcommandGroup */) | ||
continue; | ||
const originalOption = commandModule.slashOptions?.find(o => o.name === option.name); | ||
const func = `get${originalOption?.resolve ?? [option.type.charAt(0) + Util_js_1.Util.snakeToCamelCase(option.type.substring(1))]}`; | ||
const func = `get${originalOption?.resolve ?? AkairoApplicationCommandOptionType[option.type]}`; | ||
if (![ | ||
@@ -603,3 +596,3 @@ "getBoolean", | ||
].includes(func)) | ||
throw new Error(`${func} is not a valid get function.`); | ||
throw new Error(` ${option.type}`); | ||
convertedOptions[option.name] = interaction.options[func](option.name, false); | ||
@@ -615,4 +608,3 @@ } | ||
} | ||
if (usedSubcommandOrGroup.type === "SUB_COMMAND" || | ||
usedSubcommandOrGroup.type === 1 /* SUB_COMMAND */) { | ||
if (usedSubcommandOrGroup.type === 1 /* Subcommand */) { | ||
if (!usedSubcommandOrGroup.options) { | ||
@@ -624,4 +616,3 @@ this.client.emit("akairoDebug", "[handleSlash] Unable to find subcommand options"); | ||
} | ||
else if (usedSubcommandOrGroup.type === "SUB_COMMAND_GROUP" || | ||
usedSubcommandOrGroup.type === 2 /* SUB_COMMAND_GROUP */) { | ||
else if (usedSubcommandOrGroup.type === 2 /* SubcommandGroup */) { | ||
const usedSubCommand = usedSubcommandOrGroup.options?.find(subcommand => subcommand.name === convertedOptions.subcommand); | ||
@@ -648,20 +639,12 @@ if (!usedSubCommand) { | ||
switch (option.type) { | ||
case 5 /* BOOLEAN */: | ||
case "BOOLEAN": | ||
case 5 /* Boolean */: | ||
convertedOptions[option.name] ??= false; | ||
break; | ||
case 7 /* CHANNEL */: | ||
case "CHANNEL": | ||
case 4 /* INTEGER */: | ||
case "INTEGER": | ||
case 9 /* MENTIONABLE */: | ||
case "MENTIONABLE": | ||
case 10 /* NUMBER */: | ||
case "NUMBER": | ||
case 8 /* ROLE */: | ||
case "ROLE": | ||
case 3 /* STRING */: | ||
case "STRING": | ||
case 6 /* USER */: | ||
case "USER": | ||
case 7 /* Channel */: | ||
case 4 /* Integer */: | ||
case 9 /* Mentionable */: | ||
case 10 /* Number */: | ||
case 8 /* Role */: | ||
case 3 /* String */: | ||
case 6 /* User */: | ||
default: | ||
@@ -1003,3 +986,3 @@ convertedOptions[option.name] ??= null; | ||
else if (message.guild) { | ||
if (message.channel?.type === "DM") | ||
if (message.channel?.type === 1 /* DM */) | ||
return false; | ||
@@ -1031,3 +1014,3 @@ const missing = message.channel?.permissionsFor(message.guild.me)?.missing(command.clientPermissions); | ||
else if (message.guild) { | ||
if (message.channel?.type === "DM") | ||
if (message.channel?.type === 1 /* DM */) | ||
return false; | ||
@@ -1313,3 +1296,22 @@ const missing = message.channel?.permissionsFor(message.author)?.missing(command.userPermissions); | ||
const slashResolvable = ["Boolean", "Channel", "String", "Integer", "Number", "User", "Member", "Role", "Mentionable"]; | ||
// todo: remove this once discord-api-types updates | ||
/** | ||
* Used for reverse mapping since discord exports its enums as const enums. | ||
* @internal | ||
*/ | ||
var AkairoApplicationCommandOptionType; | ||
(function (AkairoApplicationCommandOptionType) { | ||
AkairoApplicationCommandOptionType[AkairoApplicationCommandOptionType["Subcommand"] = 1] = "Subcommand"; | ||
AkairoApplicationCommandOptionType[AkairoApplicationCommandOptionType["SubcommandGroup"] = 2] = "SubcommandGroup"; | ||
AkairoApplicationCommandOptionType[AkairoApplicationCommandOptionType["String"] = 3] = "String"; | ||
AkairoApplicationCommandOptionType[AkairoApplicationCommandOptionType["Integer"] = 4] = "Integer"; | ||
AkairoApplicationCommandOptionType[AkairoApplicationCommandOptionType["Boolean"] = 5] = "Boolean"; | ||
// eslint-disable-next-line @typescript-eslint/no-shadow | ||
AkairoApplicationCommandOptionType[AkairoApplicationCommandOptionType["User"] = 6] = "User"; | ||
AkairoApplicationCommandOptionType[AkairoApplicationCommandOptionType["Channel"] = 7] = "Channel"; | ||
AkairoApplicationCommandOptionType[AkairoApplicationCommandOptionType["Role"] = 8] = "Role"; | ||
AkairoApplicationCommandOptionType[AkairoApplicationCommandOptionType["Mentionable"] = 9] = "Mentionable"; | ||
AkairoApplicationCommandOptionType[AkairoApplicationCommandOptionType["Number"] = 10] = "Number"; | ||
})(AkairoApplicationCommandOptionType || (AkairoApplicationCommandOptionType = {})); | ||
/** | ||
* @typedef {CommandInteractionOptionResolver} VSCodePleaseStopRemovingMyImports | ||
@@ -1316,0 +1318,0 @@ * @internal |
@@ -1,2 +0,2 @@ | ||
import { type ContextMenuInteraction, type Snowflake } from "discord.js"; | ||
import { ApplicationCommandType, type ContextMenuCommandInteraction, type 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: ApplicationCommandType.User | ApplicationCommandType.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 interface ContextMenuCommand extends AkairoModule { | ||
*/ | ||
type: "USER" | "MESSAGE"; | ||
type: ApplicationCommandType.User | ApplicationCommandType.Message; | ||
} | ||
//# sourceMappingURL=ContextMenuCommand.d.ts.map |
@@ -25,4 +25,4 @@ "use strict"; | ||
throw new TypeError("options.ownerOnly must be a boolean"); | ||
if (type !== "USER" && type !== "MESSAGE") | ||
throw new TypeError("options.type must be either 'USER' or 'MESSAGE'."); | ||
if (type !== 2 /* User */ && type !== 3 /* Message */) | ||
throw new TypeError("options.type must be either ApplicationCommandType.User or ApplicationCommandType.Message."); | ||
super(id, { category }); | ||
@@ -29,0 +29,0 @@ this.guilds = guilds; |
@@ -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; |
@@ -36,3 +36,3 @@ "use strict"; | ||
this.client.on("interactionCreate", i => { | ||
if (!i.isUserContextMenu()) | ||
if (!i.isUserContextMenuCommand()) | ||
return; | ||
@@ -39,0 +39,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, GuildTextBasedChannel, InteractionReplyOptions, Message, MessagePayload, Snowflake, TextBasedChannel, User } from "discord.js"; | ||
import { Base, ChatInputCommandInteraction, Guild, GuildMember, GuildTextBasedChannel, 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; | ||
/** | ||
@@ -59,3 +59,3 @@ * Represents the author of the interaction as a guild member. | ||
*/ | ||
constructor(client: AkairoClient, interaction: CommandInteraction); | ||
constructor(client: AkairoClient, interaction: ChatInputCommandInteraction); | ||
/** | ||
@@ -62,0 +62,0 @@ * The channel that the interaction was sent in. |
{ | ||
"name": "@notenoughupdates/discord-akairo", | ||
"version": "9.1.2", | ||
"version": "9.1.3-dev.1644799330.8fbaf39", | ||
"description": "A highly customizable bot framework for Discord.js.", | ||
@@ -48,3 +48,3 @@ "main": "./dist/src/index.js", | ||
"discord-api-types": "^0.26.1", | ||
"discord.js": "^13.6.0", | ||
"discord.js": "npm:@notenoughupdates/discord.js@dev", | ||
"eslint": "^8.7.0", | ||
@@ -51,0 +51,0 @@ "eslint-config-prettier": "^8.3.0", |
import { APIEmbed } from "discord-api-types"; | ||
import { | ||
ActivityType, | ||
BufferResolvable, | ||
Collection, | ||
Embed, | ||
Emoji, | ||
@@ -10,5 +12,4 @@ Guild, | ||
MessageAttachment, | ||
MessageEmbed, | ||
Permissions, | ||
PermissionString, | ||
PermissionFlagsBits, | ||
PermissionsString, | ||
Role, | ||
@@ -221,4 +222,4 @@ Snowflake, | ||
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 === ActivityType.Streaming); | ||
const s2 = newMember.presence?.activities.find(c => c.type === ActivityType.Streaming); | ||
if (s1 === s2) return 0; | ||
@@ -234,4 +235,4 @@ if (s1) return 1; | ||
*/ | ||
public embed(data?: MessageEmbed | APIEmbed): MessageEmbed { | ||
return new MessageEmbed(data); | ||
public embed(data?: Embed | APIEmbed): Embed { | ||
return new Embed(data); | ||
} | ||
@@ -253,4 +254,4 @@ | ||
*/ | ||
public permissionNames(): PermissionString[] { | ||
return Object.keys(Permissions.FLAGS) as PermissionString[]; | ||
public permissionNames(): PermissionsString[] { | ||
return Object.keys(PermissionFlagsBits) as PermissionsString[]; | ||
} | ||
@@ -393,4 +394,4 @@ | ||
for (const key of Object.keys(Permissions.FLAGS)) { | ||
if (BigInt(number) & Permissions.FLAGS[key as PermissionString]) resolved.push(key); | ||
for (const key of Object.keys(PermissionFlagsBits)) { | ||
if (BigInt(number) & PermissionFlagsBits[key as PermissionsString]) resolved.push(key); | ||
} | ||
@@ -397,0 +398,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; | ||
@@ -253,3 +253,3 @@ return channel; | ||
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; | ||
@@ -272,3 +272,3 @@ }, | ||
const channel = this.client.util.resolveChannel(phrase, message.guild.channels.cache); | ||
if (!channel || channel.type !== "GUILD_CATEGORY") return null; | ||
if (!channel || !channel.isCategory()) return null; | ||
@@ -284,3 +284,3 @@ return channel; | ||
const categoryChannels = <Collection<string, CategoryChannel>>channels.filter(c => c.type === "GUILD_CATEGORY"); | ||
const categoryChannels = <Collection<string, CategoryChannel>>channels.filter(c => c.isCategory()); | ||
return categoryChannels.size ? categoryChannels : null; | ||
@@ -293,3 +293,3 @@ }, | ||
const channel = this.client.util.resolveChannel(phrase, message.guild.channels.cache); | ||
if (!channel || channel.type !== "GUILD_NEWS") return null; | ||
if (!channel || !channel.isNews()) return null; | ||
@@ -305,3 +305,3 @@ return channel; | ||
const newsChannels = <Collection<string, NewsChannel>>channels.filter(c => c.type === "GUILD_NEWS"); | ||
const newsChannels = <Collection<string, NewsChannel>>channels.filter(c => c.isNews()); | ||
return newsChannels.size ? newsChannels : null; | ||
@@ -314,3 +314,3 @@ }, | ||
const channel = this.client.util.resolveChannel(phrase, message.guild.channels.cache); | ||
if (!channel || channel.type !== "GUILD_STORE") return null; | ||
if (!channel || !channel.isStore()) return null; | ||
@@ -327,3 +327,3 @@ return channel; | ||
// eslint-disable-next-line deprecation/deprecation | ||
const storeChannels = <Collection<string, StoreChannel>>channels.filter(c => c.type === "GUILD_STORE"); | ||
const storeChannels = <Collection<string, StoreChannel>>channels.filter(c => c.isStore()); | ||
return storeChannels.size ? storeChannels : null; | ||
@@ -336,3 +336,3 @@ }, | ||
const channel = this.client.util.resolveChannel(phrase, message.guild.channels.cache); | ||
if (!channel || channel.type !== "GUILD_STAGE_VOICE") return null; | ||
if (!channel || !channel.isStage()) return null; | ||
@@ -348,3 +348,3 @@ return channel; | ||
const storeChannels = <Collection<string, StageChannel>>channels.filter(c => c.type === "GUILD_STAGE_VOICE"); | ||
const storeChannels = <Collection<string, StageChannel>>channels.filter(c => c.isStage()); | ||
return storeChannels.size ? storeChannels : null; | ||
@@ -422,3 +422,3 @@ }, | ||
for (const channel of message.guild.channels.cache.values()) { | ||
if (!channel.isText()) continue; | ||
if (!channel.isTextBased()) continue; | ||
try { | ||
@@ -443,3 +443,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 { | ||
@@ -446,0 +446,0 @@ return await channel.messages.fetch(phrase); |
@@ -5,6 +5,10 @@ import { | ||
ApplicationCommandOptionData, | ||
ApplicationCommandOptionType, | ||
ApplicationCommandPermissionType, | ||
ApplicationCommandType, | ||
AutocompleteInteraction, | ||
Awaitable, | ||
ChannelType, | ||
ChatInputCommandInteraction, | ||
Collection, | ||
CommandInteraction, | ||
CommandInteractionOption, | ||
@@ -21,3 +25,2 @@ CommandInteractionOptionResolver, | ||
} from "discord.js"; | ||
import { ApplicationCommandOptionTypes, ApplicationCommandTypes } from "discord.js/typings/enums"; | ||
import type { CommandHandlerEvents as CommandHandlerEventsType } from "../../typings/events"; | ||
@@ -380,3 +383,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); | ||
@@ -421,3 +424,3 @@ }); | ||
defaultPermission: data.slashDefaultPermission, | ||
type: ApplicationCommandTypes.CHAT_INPUT | ||
type: ApplicationCommandType.ChatInput | ||
}); | ||
@@ -449,10 +452,4 @@ } | ||
name: options.name, | ||
description: | ||
options.type === ApplicationCommandTypes.CHAT_INPUT || options.type === "CHAT_INPUT" | ||
? options.description ?? "" | ||
: undefined, | ||
options: | ||
options.type === ApplicationCommandTypes.CHAT_INPUT || options.type === "CHAT_INPUT" | ||
? options.options ?? [] | ||
: undefined, | ||
description: options.type === ApplicationCommandType.ChatInput ? options.description ?? "" : undefined, | ||
options: options.type === ApplicationCommandType.ChatInput ? options.options ?? [] : undefined, | ||
defaultPermission: options.defaultPermission, | ||
@@ -497,10 +494,4 @@ type: options.type | ||
name: options.name, | ||
description: | ||
options.type === ApplicationCommandTypes.CHAT_INPUT || options.type === "CHAT_INPUT" | ||
? options.description ?? "" | ||
: undefined, | ||
options: | ||
options.type === ApplicationCommandTypes.CHAT_INPUT || options.type === "CHAT_INPUT" | ||
? options.options ?? [] | ||
: undefined, | ||
description: options.type === ApplicationCommandType.ChatInput ? options.description ?? "" : undefined, | ||
options: options.type === ApplicationCommandType.ChatInput ? options.options ?? [] : undefined, | ||
defaultPermission: options.defaultPermission, | ||
@@ -576,3 +567,3 @@ type: options.type | ||
id: u, | ||
type: "USER", | ||
type: ApplicationCommandPermissionType.User, | ||
permission: true | ||
@@ -787,3 +778,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); | ||
@@ -842,8 +833,10 @@ | ||
for (const option of (interaction.options as CommandInteractionOptionResolver)["_hoistedOptions"]) { | ||
if (option.type === "SUB_COMMAND" || option.type === "SUB_COMMAND_GROUP") continue; | ||
if ( | ||
option.type === ApplicationCommandOptionType.Subcommand || | ||
option.type === ApplicationCommandOptionType.SubcommandGroup | ||
) | ||
continue; | ||
const originalOption = commandModule.slashOptions?.find(o => o.name === option.name); | ||
const func = `get${ | ||
originalOption?.resolve ?? [option.type.charAt(0) + Util.snakeToCamelCase(option.type.substring(1))] | ||
}` as GetFunction; | ||
const func = `get${originalOption?.resolve ?? AkairoApplicationCommandOptionType[option.type]}` as GetFunction; | ||
if ( | ||
@@ -864,3 +857,3 @@ !( | ||
) | ||
throw new Error(`${func} is not a valid get function.`); | ||
throw new Error(` ${option.type}`); | ||
convertedOptions[option.name] = interaction.options[func](option.name, false); | ||
@@ -884,6 +877,3 @@ } | ||
} | ||
if ( | ||
usedSubcommandOrGroup.type === "SUB_COMMAND" || | ||
usedSubcommandOrGroup.type === ApplicationCommandOptionTypes.SUB_COMMAND | ||
) { | ||
if (usedSubcommandOrGroup.type === ApplicationCommandOptionType.Subcommand) { | ||
if (!(<SubCommand>usedSubcommandOrGroup).options) { | ||
@@ -894,6 +884,3 @@ this.client.emit("akairoDebug", "[handleSlash] Unable to find subcommand options"); | ||
handleOptions((<SubCommand>usedSubcommandOrGroup).options!); | ||
} else if ( | ||
usedSubcommandOrGroup.type === "SUB_COMMAND_GROUP" || | ||
usedSubcommandOrGroup.type === ApplicationCommandOptionTypes.SUB_COMMAND_GROUP | ||
) { | ||
} else if (usedSubcommandOrGroup.type === ApplicationCommandOptionType.SubcommandGroup) { | ||
const usedSubCommand = (<SubCommandGroup>usedSubcommandOrGroup).options?.find( | ||
@@ -921,20 +908,12 @@ subcommand => subcommand.name === convertedOptions.subcommand | ||
switch (option.type) { | ||
case ApplicationCommandOptionTypes.BOOLEAN: | ||
case "BOOLEAN": | ||
case ApplicationCommandOptionType.Boolean: | ||
convertedOptions[option.name] ??= false; | ||
break; | ||
case ApplicationCommandOptionTypes.CHANNEL: | ||
case "CHANNEL": | ||
case ApplicationCommandOptionTypes.INTEGER: | ||
case "INTEGER": | ||
case ApplicationCommandOptionTypes.MENTIONABLE: | ||
case "MENTIONABLE": | ||
case ApplicationCommandOptionTypes.NUMBER: | ||
case "NUMBER": | ||
case ApplicationCommandOptionTypes.ROLE: | ||
case "ROLE": | ||
case ApplicationCommandOptionTypes.STRING: | ||
case "STRING": | ||
case ApplicationCommandOptionTypes.USER: | ||
case "USER": | ||
case ApplicationCommandOptionType.Channel: | ||
case ApplicationCommandOptionType.Integer: | ||
case ApplicationCommandOptionType.Mentionable: | ||
case ApplicationCommandOptionType.Number: | ||
case ApplicationCommandOptionType.Role: | ||
case ApplicationCommandOptionType.String: | ||
case ApplicationCommandOptionType.User: | ||
default: | ||
@@ -1305,3 +1284,3 @@ convertedOptions[option.name] ??= null; | ||
} else if (message.guild) { | ||
if (message.channel?.type === "DM") return false; | ||
if (message.channel?.type === ChannelType.DM) return false; | ||
const missing = message.channel?.permissionsFor(message.guild.me!)?.missing(command.clientPermissions); | ||
@@ -1333,3 +1312,3 @@ if (missing?.length) { | ||
} else if (message.guild) { | ||
if (message.channel?.type === "DM") return false; | ||
if (message.channel?.type === ChannelType.DM) return false; | ||
const missing = message.channel?.permissionsFor(message.author)?.missing(command.userPermissions); | ||
@@ -1927,5 +1906,24 @@ if (missing?.length) { | ||
// todo: remove this once discord-api-types updates | ||
/** | ||
* Used for reverse mapping since discord exports its enums as const enums. | ||
* @internal | ||
*/ | ||
enum AkairoApplicationCommandOptionType { | ||
Subcommand = ApplicationCommandOptionType.Subcommand, | ||
SubcommandGroup = ApplicationCommandOptionType.SubcommandGroup, | ||
String = ApplicationCommandOptionType.String, | ||
Integer = ApplicationCommandOptionType.Integer, | ||
Boolean = ApplicationCommandOptionType.Boolean, | ||
// eslint-disable-next-line @typescript-eslint/no-shadow | ||
User = ApplicationCommandOptionType.User, | ||
Channel = ApplicationCommandOptionType.Channel, | ||
Role = ApplicationCommandOptionType.Role, | ||
Mentionable = ApplicationCommandOptionType.Mentionable, | ||
Number = ApplicationCommandOptionType.Number | ||
} | ||
/** | ||
* @typedef {CommandInteractionOptionResolver} VSCodePleaseStopRemovingMyImports | ||
* @internal | ||
*/ |
/* eslint-disable func-names, @typescript-eslint/no-unused-vars */ | ||
import { type ContextMenuInteraction, type Snowflake } from "discord.js"; | ||
import { ApplicationCommandType, type ContextMenuCommandInteraction, type Snowflake } from "discord.js"; | ||
import { AkairoError } from "../../util/AkairoError.js"; | ||
@@ -37,3 +37,3 @@ import type { Category } from "../../util/Category.js"; | ||
*/ | ||
public declare type: "USER" | "MESSAGE"; | ||
public declare type: ApplicationCommandType.User | ApplicationCommandType.Message; | ||
@@ -72,3 +72,4 @@ /** | ||
if (ownerOnly !== undefined && typeof ownerOnly !== "boolean") throw new TypeError("options.ownerOnly must be a boolean"); | ||
if (type !== "USER" && type !== "MESSAGE") throw new TypeError("options.type must be either 'USER' or 'MESSAGE'."); | ||
if (type !== ApplicationCommandType.User && type !== ApplicationCommandType.Message) | ||
throw new TypeError("options.type must be either ApplicationCommandType.User or ApplicationCommandType.Message."); | ||
@@ -88,3 +89,3 @@ super(id, { category }); | ||
*/ | ||
public exec(interaction: ContextMenuInteraction): any { | ||
public exec(interaction: ContextMenuCommandInteraction): any { | ||
throw new AkairoError("NOT_IMPLEMENTED", this.constructor.name, "exec"); | ||
@@ -133,3 +134,3 @@ } | ||
*/ | ||
type: "USER" | "MESSAGE"; | ||
type: ApplicationCommandType.User | ApplicationCommandType.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.isUserContextMenu()) 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, | ||
Guild, | ||
@@ -61,3 +61,3 @@ GuildMember, | ||
*/ | ||
public declare interaction: CommandInteraction; | ||
public declare interaction: ChatInputCommandInteraction; | ||
@@ -84,3 +84,3 @@ /** | ||
*/ | ||
public constructor(client: AkairoClient, interaction: CommandInteraction) { | ||
public constructor(client: AkairoClient, interaction: ChatInputCommandInteraction) { | ||
super(client); | ||
@@ -87,0 +87,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
Deprecated
MaintenanceThe maintainer of the package marked it as deprecated. This could indicate that a single version should not be used, or that the package is no longer maintained and any new vulnerabilities will not be fixed.
Found 1 instance in 1 package
No v1
QualityPackage is not semver >=1. This means it is not stable and does not support ^ ranges.
Found 1 instance in 1 package
947885
16727
1
1