From c40a94697d64962edda41345e03fa76f51aa431c Mon Sep 17 00:00:00 2001 From: IRONM00N <64110067+IRONM00N@users.noreply.github.com> Date: Sun, 31 Oct 2021 22:38:06 -0400 Subject: upgrade typescript, improve workflow, bunch of bug fixes and some other things --- .../discord-akairo/BushArgumentTypeCaster.ts | 2 +- src/lib/extensions/discord-akairo/BushClient.ts | 33 ++++++++++----------- .../extensions/discord-akairo/BushClientUtil.ts | 34 +++++++++++----------- src/lib/extensions/discord-akairo/BushCommand.ts | 9 ++---- .../discord-akairo/BushCommandHandler.ts | 9 ++---- .../extensions/discord-akairo/BushCommandUtil.ts | 10 ++----- src/lib/extensions/discord-akairo/BushInhibitor.ts | 5 +--- .../discord-akairo/BushInhibitorHandler.ts | 2 +- src/lib/extensions/discord-akairo/BushListener.ts | 5 ++-- .../discord-akairo/BushListenerHandler.ts | 2 +- .../extensions/discord-akairo/BushSlashMessage.ts | 8 ++--- src/lib/extensions/discord-akairo/BushTask.ts | 4 +-- .../extensions/discord-akairo/BushTaskHandler.ts | 4 +-- 13 files changed, 55 insertions(+), 72 deletions(-) (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 42d989c..c07644c 100644 --- a/src/lib/extensions/discord-akairo/BushArgumentTypeCaster.ts +++ b/src/lib/extensions/discord-akairo/BushArgumentTypeCaster.ts @@ -1,3 +1,3 @@ -import { BushMessage } from '../discord.js/BushMessage'; +import { type BushMessage } from '@lib'; 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 c5d05b7..8f7533c 100644 --- a/src/lib/extensions/discord-akairo/BushClient.ts +++ b/src/lib/extensions/discord-akairo/BushClient.ts @@ -1,21 +1,20 @@ import * as Sentry from '@sentry/node'; import { AkairoClient, ContextMenuCommandHandler, version as akairoVersion } from 'discord-akairo'; import { - Awaitable, - Collection, - Intents, - InteractionReplyOptions, - Message, - MessageEditOptions, - MessageOptions, - MessagePayload, - Options, - PartialDMChannel, - ReplyMessageOptions, - Snowflake, - Structures, - version as discordJsVersion, - WebhookEditMessageOptions + DMChannel, + Intents, Options, + Structures, version as discordJsVersion, + type Awaitable, + type Collection, + type InteractionReplyOptions, + type Message, + type MessageEditOptions, + type MessageOptions, + type MessagePayload, + type PartialDMChannel, + type ReplyMessageOptions, + type Snowflake, + type WebhookEditMessageOptions } from 'discord.js'; //@ts-ignore: no typings import eventsIntercept from 'events-intercept'; @@ -89,7 +88,7 @@ export type BushThreadMemberResolvable = BushThreadMember | BushUserResolvable; export type BushUserResolvable = BushUser | Snowflake | BushMessage | BushGuildMember | BushThreadMember; export type BushGuildMemberResolvable = BushGuildMember | BushUserResolvable; export type BushRoleResolvable = BushRole | Snowflake; -export type BushMessageResolvable = BushMessage | Snowflake; +export type BushMessageResolvable = Message| BushMessage | Snowflake; export type BushEmojiResolvable = Snowflake | BushGuildEmoji | BushReactionEmoji; export type BushEmojiIdentifierResolvable = string | BushEmojiResolvable; export type BushThreadChannelResolvable = BushThreadChannel | Snowflake; @@ -97,7 +96,7 @@ export type BushApplicationCommandResolvable = BushApplicationCommand | Snowflak export type BushGuildTextChannelResolvable = BushTextChannel | BushNewsChannel | Snowflake; export type BushChannelResolvable = BushChannel | Snowflake; export type BushTextBasedChannels = PartialDMChannel | BushDMChannel | BushTextChannel | BushNewsChannel | BushThreadChannel; -export type BushGuildTextBasedChannel = Exclude; +export type BushGuildTextBasedChannel = Exclude; export interface BushFetchedThreads { threads: Collection; hasMore?: boolean; diff --git a/src/lib/extensions/discord-akairo/BushClientUtil.ts b/src/lib/extensions/discord-akairo/BushClientUtil.ts index 32081ed..4507458 100644 --- a/src/lib/extensions/discord-akairo/BushClientUtil.ts +++ b/src/lib/extensions/discord-akairo/BushClientUtil.ts @@ -1,31 +1,32 @@ import { - BushCache, - BushClient, + Arg, BushConstants, - BushMessage, - BushSlashMessage, - BushUser, Global, - Pronoun, - PronounCode + type BushCache, + type BushClient, + type BushMessage, + type BushSlashMessage, + type BushUser, + type Pronoun, + type PronounCode } from '@lib'; import { exec } from 'child_process'; import { ClientUtil, Util as AkairoUtil } from 'discord-akairo'; import { APIMessage } from 'discord-api-types'; import { - ColorResolvable, - CommandInteraction, GuildMember, - InteractionReplyOptions, Message, MessageEmbed, - PermissionResolvable, - Snowflake, - TextChannel, ThreadMember, User, - UserResolvable, - Util as DiscordUtil + Util as DiscordUtil, + type ColorResolvable, + type CommandInteraction, + type InteractionReplyOptions, + type PermissionResolvable, + type Snowflake, + type TextChannel, + type UserResolvable } from 'discord.js'; import got from 'got'; import humanizeDuration from 'humanize-duration'; @@ -36,7 +37,6 @@ import CommandErrorListener from '../../../listeners/commands/commandError'; import { Format } from '../../common/Format'; import { BushInspectOptions } from '../../common/typings/BushInspectOptions'; import { CodeBlockLang } from '../../common/typings/CodeBlockLang'; -import { Arg } from '../../common/util/Arg'; import { BushNewsChannel } from '../discord.js/BushNewsChannel'; import { BushTextChannel } from '../discord.js/BushTextChannel'; import { BushSlashEditMessageType, BushSlashSendMessageType, BushUserResolvable } from './BushClient'; @@ -401,7 +401,7 @@ export class BushClientUtil extends ClientUtil { /** * Add or remove an item from an array. All duplicates will be removed. */ - public addOrRemoveFromArray(action: 'add' | 'remove', array: T[], value: T): T[] { + public addOrRemoveFromArray(action: 'add' | 'remove', array: T[], value: T): T[] { const set = new Set(array); action === 'add' ? set.add(value) : set.delete(value); return [...set]; diff --git a/src/lib/extensions/discord-akairo/BushCommand.ts b/src/lib/extensions/discord-akairo/BushCommand.ts index e3066aa..40c5974 100644 --- a/src/lib/extensions/discord-akairo/BushCommand.ts +++ b/src/lib/extensions/discord-akairo/BushCommand.ts @@ -1,9 +1,6 @@ -import { ArgumentOptions, ArgumentPromptOptions, ArgumentTypeCaster, Command, CommandOptions } from 'discord-akairo'; -import { PermissionResolvable, Snowflake } from 'discord.js'; -import { BushMessage } from '../discord.js/BushMessage'; -import { BushClient } from './BushClient'; -import { BushCommandHandler } from './BushCommandHandler'; -import { BushSlashMessage } from './BushSlashMessage'; +import { type BushClient, type BushCommandHandler, type BushMessage, type BushSlashMessage } from '@lib'; +import { Command, type ArgumentOptions, type ArgumentPromptOptions, type ArgumentTypeCaster, type CommandOptions } from 'discord-akairo'; +import { type PermissionResolvable, type Snowflake } from 'discord.js'; export type BaseBushArgumentType = | 'string' diff --git a/src/lib/extensions/discord-akairo/BushCommandHandler.ts b/src/lib/extensions/discord-akairo/BushCommandHandler.ts index 8ab47d8..09cb303 100644 --- a/src/lib/extensions/discord-akairo/BushCommandHandler.ts +++ b/src/lib/extensions/discord-akairo/BushCommandHandler.ts @@ -1,9 +1,6 @@ -import { Category, CommandHandler, CommandHandlerEvents, CommandHandlerOptions } from 'discord-akairo'; -import { Collection, PermissionString } from 'discord.js'; -import { BushMessage } from '../discord.js/BushMessage'; -import { BushClient } from './BushClient'; -import { BushCommand } from './BushCommand'; -import { BushSlashMessage } from './BushSlashMessage'; +import { type BushClient, type BushCommand, type BushMessage, type BushSlashMessage } from '@lib'; +import { CommandHandler, type Category, type CommandHandlerEvents, type CommandHandlerOptions } from 'discord-akairo'; +import { type Collection, type PermissionString } from 'discord.js'; export type BushCommandHandlerOptions = CommandHandlerOptions; diff --git a/src/lib/extensions/discord-akairo/BushCommandUtil.ts b/src/lib/extensions/discord-akairo/BushCommandUtil.ts index 7720d57..04533bd 100644 --- a/src/lib/extensions/discord-akairo/BushCommandUtil.ts +++ b/src/lib/extensions/discord-akairo/BushCommandUtil.ts @@ -1,10 +1,6 @@ -import { CommandUtil, ParsedComponentData } from 'discord-akairo'; -import { Snowflake } from 'discord-api-types'; -import { Collection } from 'discord.js'; -import { BushMessage } from '../discord.js/BushMessage'; -import { BushCommand } from './BushCommand'; -import { BushCommandHandler } from './BushCommandHandler'; -import { BushSlashMessage } from './BushSlashMessage'; +import { type BushCommand, type BushCommandHandler, type BushMessage, type BushSlashMessage } from '@lib'; +import { CommandUtil, type ParsedComponentData } from 'discord-akairo'; +import { type Collection, type Snowflake } from 'discord.js'; 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 d689a72..638f663 100644 --- a/src/lib/extensions/discord-akairo/BushInhibitor.ts +++ b/src/lib/extensions/discord-akairo/BushInhibitor.ts @@ -1,8 +1,5 @@ +import { type BushClient, type BushCommand, type BushMessage, type BushSlashMessage } from '@lib'; import { Inhibitor } from 'discord-akairo'; -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 2a947da..4984934 100644 --- a/src/lib/extensions/discord-akairo/BushInhibitorHandler.ts +++ b/src/lib/extensions/discord-akairo/BushInhibitorHandler.ts @@ -1,5 +1,5 @@ +import { type BushClient } from '@lib'; import { InhibitorHandler } from 'discord-akairo'; -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 82e874f..e3c845c 100644 --- a/src/lib/extensions/discord-akairo/BushListener.ts +++ b/src/lib/extensions/discord-akairo/BushListener.ts @@ -1,6 +1,7 @@ +import { type BushClient } from '@lib'; import { Listener } from 'discord-akairo'; -import EventEmitter from 'events'; -import { BushClient } from './BushClient'; +import type EventEmitter from 'events'; + export class BushListener extends Listener { public declare client: BushClient; public constructor( diff --git a/src/lib/extensions/discord-akairo/BushListenerHandler.ts b/src/lib/extensions/discord-akairo/BushListenerHandler.ts index 28615fc..f5354e4 100644 --- a/src/lib/extensions/discord-akairo/BushListenerHandler.ts +++ b/src/lib/extensions/discord-akairo/BushListenerHandler.ts @@ -1,5 +1,5 @@ +import { type BushClient } from '@lib'; import { ListenerHandler } from 'discord-akairo'; -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 b5e48ea..fd248b1 100644 --- a/src/lib/extensions/discord-akairo/BushSlashMessage.ts +++ b/src/lib/extensions/discord-akairo/BushSlashMessage.ts @@ -1,10 +1,6 @@ +import { type BushClient, type BushCommandUtil, type BushGuild, type BushGuildMember, type BushUser } from '@lib'; import { AkairoMessage } from 'discord-akairo'; -import { CommandInteraction } from 'discord.js'; -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'; +import { type CommandInteraction } from 'discord.js'; 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 1b14a2b..299e977 100644 --- a/src/lib/extensions/discord-akairo/BushTask.ts +++ b/src/lib/extensions/discord-akairo/BushTask.ts @@ -1,5 +1,5 @@ -import { Task, TaskOptions } from 'discord-akairo'; -import { BushClient } from './BushClient'; +import { type BushClient } from '@lib'; +import { Task, type TaskOptions } from 'discord-akairo'; export class BushTask extends Task { public declare client: BushClient; diff --git a/src/lib/extensions/discord-akairo/BushTaskHandler.ts b/src/lib/extensions/discord-akairo/BushTaskHandler.ts index 588988d..8531ff1 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 './BushClient'; +import { type BushClient } from '@lib'; +import { TaskHandler, type AkairoHandlerOptions } from 'discord-akairo'; export type BushTaskHandlerOptions = AkairoHandlerOptions; -- cgit