From edcc0dd0a9228192ff6c4f6d6797dd6238e98f92 Mon Sep 17 00:00:00 2001 From: IRONM00N <64110067+IRONM00N@users.noreply.github.com> Date: Sat, 31 Jul 2021 13:46:27 -0400 Subject: upgraded to typescript 4.3.5 The reason I had to use getters and setters for the db models is because in the newer version of typescript the properties would be defined at runtime and override the getter and setters that sequalize uses later, causing all the values to be undefined and not being able to save any information. --- src/lib/extensions/discord-akairo/BushClient.ts | 24 ++++++++++++++++++---- .../extensions/discord-akairo/BushClientUtil.ts | 2 +- src/lib/extensions/discord-akairo/BushCommand.ts | 4 ++-- .../discord-akairo/BushCommandHandler.ts | 2 +- src/lib/extensions/discord-akairo/BushInhibitor.ts | 4 ++-- 5 files changed, 26 insertions(+), 10 deletions(-) (limited to 'src/lib/extensions/discord-akairo') diff --git a/src/lib/extensions/discord-akairo/BushClient.ts b/src/lib/extensions/discord-akairo/BushClient.ts index 7b270f6..4c2b940 100644 --- a/src/lib/extensions/discord-akairo/BushClient.ts +++ b/src/lib/extensions/discord-akairo/BushClient.ts @@ -34,12 +34,17 @@ import { BushConstants } from '../../utils/BushConstants'; import { BushLogger } from '../../utils/BushLogger'; import { Config } from '../../utils/Config'; import { BushApplicationCommand } from '../discord.js/BushApplicationCommand'; +import { BushBaseGuildEmojiManager } from '../discord.js/BushBaseGuildEmojiManager'; import { BushButtonInteraction } from '../discord.js/BushButtonInteraction'; import { BushCategoryChannel } from '../discord.js/BushCategoryChannel'; +import { BushChannel } from '../discord.js/BushChannel'; +import { BushChannelManager } from '../discord.js/BushChannelManager'; +import { BushClientUser } from '../discord.js/BushClientUser'; import { BushCommandInteraction } from '../discord.js/BushCommandInteraction'; import { BushDMChannel } from '../discord.js/BushDMChannel'; import { BushGuild } from '../discord.js/BushGuild'; import { BushGuildEmoji } from '../discord.js/BushGuildEmoji'; +import { BushGuildManager } from '../discord.js/BushGuildManager'; import { BushGuildMember } from '../discord.js/BushGuildMember'; import { BushMessage } from '../discord.js/BushMessage'; import { BushMessageReaction } from '../discord.js/BushMessageReaction'; @@ -53,6 +58,7 @@ import { BushTextChannel } from '../discord.js/BushTextChannel'; import { BushThreadChannel } from '../discord.js/BushThreadChannel'; import { BushThreadMember } from '../discord.js/BushThreadMember'; import { BushUser } from '../discord.js/BushUser'; +import { BushUserManager } from '../discord.js/BushUserManager'; import { BushVoiceChannel } from '../discord.js/BushVoiceChannel'; import { BushVoiceState } from '../discord.js/BushVoiceState'; import { BushClientUtil } from './BushClientUtil'; @@ -75,6 +81,8 @@ export type BushEmojiResolvable = Snowflake | BushGuildEmoji | BushReactionEmoji export type BushEmojiIdentifierResolvable = string | BushEmojiResolvable; export type BushThreadChannelResolvable = BushThreadChannel | Snowflake; export type BushApplicationCommandResolvable = BushApplicationCommand | Snowflake; +export type BushGuildTextChannelResolvable = BushTextChannel | BushNewsChannel | Snowflake; +export type BushChannelResolvable = BushChannel | Snowflake; export interface BushFetchedThreads { threads: Collection; hasMore?: boolean; @@ -86,7 +94,9 @@ const rl = readline.createInterface({ terminal: false }); -export class BushClient extends AkairoClient { +type If = T extends true ? A : T extends false ? B : A | B; + +export class BushClient extends AkairoClient { public static preStart(): void { Structures.extend('GuildEmoji', () => BushGuildEmoji); Structures.extend('DMChannel', () => BushDMChannel); @@ -110,6 +120,12 @@ export class BushClient extends AkairoClient { Structures.extend('SelectMenuInteraction', () => BushSelectMenuInteraction); } + public declare channels: BushChannelManager; + public declare readonly emojis: BushBaseGuildEmojiManager; + public declare guilds: BushGuildManager; + public declare user: If; + public declare users: BushUserManager; + public config: Config; public listenerHandler: BushListenerHandler; public inhibitorHandler: BushInhibitorHandler; @@ -289,17 +305,17 @@ export class BushClient extends AkairoClient { } /** Logs out, terminates the connection to Discord, and destroys the client. */ - public destroy(relogin = false): void | Promise { + public override destroy(relogin = false): void | Promise { super.destroy(); if (relogin) { return this.login(this.token); } } - public isOwner(user: BushUserResolvable): boolean { + public override isOwner(user: BushUserResolvable): boolean { return this.config.owners.includes(this.users.resolveId(user)); } - public isSuperUser(user: BushUserResolvable): boolean { + public override isSuperUser(user: BushUserResolvable): boolean { const userID = this.users.resolveId(user); return !!BushCache?.global?.superUsers?.includes(userID) || this.config.owners.includes(userID); } diff --git a/src/lib/extensions/discord-akairo/BushClientUtil.ts b/src/lib/extensions/discord-akairo/BushClientUtil.ts index aecc635..ac39611 100644 --- a/src/lib/extensions/discord-akairo/BushClientUtil.ts +++ b/src/lib/extensions/discord-akairo/BushClientUtil.ts @@ -521,7 +521,7 @@ export class BushClientUtil extends ClientUtil { /** Gets the channel configs as a TextChannel */ public async getConfigChannel(channel: 'log' | 'error' | 'dm'): Promise { - return (await client.channels.fetch(client.config.channels[channel])) as TextChannel; + return (await client.channels.fetch(client.config.channels[channel])) as unknown as TextChannel; } /** diff --git a/src/lib/extensions/discord-akairo/BushCommand.ts b/src/lib/extensions/discord-akairo/BushCommand.ts index 6616d1d..6dd5449 100644 --- a/src/lib/extensions/discord-akairo/BushCommand.ts +++ b/src/lib/extensions/discord-akairo/BushCommand.ts @@ -182,8 +182,8 @@ export class BushCommand extends Command { } } - public exec(message: BushMessage, args: any): any; - public exec(message: BushMessage | BushSlashMessage, args: any): any { + public override exec(message: BushMessage, args: any): any; + public override exec(message: BushMessage | BushSlashMessage, args: any): any { super.exec(message, args); } } diff --git a/src/lib/extensions/discord-akairo/BushCommandHandler.ts b/src/lib/extensions/discord-akairo/BushCommandHandler.ts index f16554c..7eca05b 100644 --- a/src/lib/extensions/discord-akairo/BushCommandHandler.ts +++ b/src/lib/extensions/discord-akairo/BushCommandHandler.ts @@ -35,7 +35,7 @@ export class BushCommandHandler extends CommandHandler { super(client, options); } - public async runPostTypeInhibitors(message: BushMessage, command: BushCommand, slash = false): Promise { + public override async runPostTypeInhibitors(message: BushMessage, command: BushCommand, slash = false): Promise { if (command.ownerOnly) { const isOwner = client.isOwner(message.author); if (!isOwner) { diff --git a/src/lib/extensions/discord-akairo/BushInhibitor.ts b/src/lib/extensions/discord-akairo/BushInhibitor.ts index f924458..8a199fc 100644 --- a/src/lib/extensions/discord-akairo/BushInhibitor.ts +++ b/src/lib/extensions/discord-akairo/BushInhibitor.ts @@ -8,8 +8,8 @@ import { BushSlashMessage } from './BushSlashMessage'; export class BushInhibitor extends Inhibitor { public declare client: BushClient; - public exec(message: BushMessage, command: BushCommand): any; - public exec(message: BushMessage | BushSlashMessage, command: BushCommand): any { + public override exec(message: BushMessage, command: BushCommand): any; + public override exec(message: BushMessage | BushSlashMessage, command: BushCommand): any { return super.exec(message, command); } } -- cgit