diff options
author | IRONM00N <64110067+IRONM00N@users.noreply.github.com> | 2022-10-03 22:57:40 -0400 |
---|---|---|
committer | IRONM00N <64110067+IRONM00N@users.noreply.github.com> | 2022-10-03 22:57:40 -0400 |
commit | 612ed820a0600ec11ed642005377cd7f5a8a8b77 (patch) | |
tree | 6bca4e7268fd0063ff53cf64fa44df62a23dba50 /lib/extensions | |
parent | ed98ff7e2679f362f2657e77a6cf8dd3ce9b3d43 (diff) | |
download | tanzanite-612ed820a0600ec11ed642005377cd7f5a8a8b77.tar.gz tanzanite-612ed820a0600ec11ed642005377cd7f5a8a8b77.tar.bz2 tanzanite-612ed820a0600ec11ed642005377cd7f5a8a8b77.zip |
wip
Diffstat (limited to 'lib/extensions')
-rw-r--r-- | lib/extensions/discord-akairo/BotCommand.ts | 33 | ||||
-rw-r--r-- | lib/extensions/discord-akairo/BotCommandHandler.ts | 11 | ||||
-rw-r--r-- | lib/extensions/discord-akairo/BotInhibitor.ts | 6 | ||||
-rw-r--r-- | lib/extensions/discord-akairo/BotInhibitorHandler.ts | 7 | ||||
-rw-r--r-- | lib/extensions/discord-akairo/BotListener.ts | 5 | ||||
-rw-r--r-- | lib/extensions/discord-akairo/BotListenerHandler.ts | 2 | ||||
-rw-r--r-- | lib/extensions/discord-akairo/BotTask.ts | 2 | ||||
-rw-r--r-- | lib/extensions/discord-akairo/BotTaskHandler.ts | 2 | ||||
-rw-r--r-- | lib/extensions/discord-akairo/SlashMessage.ts | 2 | ||||
-rw-r--r-- | lib/extensions/discord-akairo/TanzaniteClient.ts | 48 | ||||
-rw-r--r-- | lib/extensions/discord.js/BotClientEvents.ts | 2 | ||||
-rw-r--r-- | lib/extensions/discord.js/ExtendedGuild.ts | 40 | ||||
-rw-r--r-- | lib/extensions/discord.js/ExtendedGuildMember.ts | 48 | ||||
-rw-r--r-- | lib/extensions/discord.js/ExtendedMessage.ts | 8 | ||||
-rw-r--r-- | lib/extensions/discord.js/ExtendedUser.ts | 2 |
15 files changed, 113 insertions, 105 deletions
diff --git a/lib/extensions/discord-akairo/BotCommand.ts b/lib/extensions/discord-akairo/BotCommand.ts index 11a8bad..a975667 100644 --- a/lib/extensions/discord-akairo/BotCommand.ts +++ b/lib/extensions/discord-akairo/BotCommand.ts @@ -11,14 +11,6 @@ import type { import { Command, CommandArguments, - type AkairoApplicationCommandAutocompleteOption, - type AkairoApplicationCommandChannelOptionData, - type AkairoApplicationCommandChoicesData, - type AkairoApplicationCommandNonOptionsData, - type AkairoApplicationCommandNumericOptionData, - type AkairoApplicationCommandOptionData, - type AkairoApplicationCommandSubCommandData, - type AkairoApplicationCommandSubGroupData, type ArgumentMatch, type ArgumentOptions, type ArgumentType, @@ -29,8 +21,9 @@ import { type ContextMenuCommand, type SlashOption, type SlashResolveType -} from 'discord-akairo'; +} from '@notenoughupdates/discord-akairo'; import { + ApplicationCommandChannelOption, PermissionsBitField, type ApplicationCommandOptionChoiceData, type ApplicationCommandOptionType, @@ -39,7 +32,7 @@ import { type Snowflake, type User } from 'discord.js'; -import _ from 'lodash'; +import { camelCase } from 'lodash-es'; import { SlashMessage } from './SlashMessage.js'; export interface OverriddenBaseArgumentType extends BaseArgumentType { @@ -89,7 +82,7 @@ interface BaseBotArgumentOptions extends Omit<ArgumentOptions, 'type' | 'prompt' /** * The type used for slash commands. Set to false to disable this argument for slash commands. */ - slashType: AkairoApplicationCommandOptionData['type'] | false; + slashType: SlashOption['type'] | false; /** * Allows you to get a discord resolved object @@ -111,7 +104,7 @@ interface BaseBotArgumentOptions extends Omit<ArgumentOptions, 'type' | 'prompt' /** * When the option type is channel, the allowed types of channels that can be selected */ - channelTypes?: AkairoApplicationCommandChannelOptionData['channelTypes']; + channelTypes?: ApplicationCommandChannelOption['channelTypes']; /** * The minimum value for an {@link ApplicationCommandOptionType.Integer Integer} or {@link ApplicationCommandOptionType.Number Number} option @@ -508,8 +501,11 @@ export abstract class BotCommand extends Command { (options_.slash || options_.slashOnly) && arg.slashType !== false ) { + // credit to https://dev.to/lucianbc/union-type-merging-in-typescript-9al + type AllKeys<T> = T extends any ? keyof T : never; + const newArg: { - [key in SlashOptionKeys]?: any; + [key in AllKeys<SlashOption>]?: any; } = { name: arg.id, // eslint-disable-next-line @typescript-eslint/prefer-nullish-coalescing @@ -560,7 +556,7 @@ export abstract class BotCommand extends Command { }); for (const arg of combined) { - const name = _.camelCase('id' in arg ? arg.id : arg.name), + const name = camelCase('id' in arg ? arg.id : arg.name), description = arg.description || '*No description provided.*', optional = arg.optional ?? false, autocomplete = arg.autocomplete ?? false, @@ -607,15 +603,6 @@ export abstract class BotCommand extends Command { public abstract override exec(message: CommandMessage | SlashMessage, args: CommandArguments): any; } -type SlashOptionKeys = - | keyof AkairoApplicationCommandSubGroupData - | keyof AkairoApplicationCommandNonOptionsData - | keyof AkairoApplicationCommandChannelOptionData - | keyof AkairoApplicationCommandChoicesData - | keyof AkairoApplicationCommandAutocompleteOption - | keyof AkairoApplicationCommandNumericOptionData - | keyof AkairoApplicationCommandSubCommandData; - interface PseudoArguments extends BaseBotArgumentType { boolean: boolean; flag: boolean; diff --git a/lib/extensions/discord-akairo/BotCommandHandler.ts b/lib/extensions/discord-akairo/BotCommandHandler.ts index e9b509f..c1415e3 100644 --- a/lib/extensions/discord-akairo/BotCommandHandler.ts +++ b/lib/extensions/discord-akairo/BotCommandHandler.ts @@ -1,5 +1,10 @@ -import type { BotCommand, CommandMessage, SlashMessage } from '#lib'; -import { CommandHandler, CommandHandlerEvents, type Category, type CommandHandlerOptions } from 'discord-akairo'; +import type { BotCommand, CommandMessage, SlashMessage, TanzaniteClient } from '#lib'; +import { + CommandHandler, + CommandHandlerEvents, + type Category, + type CommandHandlerOptions +} from '@notenoughupdates/discord-akairo'; import { GuildMember, PermissionResolvable, type Collection, type Message, type PermissionsString } from 'discord.js'; import { CommandHandlerEvent } from '../../utils/Constants.js'; @@ -41,6 +46,8 @@ export interface BotCommandHandlerEvents extends CommandHandlerEvents { } export class BotCommandHandler extends CommandHandler { + public declare readonly client: TanzaniteClient; + public declare modules: Collection<string, BotCommand>; public declare categories: Collection<string, Category<string, BotCommand>>; diff --git a/lib/extensions/discord-akairo/BotInhibitor.ts b/lib/extensions/discord-akairo/BotInhibitor.ts index 8892b8b..8a53e0d 100644 --- a/lib/extensions/discord-akairo/BotInhibitor.ts +++ b/lib/extensions/discord-akairo/BotInhibitor.ts @@ -1,8 +1,10 @@ -import type { BotCommand, CommandMessage, InhibitorReason, InhibitorType, SlashMessage } from '#lib'; -import { Inhibitor, InhibitorOptions } from 'discord-akairo'; +import type { BotCommand, CommandMessage, InhibitorReason, InhibitorType, SlashMessage, TanzaniteClient } from '#lib'; +import { Inhibitor, InhibitorOptions } from '@notenoughupdates/discord-akairo'; import { Message } from 'discord.js'; export abstract class BotInhibitor extends Inhibitor { + public declare readonly client: TanzaniteClient; + public constructor(id: InhibitorReason, options?: BotInhibitorOptions) { super(id, options); } diff --git a/lib/extensions/discord-akairo/BotInhibitorHandler.ts b/lib/extensions/discord-akairo/BotInhibitorHandler.ts index c6f318d..05caca6 100644 --- a/lib/extensions/discord-akairo/BotInhibitorHandler.ts +++ b/lib/extensions/discord-akairo/BotInhibitorHandler.ts @@ -1,3 +1,6 @@ -import { InhibitorHandler } from 'discord-akairo'; +import { InhibitorHandler } from '@notenoughupdates/discord-akairo'; +import { TanzaniteClient } from './TanzaniteClient.js'; -export class BotInhibitorHandler extends InhibitorHandler {} +export class BotInhibitorHandler extends InhibitorHandler { + public declare readonly client: TanzaniteClient; +} diff --git a/lib/extensions/discord-akairo/BotListener.ts b/lib/extensions/discord-akairo/BotListener.ts index 4f760e2..85acce3 100644 --- a/lib/extensions/discord-akairo/BotListener.ts +++ b/lib/extensions/discord-akairo/BotListener.ts @@ -1,6 +1,9 @@ -import { Listener, type ListenerOptions } from 'discord-akairo'; +import { Listener, type ListenerOptions } from '@notenoughupdates/discord-akairo'; +import { TanzaniteClient } from './TanzaniteClient.js'; export abstract class BotListener extends Listener { + public declare readonly client: TanzaniteClient<boolean>; + public constructor(id: string, options: BotListenerOptions) { super(id, options); } diff --git a/lib/extensions/discord-akairo/BotListenerHandler.ts b/lib/extensions/discord-akairo/BotListenerHandler.ts index bc14a53..6a1ad4c 100644 --- a/lib/extensions/discord-akairo/BotListenerHandler.ts +++ b/lib/extensions/discord-akairo/BotListenerHandler.ts @@ -1,4 +1,4 @@ -import { ListenerHandler } from 'discord-akairo'; +import { ListenerHandler } from '@notenoughupdates/discord-akairo'; import type readline from 'readline'; import { TanzaniteClient } from './TanzaniteClient.js'; diff --git a/lib/extensions/discord-akairo/BotTask.ts b/lib/extensions/discord-akairo/BotTask.ts index 09b30ed..fd0dc2e 100644 --- a/lib/extensions/discord-akairo/BotTask.ts +++ b/lib/extensions/discord-akairo/BotTask.ts @@ -1,3 +1,3 @@ -import { Task } from 'discord-akairo'; +import { Task } from '@notenoughupdates/discord-akairo'; export abstract class BotTask extends Task {} diff --git a/lib/extensions/discord-akairo/BotTaskHandler.ts b/lib/extensions/discord-akairo/BotTaskHandler.ts index b522f2c..1b4b5bd 100644 --- a/lib/extensions/discord-akairo/BotTaskHandler.ts +++ b/lib/extensions/discord-akairo/BotTaskHandler.ts @@ -1,3 +1,3 @@ -import { TaskHandler } from 'discord-akairo'; +import { TaskHandler } from '@notenoughupdates/discord-akairo'; export class BotTaskHandler extends TaskHandler {} diff --git a/lib/extensions/discord-akairo/SlashMessage.ts b/lib/extensions/discord-akairo/SlashMessage.ts index 0a6669b..b93f25f 100644 --- a/lib/extensions/discord-akairo/SlashMessage.ts +++ b/lib/extensions/discord-akairo/SlashMessage.ts @@ -1,3 +1,3 @@ -import { AkairoMessage } from 'discord-akairo'; +import { AkairoMessage } from '@notenoughupdates/discord-akairo'; export class SlashMessage extends AkairoMessage {} diff --git a/lib/extensions/discord-akairo/TanzaniteClient.ts b/lib/extensions/discord-akairo/TanzaniteClient.ts index ac09aea..a8346ba 100644 --- a/lib/extensions/discord-akairo/TanzaniteClient.ts +++ b/lib/extensions/discord-akairo/TanzaniteClient.ts @@ -11,8 +11,20 @@ import { snowflake } from '#args'; import type { Config } from '#config'; -import { patch, type PatchedElements } from '@notenoughupdates/events-intercept'; -import * as Sentry from '@sentry/node'; +import { + ActivePunishment, + Global, + Guild as GuildModel, + GuildCount, + Highlight, + Level, + MemberCount, + ModLog, + Reminder, + Shared, + Stat, + StickyRole +} from '#lib/models/index.js'; import { AkairoClient, ArgumentTypeCaster, @@ -20,7 +32,9 @@ import { version as akairoVersion, type ArgumentPromptData, type OtherwiseContentSupplier -} from 'discord-akairo'; +} from '@notenoughupdates/discord-akairo'; +import * as Sentry from '@sentry/node'; +import { patch, type PatchedElements } from '@tanzanite/events-intercept'; import { ActivityType, GatewayIntentBits, @@ -32,33 +46,19 @@ import { type Awaitable, type If, type Message, - type MessageOptions, + type MessageCreateOptions, type Snowflake, type UserResolvable } from 'discord.js'; -import type EventEmitter from 'events'; import { google } from 'googleapis'; -import path from 'path'; -import readline from 'readline'; +import { type EventEmitter } from 'node:events'; +import path from 'node:path'; +import readline from 'node:readline'; +import { fileURLToPath } from 'node:url'; import { Options as SequelizeOptions, Sequelize, Sequelize as SequelizeType } from 'sequelize'; -import { fileURLToPath } from 'url'; import { tinyColor } from '../../arguments/tinyColor.js'; import { BotCache } from '../../common/BotCache.js'; import { HighlightManager } from '../../common/HighlightManager.js'; -import { - ActivePunishment, - Global, - Guild as GuildModel, - GuildCount, - Highlight, - Level, - MemberCount, - ModLog, - Reminder, - Shared, - Stat, - StickyRole -} from '../../models/index.js'; import { AllowedMentions } from '../../utils/AllowedMentions.js'; import { BotClientUtils } from '../../utils/BotClientUtils.js'; import { emojis } from '../../utils/Constants.js'; @@ -279,7 +279,7 @@ export class TanzaniteClient<Ready extends boolean = boolean> extends AkairoClie const modify = async ( message: Message, - text: string | MessagePayload | MessageOptions | OtherwiseContentSupplier, + text: string | MessagePayload | MessageCreateOptions | OtherwiseContentSupplier, data: ArgumentPromptData, replaceError: boolean ) => { @@ -387,7 +387,7 @@ export class TanzaniteClient<Ready extends boolean = boolean> extends AkairoClie */ public async init() { if (parseInt(process.versions.node.split('.')[0]) < 18) { - void (await this.console.error('version', `Please use node <<v18.x.x>>, not <<${process.version}>>.`, false)); + void (await this.console.error('version', `Please use node <<v18.x.x>> or greater, not <<${process.version}>>.`, false)); process.exit(2); } diff --git a/lib/extensions/discord.js/BotClientEvents.ts b/lib/extensions/discord.js/BotClientEvents.ts index 941a6d8..88f67e9 100644 --- a/lib/extensions/discord.js/BotClientEvents.ts +++ b/lib/extensions/discord.js/BotClientEvents.ts @@ -1,4 +1,4 @@ -import type { AkairoClientEvents } from 'discord-akairo'; +import type { AkairoClientEvents } from '@notenoughupdates/discord-akairo'; import type { ButtonInteraction, Collection, diff --git a/lib/extensions/discord.js/ExtendedGuild.ts b/lib/extensions/discord.js/ExtendedGuild.ts index 6bf81ee..84db7d0 100644 --- a/lib/extensions/discord.js/ExtendedGuild.ts +++ b/lib/extensions/discord.js/ExtendedGuild.ts @@ -1,4 +1,5 @@ import { + Action, createModLogEntry, createModLogEntrySimple, createPunishmentEntry, @@ -17,15 +18,16 @@ import { Guild, JSONEncodable, Message, + MessageCreateOptions, MessageType, PermissionFlagsBits, SnowflakeUtil, ThreadChannel, + WebhookCreateMessageOptions, type APIMessage, type GuildMember, type GuildMemberResolvable, type GuildTextBasedChannel, - type MessageOptions, type MessagePayload, type NewsChannel, type Snowflake, @@ -33,10 +35,9 @@ import { type User, type UserResolvable, type VoiceChannel, - type Webhook, - type WebhookMessageOptions + type Webhook } from 'discord.js'; -import _ from 'lodash'; +import { camelCase } from 'lodash-es'; import { TanzaniteClient } from '../discord-akairo/TanzaniteClient.js'; import { banResponse, BanResponse, dmResponse, permissionsResponse, punishmentEntryRemove } from './ExtendedGuildMember.js'; @@ -91,7 +92,10 @@ interface Extension { * @param logType The corresponding channel that the message will be sent to * @param message The parameters for {@link TextChannel.send} */ - sendLogChannel(logType: GuildLogType, message: string | MessagePayload | MessageOptions): Promise<Message | null | undefined>; + sendLogChannel( + logType: GuildLogType, + message: string | MessagePayload | MessageCreateOptions + ): Promise<Message | null | undefined>; /** * Sends a formatted error message in a guild's error log channel * @param title The title of the error embed @@ -135,7 +139,7 @@ interface Extension { declare module 'discord.js' { export interface BaseGuild { - client: TanzaniteClient; + client: TanzaniteClient<true>; } export interface Guild extends AnonymousGuild, Extension {} @@ -202,7 +206,7 @@ export class ExtendedGuild extends Guild implements Extension { public override async sendLogChannel( logType: GuildLogType, - message: string | MessagePayload | MessageOptions + message: string | MessagePayload | MessageCreateOptions ): Promise<Message | null | undefined> { const logChannel = await this.getLogChannel(logType); if (!logChannel || !logChannel.isTextBased()) { @@ -220,7 +224,7 @@ export class ExtendedGuild extends Guild implements Extension { } public override async error(title: string, message: string): Promise<void> { - void this.client.console.info(_.camelCase(title), message.replace(/\*\*(.*?)\*\*/g, '<<$1>>')); + void this.client.console.info(camelCase(title), message.replace(/\*\*(.*?)\*\*/g, '<<$1>>')); void this.sendLogChannel('error', { embeds: [{ title: title, description: message, color: colors.error }] }); } @@ -240,7 +244,7 @@ export class ExtendedGuild extends Guild implements Extension { // add modlog entry const { log: modlog } = await createModLogEntry({ client: this.client, - type: options.duration ? ModLogType.TEMP_BAN : ModLogType.PERM_BAN, + type: options.duration ? ModLogType.TempBan : ModLogType.PermBan, user: user, moderator: moderator.id, reason: options.reason, @@ -257,7 +261,7 @@ export class ExtendedGuild extends Guild implements Extension { modlog: modlog.id, guild: this, user: user, - punishment: 'banned', + punishment: Action.Ban, duration: options.duration ?? 0, reason: options.reason ?? undefined, sendFooter: true @@ -309,7 +313,7 @@ export class ExtendedGuild extends Guild implements Extension { // add modlog entry const { log: modlog } = await createModLogEntrySimple({ client: this.client, - type: ModLogType.PERM_BAN, + type: ModLogType.PermBan, user: options.user, moderator: options.moderator, reason: options.reason, @@ -326,7 +330,7 @@ export class ExtendedGuild extends Guild implements Extension { modlog: modlog.id, guild: this, user: options.user, - punishment: 'banned', + punishment: Action.Ban, duration: 0, reason: options.reason ?? undefined, sendFooter: true @@ -390,7 +394,7 @@ export class ExtendedGuild extends Guild implements Extension { // add modlog entry const { log: modlog } = await createModLogEntry({ client: this.client, - type: ModLogType.UNBAN, + type: ModLogType.Unban, user: user.id, moderator: moderator.id, reason: options.reason, @@ -414,7 +418,7 @@ export class ExtendedGuild extends Guild implements Extension { client: this.client, guild: this, user: user, - punishment: 'unbanned', + punishment: Action.Unban, reason: options.reason ?? undefined, sendFooter: false }); @@ -546,7 +550,7 @@ export class ExtendedGuild extends Guild implements Extension { if (!webhook) return null; - const sendOptions: Omit<WebhookMessageOptions, 'flags'> = {}; + const sendOptions: Omit<WebhookCreateMessageOptions, 'flags'> = {}; const displayName = quote.member?.displayName ?? quote.author.username; @@ -559,7 +563,7 @@ export class ExtendedGuild extends Guild implements Extension { sendOptions.content = quote.content || undefined; sendOptions.threadId = channel instanceof ThreadChannel ? channel.id : undefined; sendOptions.embeds = quote.embeds.length ? quote.embeds : undefined; - //@ts-expect-error: jank + // @ts-expect-error: jank sendOptions.attachments = quote.attachments.size ? [...quote.attachments.values()].map((a) => AttachmentBuilder.from(a as JSONEncodable<AttachmentPayload>)) : undefined; @@ -720,7 +724,9 @@ export class ExtendedGuild extends Guild implements Extension { } sendOptions.allowedMentions = AllowedMentions.none(); - sendOptions.username ??= quote.member?.displayName ?? quote.author.username; + sendOptions.username ??= (quote.member?.displayName ?? quote.author.username) + .replaceAll(/discord/gi, '[REDACTED]') + .replaceAll(/clyde/gi, '[REDACTED]'); sendOptions.avatarURL = quote.member?.displayAvatarURL({ size: 2048 }) ?? quote.author.displayAvatarURL({ size: 2048 }); return await webhook.send(sendOptions); /* .catch((e: any) => e); */ diff --git a/lib/extensions/discord.js/ExtendedGuildMember.ts b/lib/extensions/discord.js/ExtendedGuildMember.ts index 9ef45f1..b11e9e3 100644 --- a/lib/extensions/discord.js/ExtendedGuildMember.ts +++ b/lib/extensions/discord.js/ExtendedGuildMember.ts @@ -8,11 +8,11 @@ import { type Role } from 'discord.js'; import { + Action, checkMutePermissions, createModLogEntry, createPunishmentEntry, punishDM, - PunishmentTypeDM, removePunishmentEntry } from '../../common/Moderation.js'; import { ModLogType } from '../../models/index.js'; @@ -32,7 +32,7 @@ interface Extension { * @returns Whether or not the dm was sent successfully. */ customPunishDM( - punishment: PunishmentTypeDM, + punishment: Action, reason?: string | null, duration?: number, modlog?: string, @@ -119,13 +119,13 @@ interface Extension { declare module 'discord.js' { export interface GuildMember extends Extension { - readonly client: TanzaniteClient; + readonly client: TanzaniteClient<true>; } } export class ExtendedGuildMember extends GuildMember implements Extension { public override async customPunishDM( - punishment: PunishmentTypeDM, + punishment: Action, reason?: string | null, duration?: number, modlog?: string, @@ -154,7 +154,7 @@ export class ExtendedGuildMember extends GuildMember implements Extension { const result = await createModLogEntry( { client: this.client, - type: ModLogType.WARN, + type: ModLogType.Warn, user: this, moderator: moderator.id, reason: options.reason, @@ -169,7 +169,7 @@ export class ExtendedGuildMember extends GuildMember implements Extension { if (!options.silent) { // dm user - const dmSuccess = await this.customPunishDM('warned', options.reason); + const dmSuccess = await this.customPunishDM(Action.Warn, options.reason); dmSuccessEvent = dmSuccess; if (!dmSuccess) return { result: warnResponse.DM_ERROR, caseNum: result.caseNum }; } @@ -195,7 +195,7 @@ export class ExtendedGuildMember extends GuildMember implements Extension { if (options.addToModlog || options.duration) { const { log: modlog } = await createModLogEntry({ client: this.client, - type: options.duration ? ModLogType.TEMP_PUNISHMENT_ROLE : ModLogType.PERM_PUNISHMENT_ROLE, + type: options.duration ? ModLogType.TempPunishmentRole : ModLogType.PermPunishmentRole, guild: this.guild, moderator: moderator.id, user: this, @@ -262,7 +262,7 @@ export class ExtendedGuildMember extends GuildMember implements Extension { if (options.addToModlog) { const { log: modlog } = await createModLogEntry({ client: this.client, - type: ModLogType.REMOVE_PUNISHMENT_ROLE, + type: ModLogType.RemovePunishmentRole, guild: this.guild, moderator: moderator.id, user: this, @@ -362,7 +362,7 @@ export class ExtendedGuildMember extends GuildMember implements Extension { // add modlog entry const { log: modlog } = await createModLogEntry({ client: this.client, - type: options.duration ? ModLogType.TEMP_MUTE : ModLogType.PERM_MUTE, + type: options.duration ? ModLogType.TempMute : ModLogType.PermMute, user: this, moderator: moderator.id, reason: options.reason, @@ -389,7 +389,7 @@ export class ExtendedGuildMember extends GuildMember implements Extension { if (!options.silent) { // dm user - const dmSuccess = await this.customPunishDM('muted', options.reason, options.duration ?? 0, modlog.id); + const dmSuccess = await this.customPunishDM(Action.Mute, options.reason, options.duration ?? 0, modlog.id); dmSuccessEvent = dmSuccess; if (!dmSuccess) return muteResponse.DM_ERROR; } @@ -441,7 +441,7 @@ export class ExtendedGuildMember extends GuildMember implements Extension { // add modlog entry const { log: modlog } = await createModLogEntry({ client: this.client, - type: ModLogType.UNMUTE, + type: ModLogType.Unmute, user: this, moderator: moderator.id, reason: options.reason, @@ -465,7 +465,7 @@ export class ExtendedGuildMember extends GuildMember implements Extension { if (!options.silent) { // dm user - const dmSuccess = await this.customPunishDM('unmuted', options.reason, undefined, '', false); + const dmSuccess = await this.customPunishDM(Action.Unmute, options.reason, undefined, '', false); dmSuccessEvent = dmSuccess; if (!dmSuccess) return unmuteResponse.DM_ERROR; } @@ -505,7 +505,7 @@ export class ExtendedGuildMember extends GuildMember implements Extension { // add modlog entry const { log: modlog } = await createModLogEntry({ client: this.client, - type: ModLogType.KICK, + type: ModLogType.Kick, user: this, moderator: moderator.id, reason: options.reason, @@ -517,7 +517,7 @@ export class ExtendedGuildMember extends GuildMember implements Extension { caseID = modlog.id; // dm user - const dmSuccess = options.silent ? null : await this.customPunishDM('kicked', options.reason, undefined, modlog.id); + const dmSuccess = options.silent ? null : await this.customPunishDM(Action.Kick, options.reason, undefined, modlog.id); dmSuccessEvent = dmSuccess ?? undefined; // kick @@ -564,7 +564,7 @@ export class ExtendedGuildMember extends GuildMember implements Extension { // add modlog entry const { log: modlog } = await createModLogEntry({ client: this.client, - type: options.duration ? ModLogType.TEMP_BAN : ModLogType.PERM_BAN, + type: options.duration ? ModLogType.TempBan : ModLogType.PermBan, user: this, moderator: moderator.id, reason: options.reason, @@ -579,7 +579,7 @@ export class ExtendedGuildMember extends GuildMember implements Extension { // dm user const dmSuccess = options.silent ? null - : await this.customPunishDM('banned', options.reason, options.duration ?? 0, modlog.id); + : await this.customPunishDM(Action.Ban, options.reason, options.duration ?? 0, modlog.id); dmSuccessEvent = dmSuccess ?? undefined; // ban @@ -646,7 +646,7 @@ export class ExtendedGuildMember extends GuildMember implements Extension { // add modlog entry const { log: modlog } = await createModLogEntry({ client: this.client, - type: options.duration ? ModLogType.TEMP_CHANNEL_BLOCK : ModLogType.PERM_CHANNEL_BLOCK, + type: options.duration ? ModLogType.TempChannelBlock : ModLogType.PermChannelBlock, user: this, moderator: moderator.id, reason: options.reason, @@ -674,7 +674,7 @@ export class ExtendedGuildMember extends GuildMember implements Extension { ? null : await punishDM({ client: this.client, - punishment: 'blocked', + punishment: Action.Block, reason: options.reason ?? undefined, duration: options.duration ?? 0, modlog: modlog.id, @@ -736,7 +736,7 @@ export class ExtendedGuildMember extends GuildMember implements Extension { // add modlog entry const { log: modlog } = await createModLogEntry({ client: this.client, - type: ModLogType.CHANNEL_UNBLOCK, + type: ModLogType.ChannelUnblock, user: this, moderator: moderator.id, reason: options.reason, @@ -762,7 +762,7 @@ export class ExtendedGuildMember extends GuildMember implements Extension { ? null : await punishDM({ client: this.client, - punishment: 'unblocked', + punishment: Action.Unblock, reason: options.reason ?? undefined, guild: this.guild, user: this, @@ -819,7 +819,7 @@ export class ExtendedGuildMember extends GuildMember implements Extension { // add modlog entry const { log: modlog } = await createModLogEntry({ client: this.client, - type: ModLogType.TIMEOUT, + type: ModLogType.Timeout, user: this, moderator: moderator.id, reason: options.reason, @@ -834,7 +834,7 @@ export class ExtendedGuildMember extends GuildMember implements Extension { if (!options.silent) { // dm user - const dmSuccess = await this.customPunishDM('timedout', options.reason, options.duration, modlog.id); + const dmSuccess = await this.customPunishDM(Action.Timeout, options.reason, options.duration, modlog.id); dmSuccessEvent = dmSuccess; if (!dmSuccess) return timeoutResponse.DM_ERROR; } @@ -877,7 +877,7 @@ export class ExtendedGuildMember extends GuildMember implements Extension { // add modlog entry const { log: modlog } = await createModLogEntry({ client: this.client, - type: ModLogType.REMOVE_TIMEOUT, + type: ModLogType.RemoveTimeout, user: this, moderator: moderator.id, reason: options.reason, @@ -891,7 +891,7 @@ export class ExtendedGuildMember extends GuildMember implements Extension { if (!options.silent) { // dm user - const dmSuccess = await this.customPunishDM('untimedout', options.reason, undefined, '', false); + const dmSuccess = await this.customPunishDM(Action.Untimeout, options.reason, undefined, '', false); dmSuccessEvent = dmSuccess; if (!dmSuccess) return removeTimeoutResponse.DM_ERROR; } diff --git a/lib/extensions/discord.js/ExtendedMessage.ts b/lib/extensions/discord.js/ExtendedMessage.ts index 1bb0904..07cba3d 100644 --- a/lib/extensions/discord.js/ExtendedMessage.ts +++ b/lib/extensions/discord.js/ExtendedMessage.ts @@ -1,11 +1,11 @@ -import { CommandUtil } from 'discord-akairo'; +import { CommandUtil } from '@notenoughupdates/discord-akairo'; import { Message, type Client } from 'discord.js'; import type { RawMessageData } from 'discord.js/typings/rawDataTypes.js'; -export class ExtendedMessage<Cached extends boolean = boolean> extends Message<Cached> { - public declare util: CommandUtil<Message>; +export class ExtendedMessage<InGuild extends boolean = boolean> extends Message<InGuild> { + public declare util: CommandUtil<Message<InGuild>>; - public constructor(client: Client, data: RawMessageData) { + public constructor(client: Client<true>, data: RawMessageData) { super(client, data); this.util = new CommandUtil(client.commandHandler, this); } diff --git a/lib/extensions/discord.js/ExtendedUser.ts b/lib/extensions/discord.js/ExtendedUser.ts index 7846a70..8f9d27b 100644 --- a/lib/extensions/discord.js/ExtendedUser.ts +++ b/lib/extensions/discord.js/ExtendedUser.ts @@ -14,7 +14,7 @@ interface Extension { declare module 'discord.js' { export interface User extends Extension { - readonly client: TanzaniteClient; + readonly client: TanzaniteClient<true>; } } |