aboutsummaryrefslogtreecommitdiff
path: root/src/lib/extensions
diff options
context:
space:
mode:
Diffstat (limited to 'src/lib/extensions')
-rw-r--r--src/lib/extensions/discord-akairo/BushClientUtil.ts5
-rw-r--r--src/lib/extensions/discord-akairo/BushCommand.ts121
-rw-r--r--src/lib/extensions/discord-akairo/BushSlashMessage.ts16
3 files changed, 117 insertions, 25 deletions
diff --git a/src/lib/extensions/discord-akairo/BushClientUtil.ts b/src/lib/extensions/discord-akairo/BushClientUtil.ts
index 5ae2ac0..f44c80d 100644
--- a/src/lib/extensions/discord-akairo/BushClientUtil.ts
+++ b/src/lib/extensions/discord-akairo/BushClientUtil.ts
@@ -513,7 +513,7 @@ export class BushClientUtil extends ClientUtil {
if (!content) return { duration: 0, contentWithoutTime: null };
// eslint-disable-next-line prefer-const
- let duration = null;
+ let duration: number | null = null;
// Try to reduce false positives by requiring a space before the duration, this makes sure it still matches if it is
// in the beginning of the argument
let contentWithoutTime = ` ${content}`;
@@ -522,8 +522,7 @@ export class BushClientUtil extends ClientUtil {
const regex = BushConstants.TimeUnits[unit as keyof typeof BushConstants.TimeUnits].match;
const match = regex.exec(contentWithoutTime);
const value = Number(match?.groups?.[unit]);
- if (!isNaN(value))
- (duration as unknown as number) += value * BushConstants.TimeUnits[unit as keyof typeof BushConstants.TimeUnits].value;
+ if (!isNaN(value)) duration! += value * BushConstants.TimeUnits[unit as keyof typeof BushConstants.TimeUnits].value;
if (remove) contentWithoutTime = contentWithoutTime.replace(regex, '');
}
diff --git a/src/lib/extensions/discord-akairo/BushCommand.ts b/src/lib/extensions/discord-akairo/BushCommand.ts
index 6b54e20..0d0a0a8 100644
--- a/src/lib/extensions/discord-akairo/BushCommand.ts
+++ b/src/lib/extensions/discord-akairo/BushCommand.ts
@@ -1,34 +1,109 @@
+import { type DiscordEmojiInfo, type RoleWithDuration } from '#args';
import {
- BushArgumentTypeCaster,
- BushUser,
- ParsedDuration,
+ type BushArgumentTypeCaster,
+ type BushBaseGuildVoiceChannel,
+ type BushCategoryChannel,
type BushClient,
type BushCommandHandler,
+ type BushEmoji,
+ type BushGuild,
+ type BushGuildBasedChannel,
+ type BushGuildChannel,
+ type BushGuildEmoji,
+ type BushGuildMember,
+ type BushInhibitor,
+ type BushListener,
type BushMessage,
- type BushSlashMessage
+ type BushNewsChannel,
+ type BushRole,
+ type BushSlashMessage,
+ type BushStageChannel,
+ type BushStoreChannel,
+ type BushTask,
+ type BushTextChannel,
+ type BushThreadChannel,
+ type BushUser,
+ type BushVoiceChannel,
+ type ParsedDuration
} from '#lib';
import {
- AkairoApplicationCommandAutocompleteOption,
- AkairoApplicationCommandChannelOptionData,
- AkairoApplicationCommandChoicesData,
- AkairoApplicationCommandNonOptionsData,
- AkairoApplicationCommandNumericOptionData,
- AkairoApplicationCommandOptionData,
- AkairoApplicationCommandSubCommandData,
- AkairoApplicationCommandSubGroupData,
Command,
- MissingPermissionSupplier,
- SlashOption,
- SlashResolveTypes,
+ type AkairoApplicationCommandAutocompleteOption,
+ type AkairoApplicationCommandChannelOptionData,
+ type AkairoApplicationCommandChoicesData,
+ type AkairoApplicationCommandNonOptionsData,
+ type AkairoApplicationCommandNumericOptionData,
+ type AkairoApplicationCommandOptionData,
+ type AkairoApplicationCommandSubCommandData,
+ type AkairoApplicationCommandSubGroupData,
type ArgumentOptions,
- type CommandOptions
+ type ArgumentType,
+ type ArgumentTypeCaster,
+ type BaseArgumentType,
+ type CommandOptions,
+ type ContextMenuCommand,
+ type MissingPermissionSupplier,
+ type SlashOption,
+ type SlashResolveTypes
} from 'discord-akairo';
-import { ArgumentType, ArgumentTypeCaster, BaseArgumentType } from 'discord-akairo/dist/src/struct/commands/arguments/Argument';
-import { ApplicationCommandOptionChoice, PermissionString, type PermissionResolvable, type Snowflake } from 'discord.js';
-import { DiscordEmojiInfo } from '../../../arguments/discordEmoji';
-import { RoleWithDuration } from '../../../arguments/roleWithDuration';
+import {
+ type ApplicationCommandOptionChoice,
+ type Collection,
+ type Invite,
+ type PermissionResolvable,
+ type PermissionString,
+ type Snowflake
+} from 'discord.js';
+
+export interface OverriddenBaseArgumentType extends BaseArgumentType {
+ user: BushUser | null;
+ users: Collection<string, BushUser> | null;
+ member: BushGuildMember | null;
+ members: Collection<string, BushGuildMember> | null;
+ relevant: BushUser | BushGuildMember | null;
+ relevants: Collection<string, BushUser> | Collection<string, BushGuildMember> | null;
+ channel: BushGuildBasedChannel | BushBaseGuildVoiceChannel | null;
+ channels: Collection<string, BushGuildBasedChannel | BushBaseGuildVoiceChannel> | null;
+ textChannel: BushTextChannel | null;
+ textChannels: Collection<string, BushTextChannel> | null;
+ voiceChannel: BushVoiceChannel | null;
+ voiceChannels: Collection<string, BushVoiceChannel> | null;
+ categoryChannel: BushCategoryChannel | null;
+ categoryChannels: Collection<string, BushCategoryChannel> | null;
+ newsChannel: BushNewsChannel | null;
+ newsChannels: Collection<string, BushNewsChannel> | null;
+ // eslint-disable-next-line deprecation/deprecation
+ storeChannel: BushStoreChannel | null;
+ // eslint-disable-next-line deprecation/deprecation
+ storeChannels: Collection<string, BushStoreChannel> | null;
+ stageChannel: BushStageChannel | null;
+ stageChannels: Collection<string, BushStageChannel> | null;
+ threadChannel: BushThreadChannel | null;
+ threadChannels: Collection<string, BushThreadChannel> | null;
+ role: BushRole | null;
+ roles: Collection<string, BushRole> | null;
+ emoji: BushEmoji | null;
+ emojis: Collection<string, BushEmoji> | null;
+ guild: BushGuild | null;
+ guilds: Collection<string, BushGuild> | null;
+ message: BushMessage | null;
+ guildMessage: BushMessage | null;
+ relevantMessage: BushMessage | null;
+ invite: Invite | null;
+ userMention: BushUser | null;
+ memberMention: BushGuildMember | null;
+ channelMention: BushThreadChannel | BushGuildChannel | null;
+ roleMention: BushRole | null;
+ emojiMention: BushGuildEmoji | null;
+ commandAlias: BushCommand | null;
+ command: BushCommand | null;
+ inhibitor: BushInhibitor | null;
+ listener: BushListener | null;
+ task: BushTask | null;
+ contextMenuCommand: ContextMenuCommand | null;
+}
-export interface BaseBushArgumentType extends BaseArgumentType {
+export interface BaseBushArgumentType extends OverriddenBaseArgumentType {
duration: number | null;
contentWithDuration: ParsedDuration;
permission: PermissionString | null;
@@ -38,6 +113,7 @@ export interface BaseBushArgumentType extends BaseArgumentType {
abbreviatedNumber: number | null;
globalUser: BushUser | null;
messageLink: BushMessage | null;
+ durationSeconds: number | null;
}
export type BushArgumentType = keyof BaseBushArgumentType | RegExp;
@@ -446,3 +522,6 @@ type SlashOptionKeys =
| keyof AkairoApplicationCommandAutocompleteOption
| keyof AkairoApplicationCommandNumericOptionData
| keyof AkairoApplicationCommandSubCommandData;
+
+export type ArgType<T extends keyof BaseBushArgumentType> = NonNullable<BaseBushArgumentType[T]>;
+export type OptionalArgType<T extends keyof BaseBushArgumentType> = BaseBushArgumentType[T];
diff --git a/src/lib/extensions/discord-akairo/BushSlashMessage.ts b/src/lib/extensions/discord-akairo/BushSlashMessage.ts
index 448963b..3cd167d 100644
--- a/src/lib/extensions/discord-akairo/BushSlashMessage.ts
+++ b/src/lib/extensions/discord-akairo/BushSlashMessage.ts
@@ -1,4 +1,11 @@
-import { type BushClient, type BushCommandUtil, type BushGuild, type BushGuildMember, type BushUser } from '#lib';
+import {
+ type BushClient,
+ type BushCommandUtil,
+ type BushGuild,
+ type BushGuildMember,
+ type BushTextBasedChannel,
+ type BushUser
+} from '#lib';
import { AkairoMessage } from 'discord-akairo';
import { type CommandInteraction } from 'discord.js';
@@ -13,5 +20,12 @@ export class BushSlashMessage extends AkairoMessage {
}
export interface BushSlashMessage extends AkairoMessage {
+ /**
+ * The channel that the interaction was sent in.
+ */
+ get channel(): BushTextBasedChannel | null;
+}
+
+export interface BushSlashMessage extends AkairoMessage {
get guild(): BushGuild | null;
}