diff options
Diffstat (limited to 'src/lib/common/util')
-rw-r--r-- | src/lib/common/util/Arg.ts | 16 | ||||
-rw-r--r-- | src/lib/common/util/Moderation.ts | 51 |
2 files changed, 37 insertions, 30 deletions
diff --git a/src/lib/common/util/Arg.ts b/src/lib/common/util/Arg.ts index 01d3b0b..51d8065 100644 --- a/src/lib/common/util/Arg.ts +++ b/src/lib/common/util/Arg.ts @@ -1,4 +1,10 @@ -import { type BaseBushArgumentType, type BushArgumentType, type BushArgumentTypeCaster, type BushSlashMessage } from '#lib'; +import { + type BaseBushArgumentType, + type BushArgumentType, + type BushArgumentTypeCaster, + type CommandMessage, + type SlashMessage +} from '#lib'; import { Argument, type Flag, type ParsedValuePredicate } from 'discord-akairo'; import { type Message } from 'discord.js'; @@ -12,10 +18,10 @@ export class Arg { * @param message - Message that called the command. * @param phrase - Phrase to process. */ - public static async cast<T extends ATC>(type: T, message: Message | BushSlashMessage, phrase: string): Promise<ATCR<T>>; - public static async cast<T extends KBAT>(type: T, message: Message | BushSlashMessage, phrase: string): Promise<BAT[T]>; - public static async cast(type: AT | ATC, message: Message | BushSlashMessage, phrase: string): Promise<any>; - public static async cast(type: ATC | AT, message: Message | BushSlashMessage, phrase: string): Promise<any> { + public static async cast<T extends ATC>(type: T, message: CommandMessage | SlashMessage, phrase: string): Promise<ATCR<T>>; + public static async cast<T extends KBAT>(type: T, message: CommandMessage | SlashMessage, phrase: string): Promise<BAT[T]>; + public static async cast(type: AT | ATC, message: CommandMessage | SlashMessage, phrase: string): Promise<any>; + public static async cast(type: ATC | AT, message: CommandMessage | SlashMessage, phrase: string): Promise<any> { return Argument.cast(type as any, client.commandHandler.resolver, message as Message, phrase); } diff --git a/src/lib/common/util/Moderation.ts b/src/lib/common/util/Moderation.ts index 9f93375..6cdc141 100644 --- a/src/lib/common/util/Moderation.ts +++ b/src/lib/common/util/Moderation.ts @@ -1,17 +1,18 @@ -import { - ActivePunishment, - ActivePunishmentType, - Guild, - ModLog, - type BushGuild, - type BushGuildMember, - type BushGuildMemberResolvable, - type BushGuildResolvable, - type BushUserResolvable, - type ModLogType -} from '#lib'; +import { ActivePunishment, ActivePunishmentType, Guild as GuildDB, ModLog, type ModLogType } from '#lib'; import assert from 'assert'; -import { ActionRowBuilder, ButtonBuilder, ButtonStyle, EmbedBuilder, PermissionFlagsBits, type Snowflake } from 'discord.js'; +import { + ActionRowBuilder, + ButtonBuilder, + ButtonStyle, + EmbedBuilder, + PermissionFlagsBits, + type Guild, + type GuildMember, + type GuildMemberResolvable, + type GuildResolvable, + type Snowflake, + type UserResolvable +} from 'discord.js'; enum punishMap { 'warned' = 'warn', @@ -52,8 +53,8 @@ export class Moderation { * @returns `true` if the moderator can perform the action otherwise a reason why they can't. */ public static async permissionCheck( - moderator: BushGuildMember, - victim: BushGuildMember, + moderator: GuildMember, + victim: GuildMember, type: | 'mute' | 'unmute' @@ -146,7 +147,7 @@ export class Moderation { getCaseNumber = false ): Promise<{ log: ModLog | null; caseNum: number | null }> { // If guild does not exist create it so the modlog can reference a guild. - await Guild.findOrCreate({ + await GuildDB.findOrCreate({ where: { id: options.guild }, defaults: { id: options.guild } }); @@ -349,17 +350,17 @@ export interface CreateModLogEntryOptions extends BaseCreateModLogEntryOptions { /** * The user that a modlog entry is created for. */ - user: BushGuildMemberResolvable; + user: GuildMemberResolvable; /** * The moderator that created the modlog entry. */ - moderator: BushGuildMemberResolvable; + moderator: GuildMemberResolvable; /** * The guild that the punishment is created for. */ - guild: BushGuildResolvable; + guild: GuildResolvable; } /** @@ -394,7 +395,7 @@ export interface CreatePunishmentEntryOptions { /** * The user that the punishment is created for. */ - user: BushGuildMemberResolvable; + user: GuildMemberResolvable; /** * The length of time the punishment lasts for. @@ -404,7 +405,7 @@ export interface CreatePunishmentEntryOptions { /** * The guild that the punishment is created for. */ - guild: BushGuildResolvable; + guild: GuildResolvable; /** * The id of the modlog that is linked to the punishment entry. @@ -429,12 +430,12 @@ export interface RemovePunishmentEntryOptions { /** * The user that the punishment is destroyed for. */ - user: BushGuildMemberResolvable; + user: GuildMemberResolvable; /** * The guild that the punishment was in. */ - guild: BushGuildResolvable; + guild: GuildResolvable; /** * Extra information for the punishment. The role for role punishments and the channel for blocks. @@ -454,12 +455,12 @@ export interface PunishDMOptions { /** * The guild that the punishment is taking place in. */ - guild: BushGuild; + guild: Guild; /** * The user that is being punished. */ - user: BushUserResolvable; + user: UserResolvable; /** * The punishment that the user has received. |