aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorIRONM00N <64110067+IRONM00N@users.noreply.github.com>2022-08-20 23:07:02 -0400
committerIRONM00N <64110067+IRONM00N@users.noreply.github.com>2022-08-20 23:07:02 -0400
commitb81f9e8b73cb520ad5ae916c3e571ea55f4ca489 (patch)
tree25d7f42d66c3e3190022ece043c86082a9e85709
parentf2e5cfff7dc275bd93fac446a508b7d18ecd6c58 (diff)
downloadtanzanite-b81f9e8b73cb520ad5ae916c3e571ea55f4ca489.tar.gz
tanzanite-b81f9e8b73cb520ad5ae916c3e571ea55f4ca489.tar.bz2
tanzanite-b81f9e8b73cb520ad5ae916c3e571ea55f4ca489.zip
fix ts composite shit, replace got with native fetch, update deps
-rw-r--r--.eslintrc.cjs14
-rw-r--r--.github/workflows/checks.yml2
-rw-r--r--.vscode/settings.json12
-rw-r--r--.yarnrc.yml6
-rw-r--r--config/index.ts2
-rw-r--r--config/tsconfig.json5
-rw-r--r--ecosystem.config.cjs3
-rw-r--r--lib/automod/AutomodShared.ts4
-rw-r--r--lib/common/Sentry.ts2
-rw-r--r--lib/common/tags.ts2
-rw-r--r--lib/extensions/discord-akairo/BushClient.ts43
-rw-r--r--lib/global.ts (renamed from lib/extensions/global.ts)4
-rw-r--r--lib/index.ts5
-rw-r--r--lib/models/index.ts13
-rw-r--r--lib/models/instance/ActivePunishment.ts3
-rw-r--r--lib/models/instance/Guild.ts6
-rw-r--r--lib/models/instance/Highlight.ts3
-rw-r--r--lib/models/instance/Level.ts3
-rw-r--r--lib/models/instance/ModLog.ts3
-rw-r--r--lib/models/instance/Reminder.ts3
-rw-r--r--lib/models/instance/StickyRole.ts3
-rw-r--r--lib/models/shared/Global.ts3
-rw-r--r--lib/models/shared/Shared.ts3
-rw-r--r--lib/models/shared/Stat.ts3
-rw-r--r--lib/tsconfig.json6
-rw-r--r--lib/utils/BushClientUtils.ts45
-rw-r--r--lib/utils/BushConstants.ts2
-rw-r--r--lib/utils/BushUtils.ts6
-rw-r--r--lib/utils/ErrorHandler.ts236
-rw-r--r--lib/utils/FormatResponse.ts32
-rw-r--r--lib/utils/UpdateCache.ts36
m---------neu-item-repo0
m---------neu-item-repo-dangerous0
-rw-r--r--package.json58
-rw-r--r--src/bot.ts5
-rw-r--r--src/commands/admin/channelPermissions.ts2
-rw-r--r--src/commands/admin/roleAll.ts1
-rw-r--r--src/commands/config/config.ts1
-rw-r--r--src/commands/config/disable.ts2
-rw-r--r--src/commands/dev/eval.ts3
-rw-r--r--src/commands/dev/reload.ts15
-rw-r--r--src/commands/dev/syncAutomod.ts11
-rw-r--r--src/commands/index.ts2
-rw-r--r--src/commands/info/help.ts2
-rw-r--r--src/commands/leveling/level.ts32
-rw-r--r--src/commands/moderation/unmute.ts38
-rw-r--r--src/commands/moulberry-bush/capePermissions.ts3
-rw-r--r--src/commands/moulberry-bush/capes.ts10
-rw-r--r--src/commands/moulberry-bush/serverStatus.ts8
-rw-r--r--src/commands/utilities/hash.ts82
-rw-r--r--src/commands/utilities/price.ts9
-rw-r--r--src/context-menu-commands/user/modlog.ts2
-rw-r--r--src/context-menu-commands/user/userInfo.ts2
-rw-r--r--src/listeners/commands/commandError.ts241
-rw-r--r--src/listeners/commands/slashCommandError.ts5
-rw-r--r--src/listeners/contextCommands/contextCommandError.ts7
-rw-r--r--src/listeners/member-custom/bushBan.ts2
-rw-r--r--src/listeners/message/blacklistedFile.ts300
-rw-r--r--src/listeners/other/promiseRejection.ts5
-rw-r--r--src/listeners/other/uncaughtException.ts5
-rw-r--r--src/listeners/other/warning.ts5
-rw-r--r--src/tasks/cache/updateCache.ts49
-rw-r--r--src/tasks/cache/updatePriceItemCache.ts6
-rw-r--r--src/tasks/feature/handleReminders.ts5
-rw-r--r--src/tasks/feature/removeExpiredPunishements.ts2
-rw-r--r--src/tasks/feature/updateStats.d.ts10
-rw-r--r--src/tasks/feature/updateStats.js22
-rw-r--r--src/tasks/feature/updateStats.js.map1
-rw-r--r--src/tasks/feature/updateStats.ts7
-rw-r--r--src/tsconfig.json6
-rw-r--r--tsconfig.base.json15
-rw-r--r--tsconfig.eslint.json2
-rw-r--r--tsconfig.json9
-rw-r--r--tsconfig.pkg.json8
-rw-r--r--yarn.lock1651
75 files changed, 960 insertions, 2204 deletions
diff --git a/.eslintrc.cjs b/.eslintrc.cjs
index d246897..e65a7c8 100644
--- a/.eslintrc.cjs
+++ b/.eslintrc.cjs
@@ -1,5 +1,3 @@
-/* eslint-disable import/no-commonjs */
-
// prettier-ignore
const globals = [
'NodeFilter', 'AbortController', 'AbortSignal', 'AbstractRange', 'AnalyserNode', 'Animation', 'AnimationEffect',
@@ -20,7 +18,7 @@ const globals = [
'DocumentFragment', 'DocumentTimeline', 'DocumentType', 'DragEvent', 'DynamicsCompressorNode', 'Element', 'ElementInternals',
'ErrorEvent', 'Event', 'EventSource', 'EventTarget', 'External', 'File', 'FileList', 'FileReader', 'FileSystem',
'FileSystemDirectoryEntry', 'FileSystemDirectoryReader', 'FileSystemEntry', 'FileSystemFileEntry', 'FocusEvent', 'FontFace',
- 'FontFaceSet', 'FontFaceSetLoadEvent', 'FormData', 'FormDataEvent', 'GainNode', 'Gamepad', 'GamepadButton', 'GamepadEvent',
+ 'FontFaceSet', 'FontFaceSetLoadEvent', 'FormDataEvent', 'GainNode', 'Gamepad', 'GamepadButton', 'GamepadEvent',
'GamepadHapticActuator', 'Geolocation', 'GeolocationCoordinates', 'GeolocationPosition', 'GeolocationPositionError',
'HTMLAllCollection', 'HTMLAnchorElement', 'HTMLAreaElement', 'HTMLAudioElement', 'HTMLBRElement', 'HTMLBaseElement',
'HTMLBodyElement', 'HTMLButtonElement', 'HTMLCanvasElement', 'HTMLCollection', 'HTMLDListElement', 'HTMLDataElement',
@@ -112,7 +110,7 @@ const globals = [
'ongamepadconnected', 'ongamepaddisconnected', 'onhashchange', 'onlanguagechange', 'onmessage', 'onmessageerror', 'onoffline',
'ononline', 'onpagehide', 'onpageshow', 'onpopstate', 'onrejectionhandled', 'onstorage', 'onunhandledrejection', 'onunload',
'localStorage', 'caches', 'crossOriginIsolated', 'crypto', 'indexedDB', 'isSecureContext', 'origin', 'performance', 'atob',
- 'btoa', 'createImageBitmap', 'fetch', 'queueMicrotask', 'sessionStorage', 'addEventListener', 'removeEventListener'
+ 'btoa', 'createImageBitmap', 'queueMicrotask', 'sessionStorage', 'addEventListener', 'removeEventListener'
]
/**
@@ -130,8 +128,7 @@ module.exports = {
sourceType: 'module',
project: './tsconfig.eslint.json'
},
- plugins: ['@typescript-eslint', 'deprecation', 'import'],
- ignorePatterns: ['dist', 'node_modules'],
+ plugins: ['@typescript-eslint', 'deprecation'],
rules: {
'no-return-await': 'off',
'@typescript-eslint/no-empty-interface': 'warn',
@@ -170,14 +167,13 @@ module.exports = {
'deprecation/deprecation': 'warn',
'@typescript-eslint/explicit-member-accessibility': ['warn', { accessibility: 'explicit' }],
'@typescript-eslint/switch-exhaustiveness-check': 'warn',
- 'import/no-commonjs': 'error',
- 'import/extensions': ['error', 'ignorePackages'],
'@typescript-eslint/no-restricted-imports': [
'error',
{ paths: [{ name: 'console', importNames: ['assert'], message: 'Import from the `assert` module instead.' }] }
],
'no-restricted-globals': ['error', ...globals.map((v) => ({ name: v, message: "Don't use DOM globals." }))],
'@typescript-eslint/no-namespace': 'off',
- 'no-debugger': 'warn'
+ 'no-debugger': 'warn',
+ '@typescript-eslint/prefer-as-const': 'warn'
}
};
diff --git a/.github/workflows/checks.yml b/.github/workflows/checks.yml
index de5e141..8af3039 100644
--- a/.github/workflows/checks.yml
+++ b/.github/workflows/checks.yml
@@ -24,7 +24,7 @@ jobs:
- name: ESLint
run: yarn lint
- name: Build
- run: yarn build:tsc
+ run: yarn build
- name: Dry Run
run: yarn start:dry
diff --git a/.vscode/settings.json b/.vscode/settings.json
index d86374b..4eed974 100644
--- a/.vscode/settings.json
+++ b/.vscode/settings.json
@@ -9,8 +9,6 @@
".pnp.js": false,
"**/node_modules": true
},
- "javascript.preferences.importModuleSpecifier": "project-relative",
- "typescript.preferences.importModuleSpecifier": "project-relative",
"search.exclude": {
"**/.yarn": true,
"**/.pnp.*": true,
@@ -20,7 +18,6 @@
},
"editor.codeActionsOnSave": {
"source.organizeImports": true,
- // "source.fixAll.eslint": true,
"source.format": true
},
"diffEditor.wordWrap": "on",
@@ -31,11 +28,14 @@
"prettier.prettierPath": "node_modules/prettier",
"prettier.withNodeModules": true,
"prettier.useEditorConfig": false,
- // "typescript.tsdk": ".yarn/sdks/typescript/lib",
- "typescript.tsdk": "node_modules/typescript/lib",
- "typescript.enablePromptUseWorkspaceTsdk": true,
+ "javascript.format.enable": false,
+ "javascript.preferences.importModuleSpecifier": "relative",
"javascript.preferences.importModuleSpecifierEnding": "js",
+ "javascript.preferences.useAliasesForRenames": false,
+ "typescript.format.enable": false,
+ "typescript.preferences.importModuleSpecifier": "relative",
"typescript.preferences.importModuleSpecifierEnding": "js",
+ "typescript.preferences.useAliasesForRenames": false,
"discord.removeDetails": false,
"discord.removeLowerDetails": false,
"discord.removeRemoteRepository": false,
diff --git a/.yarnrc.yml b/.yarnrc.yml
index caaf948..39b22a0 100644
--- a/.yarnrc.yml
+++ b/.yarnrc.yml
@@ -5,10 +5,10 @@ enableTelemetry: false
nodeLinker: pnpm
plugins:
- - path: .yarn/plugins/@yarnpkg/plugin-typescript.cjs
- spec: '@yarnpkg/plugin-typescript'
- path: .yarn/plugins/@yarnpkg/plugin-interactive-tools.cjs
- spec: '@yarnpkg/plugin-interactive-tools'
+ spec: "@yarnpkg/plugin-interactive-tools"
+ - path: .yarn/plugins/@yarnpkg/plugin-typescript.cjs
+ spec: "@yarnpkg/plugin-typescript"
pnpEnableEsmLoader: true
diff --git a/config/index.ts b/config/index.ts
new file mode 100644
index 0000000..7514faa
--- /dev/null
+++ b/config/index.ts
@@ -0,0 +1,2 @@
+export * from './Config.js';
+export { default as config, default } from './options.js';
diff --git a/config/tsconfig.json b/config/tsconfig.json
index 46b2d15..583c81a 100644
--- a/config/tsconfig.json
+++ b/config/tsconfig.json
@@ -1,7 +1,6 @@
{
"extends": "../tsconfig.base.json",
"compilerOptions": {
- "outDir": "../../dist/config"
- },
- "files": ["./Config.ts", "example-options.ts", "options.ts"]
+ "outDir": "../dist/config"
+ }
}
diff --git a/ecosystem.config.cjs b/ecosystem.config.cjs
index b064f76..3bd532f 100644
--- a/ecosystem.config.cjs
+++ b/ecosystem.config.cjs
@@ -1,4 +1,3 @@
-/* eslint-disable import/no-commonjs */
module.exports = {
apps: [
...['', '-beta'].map((e) => ({
@@ -25,7 +24,7 @@ module.exports = {
'ref': `origin/${e === 'production' ? 'master' : 'beta'}`,
'repo': 'https://github.com/NotEnoughUpdates/bush-bot.git',
'path': `/code/bush-bot${e === 'beta' ? '-beta' : ''}`,
- 'post-deploy': `yarn install && yarn build:tsc && pm2 start ecosystem.config.cjs --only bush-bot${
+ 'post-deploy': `yarn install && yarn build && pm2 start ecosystem.config.cjs --only bush-bot${
e === 'beta' ? '-beta' : ''
}`
}
diff --git a/lib/automod/AutomodShared.ts b/lib/automod/AutomodShared.ts
index 5d031d0..08cde25 100644
--- a/lib/automod/AutomodShared.ts
+++ b/lib/automod/AutomodShared.ts
@@ -8,11 +8,11 @@ import {
PermissionFlagsBits,
Snowflake
} from 'discord.js';
-import UnmuteCommand from '../../src/commands/moderation/unmute.js';
import * as Moderation from '../common/Moderation.js';
import { unmuteResponse } from '../extensions/discord.js/ExtendedGuildMember.js';
import { colors, emojis } from '../utils/BushConstants.js';
import * as Format from '../utils/Format.js';
+import { formatUnmuteResponse } from '../utils/FormatResponse.js';
/**
* Handles shared auto moderation functionality.
@@ -207,7 +207,7 @@ export async function handleAutomodInteraction(interaction: ButtonInteraction) {
if (check !== true) return interaction.reply({ content: check, ephemeral: true });
const check2 = await Moderation.checkMutePermissions(interaction.guild);
- if (check2 !== true) return interaction.reply({ content: UnmuteCommand.formatCode('/', victim!, check2), ephemeral: true });
+ if (check2 !== true) return interaction.reply({ content: formatUnmuteResponse('/', victim!, check2), ephemeral: true });
const result = await victim.bushUnmute({
reason,
diff --git a/lib/common/Sentry.ts b/lib/common/Sentry.ts
index 446ec27..1b0e19a 100644
--- a/lib/common/Sentry.ts
+++ b/lib/common/Sentry.ts
@@ -1,7 +1,7 @@
+import type { Config } from '#config';
import { RewriteFrames } from '@sentry/integrations';
import * as SentryNode from '@sentry/node';
import { Integrations } from '@sentry/node';
-import type { Config } from '../../config/Config.js';
export class Sentry {
public constructor(rootdir: string, config: Config) {
diff --git a/lib/common/tags.ts b/lib/common/tags.ts
index 098cf29..4af8783 100644
--- a/lib/common/tags.ts
+++ b/lib/common/tags.ts
@@ -1,5 +1,5 @@
/* these functions are adapted from the common-tags npm package which is licensed under the MIT license */
-/* the js docs are adapted from the @types/common-tags npm package which is licensed under the MIT license */
+/* the JSDOCs are adapted from the @types/common-tags npm package which is licensed under the MIT license */
/**
* Strips the **initial** indentation from the beginning of each line in a multiline string.
diff --git a/lib/extensions/discord-akairo/BushClient.ts b/lib/extensions/discord-akairo/BushClient.ts
index 1a6bb8c..92968d6 100644
--- a/lib/extensions/discord-akairo/BushClient.ts
+++ b/lib/extensions/discord-akairo/BushClient.ts
@@ -10,7 +10,8 @@ import {
roleWithDuration,
snowflake
} from '#args';
-import { BushClientEvents, emojis, formatError, inspect } from '#lib';
+import type { Config } from '#config';
+import { BushClientEvents, emojis, formatError, inspect, updateEveryCache } from '#lib';
import { patch, type PatchedElements } from '@notenoughupdates/events-intercept';
import * as Sentry from '@sentry/node';
import {
@@ -44,26 +45,25 @@ import type EventEmitter from 'events';
import { google } from 'googleapis';
import path from 'path';
import readline from 'readline';
-import type { Options as SequelizeOptions, Sequelize as SequelizeType } from 'sequelize';
+import { Options as SequelizeOptions, Sequelize, Sequelize as SequelizeType } from 'sequelize';
import { fileURLToPath } from 'url';
-import type { Config } from '../../../config/Config.js';
-import UpdateCacheTask from '../../../src/tasks/cache/updateCache.js';
-import UpdateStatsTask from '../../../src/tasks/feature/updateStats.js';
import { tinyColor } from '../../arguments/tinyColor.js';
import { BushCache } from '../../common/BushCache.js';
import { HighlightManager } from '../../common/HighlightManager.js';
-import { ActivePunishment } from '../../models/instance/ActivePunishment.js';
-import { Guild as GuildDB } from '../../models/instance/Guild.js';
-import { Highlight } from '../../models/instance/Highlight.js';
-import { Level } from '../../models/instance/Level.js';
-import { ModLog } from '../../models/instance/ModLog.js';
-import { Reminder } from '../../models/instance/Reminder.js';
-import { StickyRole } from '../../models/instance/StickyRole.js';
-import { Global } from '../../models/shared/Global.js';
-import { GuildCount } from '../../models/shared/GuildCount.js';
-import { MemberCount } from '../../models/shared/MemberCount.js';
-import { Shared } from '../../models/shared/Shared.js';
-import { Stat } from '../../models/shared/Stat.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 { BushClientUtils } from '../../utils/BushClientUtils.js';
import { BushLogger } from '../../utils/BushLogger.js';
@@ -75,7 +75,6 @@ import { BushCommandHandler } from './BushCommandHandler.js';
import { BushInhibitorHandler } from './BushInhibitorHandler.js';
import { BushListenerHandler } from './BushListenerHandler.js';
import { BushTaskHandler } from './BushTaskHandler.js';
-const { Sequelize } = (await import('sequelize')).default;
declare module 'discord.js' {
export interface Client extends EventEmitter {
@@ -467,7 +466,7 @@ export class BushClient<Ready extends boolean = boolean> extends AkairoClient<Re
public async dbPreInit() {
try {
await this.instanceDB.authenticate();
- GuildDB.initModel(this.instanceDB, this);
+ GuildModel.initModel(this.instanceDB, this);
ModLog.initModel(this.instanceDB);
ActivePunishment.initModel(this.instanceDB);
Level.initModel(this.instanceDB);
@@ -525,9 +524,11 @@ export class BushClient<Ready extends boolean = boolean> extends AkairoClient<Re
try {
await this.highlightManager.syncCache();
- await UpdateCacheTask.init(this);
+ await updateEveryCache(this);
void this.console.success('startup', `Successfully created <<cache>>.`, false);
- const stats = await UpdateStatsTask.init(this);
+
+ const stats =
+ (await Stat.findByPk(this.config.environment)) ?? (await Stat.create({ environment: this.config.environment }));
this.stats.commandsUsed = stats.commandsUsed;
this.stats.slashCommandsUsed = stats.slashCommandsUsed;
await this.login(this.token!);
diff --git a/lib/extensions/global.ts b/lib/global.ts
index a9020d7..0a0bcca 100644
--- a/lib/extensions/global.ts
+++ b/lib/global.ts
@@ -1,6 +1,6 @@
-/* eslint-disable no-var */
+/* eslint-disable */
+
declare global {
- // eslint-disable-next-line @typescript-eslint/no-unused-vars
interface ReadonlyArray<T> {
includes<S, R extends `${Extract<S, string>}`>(
this: ReadonlyArray<R>,
diff --git a/lib/index.ts b/lib/index.ts
index 5a8ecde..ca23177 100644
--- a/lib/index.ts
+++ b/lib/index.ts
@@ -1,3 +1,5 @@
+import './global.js';
+
export * from './automod/AutomodShared.js';
export * from './automod/MemberAutomod.js';
export * from './automod/MessageAutomod.js';
@@ -53,4 +55,7 @@ export * as Arg from './utils/Arg.js';
export * from './utils/BushConstants.js';
export * from './utils/BushLogger.js';
export * from './utils/BushUtils.js';
+export * from './utils/ErrorHandler.js';
export * as Format from './utils/Format.js';
+export * from './utils/FormatResponse.js';
+export * from './utils/UpdateCache.js';
diff --git a/lib/models/index.ts b/lib/models/index.ts
new file mode 100644
index 0000000..ae82fb7
--- /dev/null
+++ b/lib/models/index.ts
@@ -0,0 +1,13 @@
+export * from './BaseModel.js';
+export * from './instance/ActivePunishment.js';
+export * from './instance/Guild.js';
+export * from './instance/Highlight.js';
+export * from './instance/Level.js';
+export * from './instance/ModLog.js';
+export * from './instance/Reminder.js';
+export * from './instance/StickyRole.js';
+export * from './shared/Global.js';
+export * from './shared/GuildCount.js';
+export * from './shared/MemberCount.js';
+export * from './shared/Shared.js';
+export * from './shared/Stat.js';
diff --git a/lib/models/instance/ActivePunishment.ts b/lib/models/instance/ActivePunishment.ts
index 38012ca..9bd9d01 100644
--- a/lib/models/instance/ActivePunishment.ts
+++ b/lib/models/instance/ActivePunishment.ts
@@ -1,8 +1,7 @@
import { type Snowflake } from 'discord.js';
import { nanoid } from 'nanoid';
-import { type Sequelize } from 'sequelize';
+import { DataTypes, type Sequelize } from 'sequelize';
import { BaseModel } from '../BaseModel.js';
-const { DataTypes } = (await import('sequelize')).default;
export enum ActivePunishmentType {
BAN = 'BAN',
diff --git a/lib/models/instance/Guild.ts b/lib/models/instance/Guild.ts
index f258d48..1d645e9 100644
--- a/lib/models/instance/Guild.ts
+++ b/lib/models/instance/Guild.ts
@@ -1,9 +1,9 @@
+import config from '#config';
import { ChannelType, Constants, type Snowflake } from 'discord.js';
-import { type Sequelize } from 'sequelize';
+import { DataTypes, type Sequelize } from 'sequelize';
import { BadWordDetails } from '../../automod/AutomodShared.js';
import { type BushClient } from '../../extensions/discord-akairo/BushClient.js';
import { BaseModel } from '../BaseModel.js';
-const { DataTypes } = (await import('sequelize')).default;
export interface GuildModel {
id: Snowflake;
@@ -199,8 +199,6 @@ const asGuildSetting = <T>(et: { [K in keyof T]: PartialBy<GuildSetting, 'config
return et as { [K in keyof T]: GuildSetting };
};