diff options
Diffstat (limited to 'src/arguments')
-rw-r--r-- | src/arguments/contentWithDuration.ts | 7 | ||||
-rw-r--r-- | src/arguments/discordEmoji.ts | 7 | ||||
-rw-r--r-- | src/arguments/permission.ts | 6 | ||||
-rw-r--r-- | src/arguments/roleWithDuration.ts | 11 |
4 files changed, 18 insertions, 13 deletions
diff --git a/src/arguments/contentWithDuration.ts b/src/arguments/contentWithDuration.ts index a9a7c23..41cb9bb 100644 --- a/src/arguments/contentWithDuration.ts +++ b/src/arguments/contentWithDuration.ts @@ -1,8 +1,5 @@ -import { type BushArgumentTypeCaster } from '#lib'; +import { ParsedDuration, type BushArgumentTypeCaster } from '#lib'; -export const contentWithDuration: BushArgumentTypeCaster = async ( - _, - phrase -): Promise<{ duration: number | null; contentWithoutTime: string | null }> => { +export const contentWithDuration: BushArgumentTypeCaster = async (_, phrase): Promise<ParsedDuration> => { return client.util.parseDuration(phrase); }; diff --git a/src/arguments/discordEmoji.ts b/src/arguments/discordEmoji.ts index 8648f7f..a3c531c 100644 --- a/src/arguments/discordEmoji.ts +++ b/src/arguments/discordEmoji.ts @@ -1,9 +1,14 @@ import { type BushArgumentTypeCaster } from '#lib'; import { type Snowflake } from 'discord-api-types'; -export const discordEmoji: BushArgumentTypeCaster = (_, phrase): { name: string; id: Snowflake } | null => { +export const discordEmoji: BushArgumentTypeCaster = (_, phrase): DiscordEmojiInfo | null => { if (!phrase) return null; const validEmoji: RegExpExecArray | null = client.consts.regex.discordEmoji.exec(phrase); if (!validEmoji || !validEmoji.groups) return null; return { name: validEmoji.groups.name, id: validEmoji.groups.id }; }; + +export interface DiscordEmojiInfo { + name: string; + id: Snowflake; +} diff --git a/src/arguments/permission.ts b/src/arguments/permission.ts index 8c09072..b5ff4bf 100644 --- a/src/arguments/permission.ts +++ b/src/arguments/permission.ts @@ -1,12 +1,12 @@ import { type BushArgumentTypeCaster } from '#lib'; -import { Permissions } from 'discord.js'; +import { Permissions, PermissionString } from 'discord.js'; -export const permission: BushArgumentTypeCaster = (_, phrase) => { +export const permission: BushArgumentTypeCaster = (_, phrase): PermissionString | null => { if (!phrase) return null; phrase = phrase.toUpperCase().replace(/ /g, '_'); if (!(phrase in Permissions.FLAGS)) { return null; } else { - return phrase; + return phrase as PermissionString; } }; diff --git a/src/arguments/roleWithDuration.ts b/src/arguments/roleWithDuration.ts index 9bf4bb2..999ac1c 100644 --- a/src/arguments/roleWithDuration.ts +++ b/src/arguments/roleWithDuration.ts @@ -1,9 +1,7 @@ import { type BushArgumentTypeCaster } from '#lib'; +import { Role } from 'discord.js'; -export const roleWithDuration: BushArgumentTypeCaster = async ( - message, - phrase -): Promise<{ duration: number | null; role: string | null } | null> => { +export const roleWithDuration: BushArgumentTypeCaster = async (message, phrase): Promise<RoleWithDuration | null> => { // eslint-disable-next-line prefer-const let { duration, contentWithoutTime } = client.util.parseDuration(phrase); if (contentWithoutTime === null || contentWithoutTime === undefined) return null; @@ -12,3 +10,8 @@ export const roleWithDuration: BushArgumentTypeCaster = async ( if (!role) return null; return { duration, role }; }; + +export interface RoleWithDuration { + duration: number | null; + role: Role | null; +} |