@notenoughupdates/discord-akairo
Advanced tools
Comparing version 9.1.3-dev.1655515392.64743a1 to 9.1.3-dev.1655521133.3f5780d
{ | ||
"name": "@notenoughupdates/discord-akairo", | ||
"version": "9.1.3-dev.1655515392.64743a1", | ||
"version": "9.1.3-dev.1655521133.3f5780d", | ||
"description": "A highly customizable bot framework for Discord.js.", | ||
@@ -5,0 +5,0 @@ "main": "./dist/src/index.js", |
/// <reference types="node" /> | ||
import type { CategoryChannel, Collection, DirectoryChannel, Emoji, Guild, GuildBasedChannel, GuildChannel, GuildEmoji, GuildMember, Invite, Message, MessageOptions, MessagePayload, NewsChannel, Role, Snowflake, StageChannel, TextChannel, ThreadChannel, User, VoiceChannel } from "discord.js"; | ||
import type { CategoryChannel, Collection, DirectoryChannel, Emoji, Guild, GuildBasedChannel, GuildChannel, GuildEmoji, GuildMember, Invite, Message, MessageOptions, MessagePayload, NewsChannel, Role, Snowflake, StageChannel, TextBasedChannel, TextChannel, ThreadChannel, User, VoiceBasedChannel, VoiceChannel } from "discord.js"; | ||
import type { URL } from "node:url"; | ||
import { ArgumentTypes } from "../../../util/Constants.js"; | ||
import type { AkairoClient } from "../../AkairoClient.js"; | ||
@@ -488,56 +489,62 @@ import type { ContextMenuCommand } from "../../contextMenuCommands/ContextMenuCommand.js"; | ||
export interface BaseArgumentType { | ||
string: string | null; | ||
lowercase: string | null; | ||
uppercase: string | null; | ||
charCodes: number[] | null; | ||
number: number | null; | ||
integer: number | null; | ||
bigint: bigint | null; | ||
emojint: number | null; | ||
url: URL | null; | ||
date: Date | null; | ||
color: number | null; | ||
user: User | null; | ||
users: Collection<Snowflake, User> | null; | ||
member: GuildMember | null; | ||
members: Collection<Snowflake, GuildMember> | null; | ||
relevant: User | GuildMember | null; | ||
relevants: Collection<Snowflake, User> | Collection<Snowflake, GuildMember> | null; | ||
channel: GuildBasedChannel | null; | ||
channels: Collection<Snowflake, GuildBasedChannel> | null; | ||
textChannel: TextChannel | null; | ||
textChannels: Collection<Snowflake, TextChannel> | null; | ||
voiceChannel: VoiceChannel | null; | ||
voiceChannels: Collection<Snowflake, VoiceChannel> | null; | ||
categoryChannel: CategoryChannel | null; | ||
categoryChannels: Collection<Snowflake, CategoryChannel> | null; | ||
newsChannel: NewsChannel | null; | ||
newsChannels: Collection<Snowflake, NewsChannel> | null; | ||
stageChannel: StageChannel | null; | ||
stageChannels: Collection<Snowflake, StageChannel> | null; | ||
threadChannel: ThreadChannel | null; | ||
threadChannels: Collection<Snowflake, ThreadChannel> | null; | ||
directoryChannel: DirectoryChannel | null; | ||
directoryChannels: Collection<Snowflake, DirectoryChannel> | null; | ||
role: Role | null; | ||
roles: Collection<Snowflake, Role> | null; | ||
emoji: Emoji | null; | ||
emojis: Collection<Snowflake, Emoji> | null; | ||
guild: Guild | null; | ||
guilds: Collection<Snowflake, Guild> | null; | ||
message: Message | null; | ||
guildMessage: Message | null; | ||
relevantMessage: Message | null; | ||
invite: Invite | null; | ||
userMention: User | null; | ||
memberMention: GuildMember | null; | ||
channelMention: ThreadChannel | GuildChannel | null; | ||
roleMention: Role | null; | ||
emojiMention: GuildEmoji | null; | ||
commandAlias: Command | null; | ||
command: Command | null; | ||
inhibitor: Inhibitor | null; | ||
listener: Listener | null; | ||
task: Task | null; | ||
contextMenuCommand: ContextMenuCommand | null; | ||
[ArgumentTypes.STRING]: string | null; | ||
[ArgumentTypes.LOWERCASE]: string | null; | ||
[ArgumentTypes.UPPERCASE]: string | null; | ||
[ArgumentTypes.CHAR_CODES]: number[] | null; | ||
[ArgumentTypes.NUMBER]: number | null; | ||
[ArgumentTypes.INTEGER]: number | null; | ||
[ArgumentTypes.BIGINT]: bigint | null; | ||
[ArgumentTypes.EMOJINT]: number | null; | ||
[ArgumentTypes.URL]: URL | null; | ||
[ArgumentTypes.DATE]: Date | null; | ||
[ArgumentTypes.COLOR]: number | null; | ||
[ArgumentTypes.USER]: User | null; | ||
[ArgumentTypes.USERS]: Collection<Snowflake, User> | null; | ||
[ArgumentTypes.MEMBER]: GuildMember | null; | ||
[ArgumentTypes.MEMBERS]: Collection<Snowflake, GuildMember> | null; | ||
[ArgumentTypes.RELEVANT]: User | GuildMember | null; | ||
[ArgumentTypes.RELEVANTS]: Collection<Snowflake, User> | Collection<Snowflake, GuildMember> | null; | ||
[ArgumentTypes.CHANNEL]: GuildBasedChannel | null; | ||
[ArgumentTypes.CHANNELS]: Collection<Snowflake, GuildBasedChannel> | null; | ||
[ArgumentTypes.TEXT_CHANNEL]: TextChannel | null; | ||
[ArgumentTypes.TEXT_CHANNELS]: Collection<Snowflake, TextChannel> | null; | ||
[ArgumentTypes.VOICE_CHANNEL]: VoiceChannel | null; | ||
[ArgumentTypes.VOICE_CHANNELS]: Collection<Snowflake, VoiceChannel> | null; | ||
[ArgumentTypes.CATEGORY_CHANNEL]: CategoryChannel | null; | ||
[ArgumentTypes.CATEGORY_CHANNELS]: Collection<Snowflake, CategoryChannel> | null; | ||
[ArgumentTypes.NEWS_CHANNEL]: NewsChannel | null; | ||
[ArgumentTypes.NEWS_CHANNELS]: Collection<Snowflake, NewsChannel> | null; | ||
[ArgumentTypes.STAGE_CHANNEL]: StageChannel | null; | ||
[ArgumentTypes.STAGE_CHANNELS]: Collection<Snowflake, StageChannel> | null; | ||
[ArgumentTypes.THREAD_CHANNEL]: ThreadChannel | null; | ||
[ArgumentTypes.THREAD_CHANNELS]: Collection<Snowflake, ThreadChannel> | null; | ||
[ArgumentTypes.DIRECTORY_CHANNEL]: DirectoryChannel | null; | ||
[ArgumentTypes.DIRECTORY_CHANNELS]: Collection<Snowflake, DirectoryChannel> | null; | ||
[ArgumentTypes.FORUM_CHANNEL]: unknown | null; | ||
[ArgumentTypes.FORUM_CHANNELS]: Collection<Snowflake, unknown> | null; | ||
[ArgumentTypes.TEXT_BASED_CHANNEL]: TextBasedChannel | null; | ||
[ArgumentTypes.TEXT_BASED_CHANNELS]: Collection<Snowflake, TextBasedChannel> | null; | ||
[ArgumentTypes.VOICE_BASED_CHANNEL]: VoiceBasedChannel | null; | ||
[ArgumentTypes.VOICE_BASED_CHANNELS]: Collection<Snowflake, VoiceBasedChannel> | null; | ||
[ArgumentTypes.ROLE]: Role | null; | ||
[ArgumentTypes.ROLES]: Collection<Snowflake, Role> | null; | ||
[ArgumentTypes.EMOJI]: Emoji | null; | ||
[ArgumentTypes.EMOJIS]: Collection<Snowflake, Emoji> | null; | ||
[ArgumentTypes.GUILD]: Guild | null; | ||
[ArgumentTypes.GUILDS]: Collection<Snowflake, Guild> | null; | ||
[ArgumentTypes.MESSAGE]: Message | null; | ||
[ArgumentTypes.GUILD_MESSAGE]: Message | null; | ||
[ArgumentTypes.RELEVANT_MESSAGE]: Message | null; | ||
[ArgumentTypes.INVITE]: Invite | null; | ||
[ArgumentTypes.USER_MENTION]: User | null; | ||
[ArgumentTypes.MEMBER_MENTION]: GuildMember | null; | ||
[ArgumentTypes.CHANNEL_MENTION]: ThreadChannel | GuildChannel | null; | ||
[ArgumentTypes.ROLE_MENTION]: Role | null; | ||
[ArgumentTypes.EMOJI_MENTION]: GuildEmoji | null; | ||
[ArgumentTypes.COMMAND_ALIAS]: Command | null; | ||
[ArgumentTypes.COMMAND]: Command | null; | ||
[ArgumentTypes.INHIBITOR]: Inhibitor | null; | ||
[ArgumentTypes.LISTENER]: Listener | null; | ||
[ArgumentTypes.TASK]: Task | null; | ||
[ArgumentTypes.CONTEXT_MENU_COMMAND]: ContextMenuCommand | null; | ||
} | ||
@@ -544,0 +551,0 @@ /** |
@@ -46,2 +46,4 @@ import { Collection } from "discord.js"; | ||
constructor(handler: CommandHandler); | ||
private singleChannelBuiltInType; | ||
private multipleChannelBuiltInType; | ||
/** | ||
@@ -48,0 +50,0 @@ * Adds built-in types. |
@@ -25,2 +25,23 @@ "use strict"; | ||
} | ||
singleChannelBuiltInType(type) { | ||
return (message, phrase) => { | ||
if (!phrase || !message.inGuild()) | ||
return null; | ||
const channel = this.client.util.resolveChannel(phrase, message.guild.channels.cache); | ||
if (channel?.type !== type) | ||
return null; | ||
return channel; | ||
}; | ||
} | ||
multipleChannelBuiltInType(type) { | ||
return (message, phrase) => { | ||
if (!phrase || !message.inGuild()) | ||
return null; | ||
const channels = this.client.util.resolveChannels(phrase, message.guild.channels.cache); | ||
if (!channels.size) | ||
return null; | ||
const textChannels = channels.filter(c => c.type === type); | ||
return textChannels.size ? textChannels : null; | ||
}; | ||
} | ||
/** | ||
@@ -170,151 +191,69 @@ * Adds built-in types. | ||
}, | ||
[Constants_js_1.ArgumentTypes.TEXT_CHANNEL]: (message, phrase) => { | ||
if (!phrase) | ||
[Constants_js_1.ArgumentTypes.TEXT_CHANNEL]: this.singleChannelBuiltInType(discord_js_1.ChannelType.GuildText), | ||
[Constants_js_1.ArgumentTypes.TEXT_CHANNELS]: this.multipleChannelBuiltInType(discord_js_1.ChannelType.GuildText), | ||
[Constants_js_1.ArgumentTypes.VOICE_CHANNEL]: this.singleChannelBuiltInType(discord_js_1.ChannelType.GuildVoice), | ||
[Constants_js_1.ArgumentTypes.VOICE_CHANNELS]: this.multipleChannelBuiltInType(discord_js_1.ChannelType.GuildVoice), | ||
[Constants_js_1.ArgumentTypes.CATEGORY_CHANNEL]: this.singleChannelBuiltInType(discord_js_1.ChannelType.GuildCategory), | ||
[Constants_js_1.ArgumentTypes.CATEGORY_CHANNELS]: this.multipleChannelBuiltInType(discord_js_1.ChannelType.GuildCategory), | ||
[Constants_js_1.ArgumentTypes.NEWS_CHANNEL]: this.singleChannelBuiltInType(discord_js_1.ChannelType.GuildNews), | ||
[Constants_js_1.ArgumentTypes.NEWS_CHANNELS]: this.multipleChannelBuiltInType(discord_js_1.ChannelType.GuildCategory), | ||
[Constants_js_1.ArgumentTypes.STAGE_CHANNEL]: this.singleChannelBuiltInType(discord_js_1.ChannelType.GuildStageVoice), | ||
[Constants_js_1.ArgumentTypes.STAGE_CHANNELS]: this.multipleChannelBuiltInType(discord_js_1.ChannelType.GuildStageVoice), | ||
[Constants_js_1.ArgumentTypes.THREAD_CHANNEL]: (message, phrase) => { | ||
if (!phrase || !message.inGuild()) | ||
return null; | ||
if (!message.inGuild()) | ||
return null; | ||
const channel = this.client.util.resolveChannel(phrase, message.guild.channels.cache); | ||
if (channel?.type !== discord_js_1.ChannelType.GuildText) | ||
if (!channel?.isThread()) | ||
return null; | ||
return channel; | ||
}, | ||
[Constants_js_1.ArgumentTypes.TEXT_CHANNELS]: (message, phrase) => { | ||
if (!phrase) | ||
[Constants_js_1.ArgumentTypes.THREAD_CHANNELS]: (message, phrase) => { | ||
if (!phrase || !message.inGuild()) | ||
return null; | ||
if (!message.inGuild()) | ||
return null; | ||
const channels = this.client.util.resolveChannels(phrase, message.guild.channels.cache); | ||
if (!channels.size) | ||
return null; | ||
const textChannels = channels.filter(c => c.type === discord_js_1.ChannelType.GuildText); | ||
return textChannels.size ? textChannels : null; | ||
const threadChannels = channels.filter(c => c.isThread()); | ||
return threadChannels.size ? threadChannels : null; | ||
}, | ||
[Constants_js_1.ArgumentTypes.VOICE_CHANNEL]: (message, phrase) => { | ||
if (!phrase) | ||
// @ts-expect-error | ||
[Constants_js_1.ArgumentTypes.DIRECTORY_CHANNEL]: this.singleChannelBuiltInType(discord_js_1.ChannelType.GuildDirectory), | ||
// @ts-expect-error | ||
[Constants_js_1.ArgumentTypes.DIRECTORY_CHANNELS]: this.multipleChannelBuiltInType(discord_js_1.ChannelType.GuildDirectory), | ||
[Constants_js_1.ArgumentTypes.FORUM_CHANNEL]: this.singleChannelBuiltInType(discord_js_1.ChannelType.GuildForum), | ||
[Constants_js_1.ArgumentTypes.FORUM_CHANNELS]: this.multipleChannelBuiltInType(discord_js_1.ChannelType.GuildForum), | ||
[Constants_js_1.ArgumentTypes.TEXT_BASED_CHANNEL]: (message, phrase) => { | ||
if (!phrase || !message.inGuild()) | ||
return null; | ||
if (!message.inGuild()) | ||
return null; | ||
const channel = this.client.util.resolveChannel(phrase, message.guild.channels.cache); | ||
if (channel?.type !== discord_js_1.ChannelType.GuildVoice) | ||
if (!channel?.isTextBased()) | ||
return null; | ||
return channel; | ||
}, | ||
[Constants_js_1.ArgumentTypes.VOICE_CHANNELS]: (message, phrase) => { | ||
if (!phrase) | ||
[Constants_js_1.ArgumentTypes.TEXT_BASED_CHANNELS]: (message, phrase) => { | ||
if (!phrase || !message.inGuild()) | ||
return null; | ||
if (!message.inGuild()) | ||
return null; | ||
const channels = this.client.util.resolveChannels(phrase, message.guild.channels.cache); | ||
if (!channels.size) | ||
return null; | ||
const voiceChannels = channels.filter(c => c.type === discord_js_1.ChannelType.GuildVoice); | ||
return voiceChannels.size ? voiceChannels : null; | ||
const threadChannels = channels.filter(c => c.isTextBased()); | ||
return threadChannels.size ? threadChannels : null; | ||
}, | ||
[Constants_js_1.ArgumentTypes.CATEGORY_CHANNEL]: (message, phrase) => { | ||
if (!phrase) | ||
[Constants_js_1.ArgumentTypes.VOICE_BASED_CHANNEL]: (message, phrase) => { | ||
if (!phrase || !message.inGuild()) | ||
return null; | ||
if (!message.inGuild()) | ||
return null; | ||
const channel = this.client.util.resolveChannel(phrase, message.guild.channels.cache); | ||
if (channel?.type !== discord_js_1.ChannelType.GuildCategory) | ||
if (!channel?.isVoiceBased()) | ||
return null; | ||
return channel; | ||
}, | ||
[Constants_js_1.ArgumentTypes.CATEGORY_CHANNELS]: (message, phrase) => { | ||
if (!phrase) | ||
[Constants_js_1.ArgumentTypes.VOICE_BASED_CHANNELS]: (message, phrase) => { | ||
if (!phrase || !message.inGuild()) | ||
return null; | ||
if (!message.inGuild()) | ||
return null; | ||
const channels = this.client.util.resolveChannels(phrase, message.guild.channels.cache); | ||
if (!channels.size) | ||
return null; | ||
const categoryChannels = channels.filter(c => c.type === discord_js_1.ChannelType.GuildCategory); | ||
return categoryChannels.size ? categoryChannels : null; | ||
}, | ||
[Constants_js_1.ArgumentTypes.NEWS_CHANNEL]: (message, phrase) => { | ||
if (!phrase) | ||
return null; | ||
if (!message.inGuild()) | ||
return null; | ||
const channel = this.client.util.resolveChannel(phrase, message.guild.channels.cache); | ||
if (channel?.type !== discord_js_1.ChannelType.GuildNews) | ||
return null; | ||
return channel; | ||
}, | ||
[Constants_js_1.ArgumentTypes.NEWS_CHANNELS]: (message, phrase) => { | ||
if (!phrase) | ||
return null; | ||
if (!message.inGuild()) | ||
return null; | ||
const channels = this.client.util.resolveChannels(phrase, message.guild.channels.cache); | ||
if (!channels.size) | ||
return null; | ||
const newsChannels = channels.filter(c => c.type === discord_js_1.ChannelType.GuildNews); | ||
return newsChannels.size ? newsChannels : null; | ||
}, | ||
[Constants_js_1.ArgumentTypes.STAGE_CHANNEL]: (message, phrase) => { | ||
if (!phrase) | ||
return null; | ||
if (!message.inGuild()) | ||
return null; | ||
const channel = this.client.util.resolveChannel(phrase, message.guild.channels.cache); | ||
if (channel?.type !== discord_js_1.ChannelType.GuildStageVoice) | ||
return null; | ||
return channel; | ||
}, | ||
[Constants_js_1.ArgumentTypes.STAGE_CHANNELS]: (message, phrase) => { | ||
if (!phrase) | ||
return null; | ||
if (!message.inGuild()) | ||
return null; | ||
const channels = this.client.util.resolveChannels(phrase, message.guild.channels.cache); | ||
if (!channels.size) | ||
return null; | ||
const stageChannels = channels.filter(c => c.type === discord_js_1.ChannelType.GuildStageVoice); | ||
return stageChannels.size ? stageChannels : null; | ||
}, | ||
[Constants_js_1.ArgumentTypes.THREAD_CHANNEL]: (message, phrase) => { | ||
if (!phrase) | ||
return null; | ||
if (!message.inGuild()) | ||
return null; | ||
const channel = this.client.util.resolveChannel(phrase, message.guild.channels.cache); | ||
if (!channel?.isThread()) | ||
return null; | ||
return channel; | ||
}, | ||
[Constants_js_1.ArgumentTypes.THREAD_CHANNELS]: (message, phrase) => { | ||
if (!phrase) | ||
return null; | ||
if (!message.inGuild()) | ||
return null; | ||
const channels = this.client.util.resolveChannels(phrase, message.guild.channels.cache); | ||
if (!channels.size) | ||
return null; | ||
const threadChannels = channels.filter(c => c.isThread()); | ||
const threadChannels = channels.filter(c => c.isVoiceBased()); | ||
return threadChannels.size ? threadChannels : null; | ||
}, | ||
[Constants_js_1.ArgumentTypes.DIRECTORY_CHANNEL]: (message, phrase) => { | ||
if (!phrase) | ||
return null; | ||
if (!message.inGuild()) | ||
return null; | ||
const channel = this.client.util.resolveChannel(phrase, message.guild.channels.cache); | ||
// @ts-expect-error | ||
if (channel?.type !== discord_js_1.ChannelType.GuildDirectory) | ||
return null; | ||
return channel; | ||
}, | ||
[Constants_js_1.ArgumentTypes.DIRECTORY_CHANNELS]: (message, phrase) => { | ||
if (!phrase) | ||
return null; | ||
if (!message.inGuild()) | ||
return null; | ||
const channels = this.client.util.resolveChannels(phrase, message.guild.channels.cache); | ||
if (!channels.size) | ||
return null; | ||
// @ts-expect-error | ||
const directoryChannels = channels.filter(c => c.type === discord_js_1.ChannelType.GuildDirectory); | ||
return directoryChannels.size ? directoryChannels : null; | ||
}, | ||
[Constants_js_1.ArgumentTypes.ROLE]: (message, phrase) => { | ||
@@ -321,0 +260,0 @@ if (!phrase) |
@@ -46,2 +46,8 @@ export declare enum ArgumentMatches { | ||
DIRECTORY_CHANNELS = "directoryChannels", | ||
FORUM_CHANNEL = "forumChannel", | ||
FORUM_CHANNELS = "forumChannels", | ||
TEXT_BASED_CHANNEL = "textBasedChannel", | ||
TEXT_BASED_CHANNELS = "textBasedChannels", | ||
VOICE_BASED_CHANNEL = "voiceBasedChannel", | ||
VOICE_BASED_CHANNELS = "voiceBasedChannels", | ||
ROLE = "role", | ||
@@ -48,0 +54,0 @@ ROLES = "roles", |
@@ -51,2 +51,8 @@ "use strict"; | ||
ArgumentTypes["DIRECTORY_CHANNELS"] = "directoryChannels"; | ||
ArgumentTypes["FORUM_CHANNEL"] = "forumChannel"; | ||
ArgumentTypes["FORUM_CHANNELS"] = "forumChannels"; | ||
ArgumentTypes["TEXT_BASED_CHANNEL"] = "textBasedChannel"; | ||
ArgumentTypes["TEXT_BASED_CHANNELS"] = "textBasedChannels"; | ||
ArgumentTypes["VOICE_BASED_CHANNEL"] = "voiceBasedChannel"; | ||
ArgumentTypes["VOICE_BASED_CHANNELS"] = "voiceBasedChannels"; | ||
ArgumentTypes["ROLE"] = "role"; | ||
@@ -53,0 +59,0 @@ ArgumentTypes["ROLES"] = "roles"; |
{ | ||
"name": "@notenoughupdates/discord-akairo", | ||
"version": "9.1.3-dev.1655515392.64743a1", | ||
"version": "9.1.3-dev.1655521133.3f5780d", | ||
"description": "A highly customizable bot framework for Discord.js.", | ||
@@ -5,0 +5,0 @@ "main": "./dist/src/index.js", |
@@ -19,5 +19,7 @@ import type { | ||
StageChannel, | ||
TextBasedChannel, | ||
TextChannel, | ||
ThreadChannel, | ||
User, | ||
VoiceBasedChannel, | ||
VoiceChannel | ||
@@ -1011,56 +1013,62 @@ } from "discord.js"; | ||
export interface BaseArgumentType { | ||
string: string | null; | ||
lowercase: string | null; | ||
uppercase: string | null; | ||
charCodes: number[] | null; | ||
number: number | null; | ||
integer: number | null; | ||
bigint: bigint | null; | ||
emojint: number | null; | ||
url: URL | null; | ||
date: Date | null; | ||
color: number | null; | ||
user: User | null; | ||
users: Collection<Snowflake, User> | null; | ||
member: GuildMember | null; | ||
members: Collection<Snowflake, GuildMember> | null; | ||
relevant: User | GuildMember | null; | ||
relevants: Collection<Snowflake, User> | Collection<Snowflake, GuildMember> | null; | ||
channel: GuildBasedChannel | null; | ||
channels: Collection<Snowflake, GuildBasedChannel> | null; | ||
textChannel: TextChannel | null; | ||
textChannels: Collection<Snowflake, TextChannel> | null; | ||
voiceChannel: VoiceChannel | null; | ||
voiceChannels: Collection<Snowflake, VoiceChannel> | null; | ||
categoryChannel: CategoryChannel | null; | ||
categoryChannels: Collection<Snowflake, CategoryChannel> | null; | ||
newsChannel: NewsChannel | null; | ||
newsChannels: Collection<Snowflake, NewsChannel> | null; | ||
stageChannel: StageChannel | null; | ||
stageChannels: Collection<Snowflake, StageChannel> | null; | ||
threadChannel: ThreadChannel | null; | ||
threadChannels: Collection<Snowflake, ThreadChannel> | null; | ||
directoryChannel: DirectoryChannel | null; | ||
directoryChannels: Collection<Snowflake, DirectoryChannel> | null; | ||
role: Role | null; | ||
roles: Collection<Snowflake, Role> | null; | ||
emoji: Emoji | null; | ||
emojis: Collection<Snowflake, Emoji> | null; | ||
guild: Guild | null; | ||
guilds: Collection<Snowflake, Guild> | null; | ||
message: Message | null; | ||
guildMessage: Message | null; | ||
relevantMessage: Message | null; | ||
invite: Invite | null; | ||
userMention: User | null; | ||
memberMention: GuildMember | null; | ||
channelMention: ThreadChannel | GuildChannel | null; | ||
roleMention: Role | null; | ||
emojiMention: GuildEmoji | null; | ||
commandAlias: Command | null; | ||
command: Command | null; | ||
inhibitor: Inhibitor | null; | ||
listener: Listener | null; | ||
task: Task | null; | ||
contextMenuCommand: ContextMenuCommand | null; | ||
[ArgumentTypes.STRING]: string | null; | ||
[ArgumentTypes.LOWERCASE]: string | null; | ||
[ArgumentTypes.UPPERCASE]: string | null; | ||
[ArgumentTypes.CHAR_CODES]: number[] | null; | ||
[ArgumentTypes.NUMBER]: number | null; | ||
[ArgumentTypes.INTEGER]: number | null; | ||
[ArgumentTypes.BIGINT]: bigint | null; | ||
[ArgumentTypes.EMOJINT]: number | null; | ||
[ArgumentTypes.URL]: URL | null; | ||
[ArgumentTypes.DATE]: Date | null; | ||
[ArgumentTypes.COLOR]: number | null; | ||
[ArgumentTypes.USER]: User | null; | ||
[ArgumentTypes.USERS]: Collection<Snowflake, User> | null; | ||
[ArgumentTypes.MEMBER]: GuildMember | null; | ||
[ArgumentTypes.MEMBERS]: Collection<Snowflake, GuildMember> | null; | ||
[ArgumentTypes.RELEVANT]: User | GuildMember | null; | ||
[ArgumentTypes.RELEVANTS]: Collection<Snowflake, User> | Collection<Snowflake, GuildMember> | null; | ||
[ArgumentTypes.CHANNEL]: GuildBasedChannel | null; | ||
[ArgumentTypes.CHANNELS]: Collection<Snowflake, GuildBasedChannel> | null; | ||
[ArgumentTypes.TEXT_CHANNEL]: TextChannel | null; | ||
[ArgumentTypes.TEXT_CHANNELS]: Collection<Snowflake, TextChannel> | null; | ||
[ArgumentTypes.VOICE_CHANNEL]: VoiceChannel | null; | ||
[ArgumentTypes.VOICE_CHANNELS]: Collection<Snowflake, VoiceChannel> | null; | ||
[ArgumentTypes.CATEGORY_CHANNEL]: CategoryChannel | null; | ||
[ArgumentTypes.CATEGORY_CHANNELS]: Collection<Snowflake, CategoryChannel> | null; | ||
[ArgumentTypes.NEWS_CHANNEL]: NewsChannel | null; | ||
[ArgumentTypes.NEWS_CHANNELS]: Collection<Snowflake, NewsChannel> | null; | ||
[ArgumentTypes.STAGE_CHANNEL]: StageChannel | null; | ||
[ArgumentTypes.STAGE_CHANNELS]: Collection<Snowflake, StageChannel> | null; | ||
[ArgumentTypes.THREAD_CHANNEL]: ThreadChannel | null; | ||
[ArgumentTypes.THREAD_CHANNELS]: Collection<Snowflake, ThreadChannel> | null; | ||
[ArgumentTypes.DIRECTORY_CHANNEL]: DirectoryChannel | null; | ||
[ArgumentTypes.DIRECTORY_CHANNELS]: Collection<Snowflake, DirectoryChannel> | null; | ||
[ArgumentTypes.FORUM_CHANNEL]: unknown | null; | ||
[ArgumentTypes.FORUM_CHANNELS]: Collection<Snowflake, unknown> | null; | ||
[ArgumentTypes.TEXT_BASED_CHANNEL]: TextBasedChannel | null; | ||
[ArgumentTypes.TEXT_BASED_CHANNELS]: Collection<Snowflake, TextBasedChannel> | null; | ||
[ArgumentTypes.VOICE_BASED_CHANNEL]: VoiceBasedChannel | null; | ||
[ArgumentTypes.VOICE_BASED_CHANNELS]: Collection<Snowflake, VoiceBasedChannel> | null; | ||
[ArgumentTypes.ROLE]: Role | null; | ||
[ArgumentTypes.ROLES]: Collection<Snowflake, Role> | null; | ||
[ArgumentTypes.EMOJI]: Emoji | null; | ||
[ArgumentTypes.EMOJIS]: Collection<Snowflake, Emoji> | null; | ||
[ArgumentTypes.GUILD]: Guild | null; | ||
[ArgumentTypes.GUILDS]: Collection<Snowflake, Guild> | null; | ||
[ArgumentTypes.MESSAGE]: Message | null; | ||
[ArgumentTypes.GUILD_MESSAGE]: Message | null; | ||
[ArgumentTypes.RELEVANT_MESSAGE]: Message | null; | ||
[ArgumentTypes.INVITE]: Invite | null; | ||
[ArgumentTypes.USER_MENTION]: User | null; | ||
[ArgumentTypes.MEMBER_MENTION]: GuildMember | null; | ||
[ArgumentTypes.CHANNEL_MENTION]: ThreadChannel | GuildChannel | null; | ||
[ArgumentTypes.ROLE_MENTION]: Role | null; | ||
[ArgumentTypes.EMOJI_MENTION]: GuildEmoji | null; | ||
[ArgumentTypes.COMMAND_ALIAS]: Command | null; | ||
[ArgumentTypes.COMMAND]: Command | null; | ||
[ArgumentTypes.INHIBITOR]: Inhibitor | null; | ||
[ArgumentTypes.LISTENER]: Listener | null; | ||
[ArgumentTypes.TASK]: Task | null; | ||
[ArgumentTypes.CONTEXT_MENU_COMMAND]: ContextMenuCommand | null; | ||
} | ||
@@ -1067,0 +1075,0 @@ |
@@ -7,8 +7,12 @@ import { | ||
type DMChannel, | ||
type GuildBasedChannel, | ||
type GuildMember, | ||
type Message, | ||
type NewsChannel, | ||
type Snowflake, | ||
type StageChannel, | ||
type TextBasedChannel, | ||
type TextChannel, | ||
type ThreadChannel, | ||
type VoiceBasedChannel, | ||
type VoiceChannel | ||
@@ -80,2 +84,23 @@ } from "discord.js"; | ||
private singleChannelBuiltInType<R extends GuildBasedChannel>(type: ChannelType) { | ||
return (message: Message, phrase: string): R | null => { | ||
if (!phrase || !message.inGuild()) return null; | ||
const channel = this.client.util.resolveChannel(phrase, message.guild.channels.cache); | ||
if (channel?.type !== type) return null; | ||
return <R>channel; | ||
}; | ||
} | ||
private multipleChannelBuiltInType<R extends GuildBasedChannel>(type: ChannelType) { | ||
return (message: Message, phrase: string): Collection<Snowflake, R> | null => { | ||
if (!phrase || !message.inGuild()) return null; | ||
const channels = this.client.util.resolveChannels(phrase, message.guild.channels.cache); | ||
if (!channels.size) return null; | ||
const textChannels = <Collection<Snowflake, R>>channels.filter(c => c.type === type); | ||
return textChannels.size ? textChannels : null; | ||
}; | ||
} | ||
/** | ||
@@ -232,63 +257,26 @@ * Adds built-in types. | ||
[ArgumentTypes.TEXT_CHANNEL]: (message, phrase) => { | ||
if (!phrase) return null; | ||
if (!message.inGuild()) return null; | ||
const channel = this.client.util.resolveChannel(phrase, message.guild.channels.cache); | ||
if (channel?.type !== ChannelType.GuildText) return null; | ||
[ArgumentTypes.TEXT_CHANNEL]: this.singleChannelBuiltInType<TextChannel>(ChannelType.GuildText), | ||
return channel; | ||
}, | ||
[ArgumentTypes.TEXT_CHANNELS]: this.multipleChannelBuiltInType<TextChannel>(ChannelType.GuildText), | ||
[ArgumentTypes.TEXT_CHANNELS]: (message, phrase) => { | ||
if (!phrase) return null; | ||
if (!message.inGuild()) return null; | ||
const channels = this.client.util.resolveChannels(phrase, message.guild.channels.cache); | ||
if (!channels.size) return null; | ||
[ArgumentTypes.VOICE_CHANNEL]: this.singleChannelBuiltInType<VoiceChannel>(ChannelType.GuildVoice), | ||
const textChannels = <Collection<string, TextChannel>>channels.filter(c => c.type === ChannelType.GuildText); | ||
return textChannels.size ? textChannels : null; | ||
}, | ||
[ArgumentTypes.VOICE_CHANNELS]: this.multipleChannelBuiltInType<VoiceChannel>(ChannelType.GuildVoice), | ||
[ArgumentTypes.VOICE_CHANNEL]: (message, phrase) => { | ||
if (!phrase) return null; | ||
if (!message.inGuild()) return null; | ||
const channel = this.client.util.resolveChannel(phrase, message.guild.channels.cache); | ||
if (channel?.type !== ChannelType.GuildVoice) return null; | ||
return channel; | ||
}, | ||
[ArgumentTypes.CATEGORY_CHANNEL]: this.singleChannelBuiltInType<CategoryChannel>(ChannelType.GuildCategory), | ||
[ArgumentTypes.VOICE_CHANNELS]: (message, phrase) => { | ||
if (!phrase) return null; | ||
if (!message.inGuild()) return null; | ||
const channels = this.client.util.resolveChannels(phrase, message.guild.channels.cache); | ||
if (!channels.size) return null; | ||
[ArgumentTypes.CATEGORY_CHANNELS]: this.multipleChannelBuiltInType<CategoryChannel>(ChannelType.GuildCategory), | ||
const voiceChannels = <Collection<string, VoiceChannel>>channels.filter(c => c.type === ChannelType.GuildVoice); | ||
return voiceChannels.size ? voiceChannels : null; | ||
}, | ||
[ArgumentTypes.NEWS_CHANNEL]: this.singleChannelBuiltInType<NewsChannel>(ChannelType.GuildNews), | ||
[ArgumentTypes.CATEGORY_CHANNEL]: (message, phrase) => { | ||
if (!phrase) return null; | ||
if (!message.inGuild()) return null; | ||
const channel = this.client.util.resolveChannel(phrase, message.guild.channels.cache); | ||
if (channel?.type !== ChannelType.GuildCategory) return null; | ||
[ArgumentTypes.NEWS_CHANNELS]: this.multipleChannelBuiltInType<NewsChannel>(ChannelType.GuildCategory), | ||
return channel; | ||
}, | ||
[ArgumentTypes.STAGE_CHANNEL]: this.singleChannelBuiltInType<StageChannel>(ChannelType.GuildStageVoice), | ||
[ArgumentTypes.CATEGORY_CHANNELS]: (message, phrase) => { | ||
if (!phrase) return null; | ||
if (!message.inGuild()) return null; | ||
const channels = this.client.util.resolveChannels(phrase, message.guild.channels.cache); | ||
if (!channels.size) return null; | ||
[ArgumentTypes.STAGE_CHANNELS]: this.multipleChannelBuiltInType<StageChannel>(ChannelType.GuildStageVoice), | ||
const categoryChannels = <Collection<string, CategoryChannel>>channels.filter(c => c.type === ChannelType.GuildCategory); | ||
return categoryChannels.size ? categoryChannels : null; | ||
}, | ||
[ArgumentTypes.NEWS_CHANNEL]: (message, phrase) => { | ||
if (!phrase) return null; | ||
if (!message.inGuild()) return null; | ||
[ArgumentTypes.THREAD_CHANNEL]: (message, phrase) => { | ||
if (!phrase || !message.inGuild()) return null; | ||
const channel = this.client.util.resolveChannel(phrase, message.guild.channels.cache); | ||
if (channel?.type !== ChannelType.GuildNews) return null; | ||
if (!channel?.isThread()) return null; | ||
@@ -298,36 +286,25 @@ return channel; | ||
[ArgumentTypes.NEWS_CHANNELS]: (message, phrase) => { | ||
if (!phrase) return null; | ||
if (!message.inGuild()) return null; | ||
[ArgumentTypes.THREAD_CHANNELS]: (message, phrase) => { | ||
if (!phrase || !message.inGuild()) return null; | ||
const channels = this.client.util.resolveChannels(phrase, message.guild.channels.cache); | ||
if (!channels.size) return null; | ||
const newsChannels = <Collection<string, NewsChannel>>channels.filter(c => c.type === ChannelType.GuildNews); | ||
return newsChannels.size ? newsChannels : null; | ||
const threadChannels = <Collection<Snowflake, ThreadChannel>>channels.filter(c => c.isThread()); | ||
return threadChannels.size ? threadChannels : null; | ||
}, | ||
[ArgumentTypes.STAGE_CHANNEL]: (message, phrase) => { | ||
if (!phrase) return null; | ||
if (!message.inGuild()) return null; | ||
const channel = this.client.util.resolveChannel(phrase, message.guild.channels.cache); | ||
if (channel?.type !== ChannelType.GuildStageVoice) return null; | ||
// @ts-expect-error | ||
[ArgumentTypes.DIRECTORY_CHANNEL]: this.singleChannelBuiltInType<DirectoryChannel>(ChannelType.GuildDirectory), | ||
return channel; | ||
}, | ||
// @ts-expect-error | ||
[ArgumentTypes.DIRECTORY_CHANNELS]: this.multipleChannelBuiltInType<DirectoryChannel>(ChannelType.GuildDirectory), | ||
[ArgumentTypes.STAGE_CHANNELS]: (message, phrase) => { | ||
if (!phrase) return null; | ||
if (!message.inGuild()) return null; | ||
const channels = this.client.util.resolveChannels(phrase, message.guild.channels.cache); | ||
if (!channels.size) return null; | ||
[ArgumentTypes.FORUM_CHANNEL]: this.singleChannelBuiltInType<any>(ChannelType.GuildForum), | ||
const stageChannels = <Collection<string, StageChannel>>channels.filter(c => c.type === ChannelType.GuildStageVoice); | ||
return stageChannels.size ? stageChannels : null; | ||
}, | ||
[ArgumentTypes.FORUM_CHANNELS]: this.multipleChannelBuiltInType<any>(ChannelType.GuildForum), | ||
[ArgumentTypes.THREAD_CHANNEL]: (message, phrase) => { | ||
if (!phrase) return null; | ||
if (!message.inGuild()) return null; | ||
[ArgumentTypes.TEXT_BASED_CHANNEL]: (message, phrase) => { | ||
if (!phrase || !message.inGuild()) return null; | ||
const channel = this.client.util.resolveChannel(phrase, message.guild.channels.cache); | ||
if (!channel?.isThread()) return null; | ||
if (!channel?.isTextBased()) return null; | ||
@@ -337,18 +314,15 @@ return channel; | ||
[ArgumentTypes.THREAD_CHANNELS]: (message, phrase) => { | ||
if (!phrase) return null; | ||
if (!message.inGuild()) return null; | ||
[ArgumentTypes.TEXT_BASED_CHANNELS]: (message, phrase) => { | ||
if (!phrase || !message.inGuild()) return null; | ||
const channels = this.client.util.resolveChannels(phrase, message.guild.channels.cache); | ||
if (!channels.size) return null; | ||
const threadChannels = <Collection<string, ThreadChannel>>channels.filter(c => c.isThread()); | ||
const threadChannels = <Collection<Snowflake, TextBasedChannel>>channels.filter(c => c.isTextBased()); | ||
return threadChannels.size ? threadChannels : null; | ||
}, | ||
[ArgumentTypes.DIRECTORY_CHANNEL]: (message, phrase) => { | ||
if (!phrase) return null; | ||
if (!message.inGuild()) return null; | ||
[ArgumentTypes.VOICE_BASED_CHANNEL]: (message, phrase) => { | ||
if (!phrase || !message.inGuild()) return null; | ||
const channel = this.client.util.resolveChannel(phrase, message.guild.channels.cache); | ||
// @ts-expect-error | ||
if (channel?.type !== ChannelType.GuildDirectory) return null; | ||
if (!channel?.isVoiceBased()) return null; | ||
@@ -358,13 +332,9 @@ return channel; | ||
[ArgumentTypes.DIRECTORY_CHANNELS]: (message, phrase) => { | ||
if (!phrase) return null; | ||
if (!message.inGuild()) return null; | ||
[ArgumentTypes.VOICE_BASED_CHANNELS]: (message, phrase) => { | ||
if (!phrase || !message.inGuild()) return null; | ||
const channels = this.client.util.resolveChannels(phrase, message.guild.channels.cache); | ||
if (!channels.size) return null; | ||
// @ts-expect-error | ||
const directoryChannels = < | ||
Collection<string, DirectoryChannel> // @ts-expect-error | ||
>channels.filter(c => c.type === ChannelType.GuildDirectory); | ||
return directoryChannels.size ? directoryChannels : null; | ||
const threadChannels = <Collection<Snowflake, VoiceBasedChannel>>channels.filter(c => c.isVoiceBased()); | ||
return threadChannels.size ? threadChannels : null; | ||
}, | ||
@@ -371,0 +341,0 @@ |
@@ -47,2 +47,8 @@ export enum ArgumentMatches { | ||
DIRECTORY_CHANNELS = "directoryChannels", | ||
FORUM_CHANNEL = "forumChannel", | ||
FORUM_CHANNELS = "forumChannels", | ||
TEXT_BASED_CHANNEL = "textBasedChannel", | ||
TEXT_BASED_CHANNELS = "textBasedChannels", | ||
VOICE_BASED_CHANNEL = "voiceBasedChannel", | ||
VOICE_BASED_CHANNELS = "voiceBasedChannels", | ||
ROLE = "role", | ||
@@ -49,0 +55,0 @@ ROLES = "roles", |
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
44272249
28510