From 66b958cd1d38a8ba0d64ecd188bc8d90e850cfbb Mon Sep 17 00:00:00 2001 From: IRONM00N <64110067+IRONM00N@users.noreply.github.com> Date: Sun, 11 Jul 2021 20:52:56 -0400 Subject: fix: circular imports --- .../discord-akairo/BushArgumentTypeCaster.ts | 2 +- src/lib/extensions/discord-akairo/BushClient.ts | 108 +++++++++++++-------- .../extensions/discord-akairo/BushClientUtil.ts | 31 +++--- src/lib/extensions/discord-akairo/BushCommand.ts | 5 +- .../discord-akairo/BushCommandHandler.ts | 5 +- .../extensions/discord-akairo/BushCommandUtil.ts | 4 +- src/lib/extensions/discord-akairo/BushInhibitor.ts | 5 +- .../discord-akairo/BushInhibitorHandler.ts | 2 +- src/lib/extensions/discord-akairo/BushListener.ts | 2 +- .../discord-akairo/BushListenerHandler.ts | 2 +- .../extensions/discord-akairo/BushSlashMessage.ts | 6 +- src/lib/extensions/discord-akairo/BushTask.ts | 4 +- .../extensions/discord-akairo/BushTaskHandler.ts | 2 +- src/lib/extensions/discord-akairo/index.ts | 13 --- 14 files changed, 106 insertions(+), 85 deletions(-) delete mode 100644 src/lib/extensions/discord-akairo/index.ts (limited to 'src/lib/extensions/discord-akairo') diff --git a/src/lib/extensions/discord-akairo/BushArgumentTypeCaster.ts b/src/lib/extensions/discord-akairo/BushArgumentTypeCaster.ts index ed81290..9afcf8b 100644 --- a/src/lib/extensions/discord-akairo/BushArgumentTypeCaster.ts +++ b/src/lib/extensions/discord-akairo/BushArgumentTypeCaster.ts @@ -1,4 +1,4 @@ /* eslint-disable @typescript-eslint/no-explicit-any */ -import { BushMessage } from '..'; +import { BushMessage } from '../discord.js/BushMessage'; export type BushArgumentTypeCaster = (message: BushMessage, phrase: string) => any; diff --git a/src/lib/extensions/discord-akairo/BushClient.ts b/src/lib/extensions/discord-akairo/BushClient.ts index 99fd772..cb6a1de 100644 --- a/src/lib/extensions/discord-akairo/BushClient.ts +++ b/src/lib/extensions/discord-akairo/BushClient.ts @@ -15,42 +15,46 @@ import * as path from 'path'; import { exit } from 'process'; import readline from 'readline'; import { Sequelize } from 'sequelize'; -import { - AllowedMentions, - BushButtonInteraction, - BushCache, - BushCategoryChannel, - BushClientUtil, - BushCommandHandler, - BushCommandInteraction, - BushConstants, - BushDMChannel, - BushGuild, - BushGuildEmoji, - BushGuildMember, - BushInhibitorHandler, - BushListenerHandler, - BushLogger, - BushMessage, - BushMessageReaction, - BushNewsChannel, - BushPresence, - BushRole, - BushSelectMenuInteraction, - BushStoreChannel, - BushTaskHandler, - BushTextChannel, - BushThreadChannel, - BushThreadMember, - BushUser, - BushVoiceChannel, - BushVoiceState -} from '../..'; import { contentWithDurationTypeCaster } from '../../../arguments/contentWithDuration'; import { durationTypeCaster } from '../../../arguments/duration'; import * as config from '../../../config/options'; import { UpdateCacheTask } from '../../../tasks/updateCache'; -import * as Models from '../../models'; +import { Ban } from '../../models/Ban'; +import { Global } from '../../models/Global'; +import { Guild as GuildModel } from '../../models/Guild'; +import { Level } from '../../models/Level'; +import { ModLog } from '../../models/ModLog'; +import { Mute } from '../../models/Mute'; +import { StickyRole } from '../../models/StickyRole'; +import { AllowedMentions } from '../../utils/AllowedMentions'; +import { BushCache } from '../../utils/BushCache'; +import { BushConstants } from '../../utils/BushConstants'; +import { BushLogger } from '../../utils/BushLogger'; +import { BushButtonInteraction } from '../discord.js/BushButtonInteraction'; +import { BushCategoryChannel } from '../discord.js/BushCategoryChannel'; +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 { BushGuildMember } from '../discord.js/BushGuildMember'; +import { BushMessage } from '../discord.js/BushMessage'; +import { BushMessageReaction } from '../discord.js/BushMessageReaction'; +import { BushNewsChannel } from '../discord.js/BushNewsChannel'; +import { BushPresence } from '../discord.js/BushPresence'; +import { BushRole } from '../discord.js/BushRole'; +import { BushSelectMenuInteraction } from '../discord.js/BushSelectMenuInteraction'; +import { BushStoreChannel } from '../discord.js/BushStoreChannel'; +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 { BushVoiceChannel } from '../discord.js/BushVoiceChannel'; +import { BushVoiceState } from '../discord.js/BushVoiceState'; +import { BushClientUtil } from './BushClientUtil'; +import { BushCommandHandler } from './BushCommandHandler'; +import { BushInhibitorHandler } from './BushInhibitorHandler'; +import { BushListenerHandler } from './BushListenerHandler'; +import { BushTaskHandler } from './BushTaskHandler'; export type BotConfig = typeof config; export type BushReplyMessageType = string | MessagePayload | ReplyMessageOptions; @@ -106,11 +110,29 @@ export class BushClient extends AkairoClient { super( { ownerID: config.owners, - intents: Object.values(Intents.FLAGS).reduce((acc, p) => acc | p, 0) + intents: Object.values(Intents.FLAGS).reduce((acc, p) => acc | p, 0), + presence: { + activities: [ + { + name: 'Beep Boop', + type: 'WATCHING' + } + ], + status: 'online' + } }, { allowedMentions: AllowedMentions.users(), // No everyone or role mentions by default - intents: Object.values(Intents.FLAGS).reduce((acc, p) => acc | p, 0) + intents: Object.values(Intents.FLAGS).reduce((acc, p) => acc | p, 0), + presence: { + activities: [ + { + name: 'Beep Boop', + type: 'WATCHING' + } + ], + status: 'online' + } } ); @@ -142,7 +164,7 @@ export class BushClient extends AkairoClient { directory: path.join(__dirname, '..', '..', '..', 'commands'), prefix: async ({ guild }: { guild: Guild }) => { if (this.config.dev) return 'dev '; - const row = await Models.Guild.findByPk(guild.id); + const row = await GuildModel.findByPk(guild.id); return (row?.prefix || this.config.prefix) as string; }, allowMention: true, @@ -223,7 +245,7 @@ export class BushClient extends AkairoClient { } } await this.dbPreInit(); - await new UpdateCacheTask().init(this); + await UpdateCacheTask.init(this); this.console.success('Startup', `Successfully created <>.`, false); this.taskHandler.startAll(); } @@ -231,13 +253,13 @@ export class BushClient extends AkairoClient { public async dbPreInit(): Promise { try { await this.db.authenticate(); - Models.Global.initModel(this.db); - Models.Guild.initModel(this.db, this); - Models.ModLog.initModel(this.db); - Models.Ban.initModel(this.db); - Models.Mute.initModel(this.db); - Models.Level.initModel(this.db); - Models.StickyRole.initModel(this.db); + Global.initModel(this.db); + GuildModel.initModel(this.db, this); + ModLog.initModel(this.db); + Ban.initModel(this.db); + Mute.initModel(this.db); + Level.initModel(this.db); + StickyRole.initModel(this.db); await this.db.sync({ alter: true }); // Sync all tables to fix everything if updated await this.console.success('Startup', `Successfully connected to <>.`, false); } catch (e) { diff --git a/src/lib/extensions/discord-akairo/BushClientUtil.ts b/src/lib/extensions/discord-akairo/BushClientUtil.ts index c2d9da7..6c6d49a 100644 --- a/src/lib/extensions/discord-akairo/BushClientUtil.ts +++ b/src/lib/extensions/discord-akairo/BushClientUtil.ts @@ -1,5 +1,6 @@ /* eslint-disable @typescript-eslint/no-explicit-any */ /* eslint-disable @typescript-eslint/explicit-module-boundary-types */ + import { exec } from 'child_process'; import { ClientUtil } from 'discord-akairo'; import { APIMessage } from 'discord-api-types'; @@ -26,23 +27,19 @@ import { import got from 'got'; import humanizeDuration from 'humanize-duration'; import { promisify } from 'util'; -import { - Ban, - BushCache, - BushClient, - BushConstants, - BushGuildMember, - BushGuildMemberResolvable, - BushGuildResolvable, - BushMessage, - BushSlashMessage, - Global, - Guild, - ModLog, - ModLogType, - Mute, - PunishmentRole -} from '../..'; +import { Ban } from '../../models/Ban'; +import { Global } from '../../models/Global'; +import { Guild } from '../../models/Guild'; +import { ModLog, ModLogType } from '../../models/ModLog'; +import { Mute } from '../../models/Mute'; +import { PunishmentRole } from '../../models/PunishmentRole'; +import { BushCache } from '../../utils/BushCache'; +import { BushConstants } from '../../utils/BushConstants'; +import { BushGuildResolvable } from '../discord.js/BushCommandInteraction'; +import { BushGuildMember } from '../discord.js/BushGuildMember'; +import { BushMessage } from '../discord.js/BushMessage'; +import { BushClient, BushGuildMemberResolvable } from './BushClient'; +import { BushSlashMessage } from './BushSlashMessage'; interface hastebinRes { key: string; diff --git a/src/lib/extensions/discord-akairo/BushCommand.ts b/src/lib/extensions/discord-akairo/BushCommand.ts index 6143816..90c68df 100644 --- a/src/lib/extensions/discord-akairo/BushCommand.ts +++ b/src/lib/extensions/discord-akairo/BushCommand.ts @@ -9,7 +9,10 @@ import { CommandOptions } from 'discord-akairo'; import { Snowflake } from 'discord.js'; -import { BushClient, BushCommandHandler, BushMessage, BushSlashMessage } from '..'; +import { BushMessage } from '../discord.js/BushMessage'; +import { BushClient } from './BushClient'; +import { BushCommandHandler } from './BushCommandHandler'; +import { BushSlashMessage } from './BushSlashMessage'; type BushArgumentType = | 'string' diff --git a/src/lib/extensions/discord-akairo/BushCommandHandler.ts b/src/lib/extensions/discord-akairo/BushCommandHandler.ts index 76bade4..09baf2e 100644 --- a/src/lib/extensions/discord-akairo/BushCommandHandler.ts +++ b/src/lib/extensions/discord-akairo/BushCommandHandler.ts @@ -1,7 +1,10 @@ /* eslint-disable @typescript-eslint/no-explicit-any */ import { Category, CommandHandler, CommandHandlerOptions } from 'discord-akairo'; import { Collection } from 'discord.js'; -import { BushClient, BushCommand, BushConstants, BushMessage } from '../..'; +import { BushConstants } from '../../utils/BushConstants'; +import { BushMessage } from '../discord.js/BushMessage'; +import { BushClient } from './BushClient'; +import { BushCommand } from './BushCommand'; export type BushCommandHandlerOptions = CommandHandlerOptions; diff --git a/src/lib/extensions/discord-akairo/BushCommandUtil.ts b/src/lib/extensions/discord-akairo/BushCommandUtil.ts index 35fdd55..1e86401 100644 --- a/src/lib/extensions/discord-akairo/BushCommandUtil.ts +++ b/src/lib/extensions/discord-akairo/BushCommandUtil.ts @@ -1,6 +1,8 @@ import { CommandUtil, ParsedComponentData } from 'discord-akairo'; import { Collection, Snowflake } from 'discord.js'; -import { BushCommand, BushCommandHandler, BushMessage } from '..'; +import { BushMessage } from '../discord.js/BushMessage'; +import { BushCommand } from './BushCommand'; +import { BushCommandHandler } from './BushCommandHandler'; export interface BushParsedComponentData extends ParsedComponentData { command?: BushCommand; diff --git a/src/lib/extensions/discord-akairo/BushInhibitor.ts b/src/lib/extensions/discord-akairo/BushInhibitor.ts index 47e9515..ae91494 100644 --- a/src/lib/extensions/discord-akairo/BushInhibitor.ts +++ b/src/lib/extensions/discord-akairo/BushInhibitor.ts @@ -1,6 +1,9 @@ /* eslint-disable @typescript-eslint/no-explicit-any */ import { Inhibitor } from 'discord-akairo'; -import { BushClient, BushCommand, BushMessage, BushSlashMessage } from '..'; +import { BushMessage } from '../discord.js/BushMessage'; +import { BushClient } from './BushClient'; +import { BushCommand } from './BushCommand'; +import { BushSlashMessage } from './BushSlashMessage'; export class BushInhibitor extends Inhibitor { public declare client: BushClient; diff --git a/src/lib/extensions/discord-akairo/BushInhibitorHandler.ts b/src/lib/extensions/discord-akairo/BushInhibitorHandler.ts index 4077228..2a947da 100644 --- a/src/lib/extensions/discord-akairo/BushInhibitorHandler.ts +++ b/src/lib/extensions/discord-akairo/BushInhibitorHandler.ts @@ -1,5 +1,5 @@ import { InhibitorHandler } from 'discord-akairo'; -import { BushClient } from '..'; +import { BushClient } from './BushClient'; export class BushInhibitorHandler extends InhibitorHandler { public declare client: BushClient; diff --git a/src/lib/extensions/discord-akairo/BushListener.ts b/src/lib/extensions/discord-akairo/BushListener.ts index 573bed9..e555e89 100644 --- a/src/lib/extensions/discord-akairo/BushListener.ts +++ b/src/lib/extensions/discord-akairo/BushListener.ts @@ -1,5 +1,5 @@ import { Listener } from 'discord-akairo'; -import { BushClient } from '..'; +import { BushClient } from './BushClient'; export class BushListener extends Listener { public declare client: BushClient; diff --git a/src/lib/extensions/discord-akairo/BushListenerHandler.ts b/src/lib/extensions/discord-akairo/BushListenerHandler.ts index 73ca2df..28615fc 100644 --- a/src/lib/extensions/discord-akairo/BushListenerHandler.ts +++ b/src/lib/extensions/discord-akairo/BushListenerHandler.ts @@ -1,5 +1,5 @@ import { ListenerHandler } from 'discord-akairo'; -import { BushClient } from '..'; +import { BushClient } from './BushClient'; export class BushListenerHandler extends ListenerHandler { declare client: BushClient; diff --git a/src/lib/extensions/discord-akairo/BushSlashMessage.ts b/src/lib/extensions/discord-akairo/BushSlashMessage.ts index 63358b0..eee6ac2 100644 --- a/src/lib/extensions/discord-akairo/BushSlashMessage.ts +++ b/src/lib/extensions/discord-akairo/BushSlashMessage.ts @@ -1,6 +1,10 @@ import { AkairoMessage } from 'discord-akairo'; import { CommandInteraction } from 'discord.js'; -import { BushClient, BushCommandUtil, BushGuild, BushGuildMember, BushUser } from '..'; +import { BushGuild } from '../discord.js/BushGuild'; +import { BushGuildMember } from '../discord.js/BushGuildMember'; +import { BushUser } from '../discord.js/BushUser'; +import { BushClient } from './BushClient'; +import { BushCommandUtil } from './BushCommandUtil'; export class BushSlashMessage extends AkairoMessage { public declare client: BushClient; diff --git a/src/lib/extensions/discord-akairo/BushTask.ts b/src/lib/extensions/discord-akairo/BushTask.ts index 498a837..b315270 100644 --- a/src/lib/extensions/discord-akairo/BushTask.ts +++ b/src/lib/extensions/discord-akairo/BushTask.ts @@ -1,9 +1,9 @@ import { Task, TaskOptions } from 'discord-akairo'; -import { BushClient } from '..'; +import { BushClient } from './BushClient'; export class BushTask extends Task { + public declare client: BushClient; public constructor(id: string, options?: TaskOptions) { super(id, options); } - public declare client: BushClient; } diff --git a/src/lib/extensions/discord-akairo/BushTaskHandler.ts b/src/lib/extensions/discord-akairo/BushTaskHandler.ts index a24aa23..588988d 100644 --- a/src/lib/extensions/discord-akairo/BushTaskHandler.ts +++ b/src/lib/extensions/discord-akairo/BushTaskHandler.ts @@ -1,5 +1,5 @@ import { AkairoHandlerOptions, TaskHandler } from 'discord-akairo'; -import { BushClient } from '..'; +import { BushClient } from './BushClient'; export type BushTaskHandlerOptions = AkairoHandlerOptions; diff --git a/src/lib/extensions/discord-akairo/index.ts b/src/lib/extensions/discord-akairo/index.ts deleted file mode 100644 index fd92de2..0000000 --- a/src/lib/extensions/discord-akairo/index.ts +++ /dev/null @@ -1,13 +0,0 @@ -export * from './BushArgumentTypeCaster'; -export * from './BushClient'; -export * from './BushClientUtil'; -export * from './BushCommand'; -export * from './BushCommandHandler'; -export * from './BushCommandUtil'; -export * from './BushInhibitor'; -export * from './BushInhibitorHandler'; -export * from './BushListener'; -export * from './BushListenerHandler'; -export * from './BushSlashMessage'; -export * from './BushTask'; -export * from './BushTaskHandler'; -- cgit