diff options
author | IRONM00N <64110067+IRONM00N@users.noreply.github.com> | 2021-07-31 13:46:27 -0400 |
---|---|---|
committer | IRONM00N <64110067+IRONM00N@users.noreply.github.com> | 2021-07-31 13:46:27 -0400 |
commit | edcc0dd0a9228192ff6c4f6d6797dd6238e98f92 (patch) | |
tree | 70c3f5436342d7f6b0e81222467d2773a3bb0b33 /src/lib/extensions/discord-akairo/BushClient.ts | |
parent | b63a6b0cb61f0abf8a946a7f0f04a2a19a31e690 (diff) | |
download | tanzanite-edcc0dd0a9228192ff6c4f6d6797dd6238e98f92.tar.gz tanzanite-edcc0dd0a9228192ff6c4f6d6797dd6238e98f92.tar.bz2 tanzanite-edcc0dd0a9228192ff6c4f6d6797dd6238e98f92.zip |
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.
Diffstat (limited to 'src/lib/extensions/discord-akairo/BushClient.ts')
-rw-r--r-- | src/lib/extensions/discord-akairo/BushClient.ts | 24 |
1 files changed, 20 insertions, 4 deletions
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<Snowflake, BushThreadChannel>; hasMore?: boolean; @@ -86,7 +94,9 @@ const rl = readline.createInterface({ terminal: false }); -export class BushClient extends AkairoClient { +type If<T extends boolean, A, B = null> = T extends true ? A : T extends false ? B : A | B; + +export class BushClient<Ready extends boolean = boolean> 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<Ready, BushClientUser>; + 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<string> { + public override destroy(relogin = false): void | Promise<string> { 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); } |