aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--.vscode/extensions.json19
-rw-r--r--.vscode/settings.json187
-rw-r--r--src/commands/dev/eval.ts6
-rw-r--r--src/commands/dev/reload.ts6
-rw-r--r--src/commands/dev/setLevel.ts4
-rw-r--r--src/commands/moderation/kick.ts4
-rw-r--r--src/commands/moderation/mute.ts20
-rw-r--r--src/commands/moderation/warn.ts4
-rw-r--r--src/lib/extensions/discord-akairo/BushArgumentOptions.ts59
-rw-r--r--src/lib/extensions/discord-akairo/BushClient.ts57
-rw-r--r--src/lib/extensions/discord-akairo/BushClientUtil.ts29
-rw-r--r--src/lib/extensions/discord-akairo/BushCommand.ts64
-rw-r--r--src/lib/extensions/discord-akairo/BushInhibitorHandler.ts (renamed from src/lib/extensions/discord-akairo/BushInhinitorHandler.ts)0
-rw-r--r--src/lib/extensions/discord-akairo/index.ts13
-rw-r--r--src/lib/extensions/discord.js/BushGuildMember.ts12
-rw-r--r--src/lib/extensions/discord.js/index.ts35
-rw-r--r--src/lib/extensions/index.ts3
-rw-r--r--src/lib/index.ts3
-rw-r--r--src/lib/utils/BushLogger.ts2
-rw-r--r--src/lib/utils/index.ts5
-rw-r--r--src/listeners/commands/commandError.ts19
-rw-r--r--src/listeners/commands/slashCommandError.ts19
-rw-r--r--src/listeners/message/level.ts2
-rw-r--r--src/listeners/other/consoleListener.ts40
-rw-r--r--src/listeners/other/promiseRejection.ts4
25 files changed, 329 insertions, 287 deletions
diff --git a/.vscode/extensions.json b/.vscode/extensions.json
index 82416ce..08b7552 100644
--- a/.vscode/extensions.json
+++ b/.vscode/extensions.json
@@ -1,11 +1,10 @@
-/* prettier-ignore */
-{
- "recommendations": [
- "aaron-bond.better-comments",
- "arcanis.vscode-zipfs",
- "dbaeumer.vscode-eslint",
- "eamodio.gitlens",
- "esbenp.prettier-vscode",
- "streetsidesoftware.code-spell-checker"
- ]
+/* prettier-ignore */{
+ "recommendations": [
+ "aaron-bond.better-comments",
+ "arcanis.vscode-zipfs",
+ "dbaeumer.vscode-eslint",
+ "eamodio.gitlens",
+ "esbenp.prettier-vscode",
+ "streetsidesoftware.code-spell-checker"
+ ]
}
diff --git a/.vscode/settings.json b/.vscode/settings.json
index 7f4c795..d8b509c 100644
--- a/.vscode/settings.json
+++ b/.vscode/settings.json
@@ -1,95 +1,94 @@
-/* prettier-ignore */
-{
- "files.exclude": {
- "**/.git": true,
- "**/.svn": true,
- "**/.hg": true,
- "**/CVS": true,
- "**/.DS_Store": true,
- "node_modules": true,
- "dist": true,
- ".pnp.js": true
- },
- "javascript.preferences.importModuleSpecifier": "project-relative",
- "typescript.preferences.importModuleSpecifier": "project-relative",
- "typescript.preferences.importModuleSpecifierEnding": "minimal",
- "search.exclude": {
- "**/.yarn": true,
- "**/.pnp.*": true
- },
- "editor.codeActionsOnSave": {
- "source.organizeImports": true,
- "source.fixAll.eslint": true,
- "source.format": true
- },
- "editor.formatOnSave": true,
- "diffEditor.wordWrap": "on",
- "editor.insertSpaces": false,
- "editor.wordWrap": "on",
- "editor.tabSize": 2,
- "prettier.configPath": "package.json",
- "prettier.prettierPath": ".yarn/sdks/prettier/index.js",
- "prettier.withNodeModules": true,
- "prettier.useEditorConfig": false,
- "eslint.nodePath": ".yarn/sdks",
- "typescript.tsdk": ".yarn/sdks/typescript/lib",
- "typescript.enablePromptUseWorkspaceTsdk": true,
- "better-comments.highlightPlainText": false,
- "better-comments.multilineComments": true,
- "better-comments.tags": [
- {
- "tag": "!",
- "color": "#FF2D00",
- "strikethrough": false,
- "underline": false,
- "backgroundColor": "transparent",
- "bold": false,
- "italic": false
- },
- {
- "tag": "?",
- "color": "#3498DB",
- "strikethrough": false,
- "underline": false,
- "backgroundColor": "transparent",
- "bold": false,
- "italic": false
- },
- {
- "tag": "#",
- "color": "#f003fc",
- "strikethrough": false,
- "underline": false,
- "backgroundColor": "transparent",
- "bold": false,
- "italic": false
- },
- {
- "tag": "//",
- "color": "#474747",
- "strikethrough": true,
- "underline": false,
- "backgroundColor": "transparent",
- "bold": false,
- "italic": false
- },
- {
- "tag": "todo",
- "color": "#FF8C00",
- "strikethrough": false,
- "underline": false,
- "backgroundColor": "transparent",
- "bold": false,
- "italic": false
- },
- {
- "tag": "*",
- "color": "#98C379",
- "strikethrough": false,
- "underline": false,
- "backgroundColor": "transparent",
- "bold": false,
- "italic": false
- }
- ]
+/* prettier-ignore */{
+ "files.exclude": {
+ "**/.git": true,
+ "**/.svn": true,
+ "**/.hg": true,
+ "**/CVS": true,
+ "**/.DS_Store": true,
+ "node_modules": true,
+ "dist": true,
+ ".pnp.js": true
+ },
+ "javascript.preferences.importModuleSpecifier": "project-relative",
+ "typescript.preferences.importModuleSpecifier": "project-relative",
+ "typescript.preferences.importModuleSpecifierEnding": "minimal",
+ "search.exclude": {
+ "**/.yarn": true,
+ "**/.pnp.*": true
+ },
+ "editor.codeActionsOnSave": {
+ "source.organizeImports": true,
+ "source.fixAll.eslint": true,
+ "source.format": true
+ },
+ "editor.formatOnSave": true,
+ "diffEditor.wordWrap": "on",
+ "editor.insertSpaces": false,
+ "editor.wordWrap": "on",
+ "editor.tabSize": 2,
+ "prettier.configPath": "package.json",
+ "prettier.prettierPath": ".yarn/sdks/prettier/index.js",
+ "prettier.withNodeModules": true,
+ "prettier.useEditorConfig": false,
+ "eslint.nodePath": ".yarn/sdks",
+ "typescript.tsdk": ".yarn/sdks/typescript/lib",
+ "typescript.enablePromptUseWorkspaceTsdk": true,
+ "better-comments.highlightPlainText": false,
+ "better-comments.multilineComments": true,
+ "better-comments.tags": [
+ {
+ "tag": "!",
+ "color": "#FF2D00",
+ "strikethrough": false,
+ "underline": false,
+ "backgroundColor": "transparent",
+ "bold": false,
+ "italic": false
+ },
+ {
+ "tag": "?",
+ "color": "#3498DB",
+ "strikethrough": false,
+ "underline": false,
+ "backgroundColor": "transparent",
+ "bold": false,
+ "italic": false
+ },
+ {
+ "tag": "#",
+ "color": "#f003fc",
+ "strikethrough": false,
+ "underline": false,
+ "backgroundColor": "transparent",
+ "bold": false,
+ "italic": false
+ },
+ {
+ "tag": "//",
+ "color": "#474747",
+ "strikethrough": true,
+ "underline": false,
+ "backgroundColor": "transparent",
+ "bold": false,
+ "italic": false
+ },
+ {
+ "tag": "todo",
+ "color": "#FF8C00",
+ "strikethrough": false,
+ "underline": false,
+ "backgroundColor": "transparent",
+ "bold": false,
+ "italic": false
+ },
+ {
+ "tag": "*",
+ "color": "#98C379",
+ "strikethrough": false,
+ "underline": false,
+ "backgroundColor": "transparent",
+ "bold": false,
+ "italic": false
+ }
+ ]
}
diff --git a/src/commands/dev/eval.ts b/src/commands/dev/eval.ts
index ebf055b..82b0e5e 100644
--- a/src/commands/dev/eval.ts
+++ b/src/commands/dev/eval.ts
@@ -1,3 +1,4 @@
+/* eslint-disable @typescript-eslint/no-var-requires */
/* eslint-disable @typescript-eslint/no-unused-vars */
import { exec } from 'child_process';
import { Constants } from 'discord-akairo';
@@ -198,7 +199,6 @@ export default class EvalCommand extends BushCommand {
MessageSelectMenu,
ReactionCollector,
Util
- // eslint-disable-next-line @typescript-eslint/no-var-requires
} = require('discord.js'); // I would use import here but esbuild doesn't like that
if (code[code.lang].replace(/ /g, '').includes('9+10' || '10+9')) {
output = 21;
@@ -259,7 +259,7 @@ export default class EvalCommand extends BushCommand {
} else {
embed.addField('📥 Input', await this.client.util.codeblock(inputJS, 1024, 'js'));
}
- embed.addField('📤 Output', await this.client.util.codeblock(typeof e === 'object' ? e?.stack : e, 1024, 'js'));
+ embed.addField('📤 Output', await this.client.util.codeblock(e?.stack || e, 1024, 'js'));
}
if (!args.silent && !message.util.isSlash) {
await message.util.reply({ embeds: [embed], ephemeral: args.silent });
@@ -269,7 +269,7 @@ export default class EvalCommand extends BushCommand {
try {
await message.author.send({ embeds: [embed] });
if (!args.deleteMSG) await (message as BushMessage).react(this.client.util.emojis.successFull);
- } catch (e) {
+ } catch {
if (!args.deleteMSG) await (message as BushMessage).react(this.client.util.emojis.errorFull);
}
}
diff --git a/src/commands/dev/reload.ts b/src/commands/dev/reload.ts
index 4a69098..fdb669f 100644
--- a/src/commands/dev/reload.ts
+++ b/src/commands/dev/reload.ts
@@ -46,11 +46,7 @@ export default class ReloadCommand extends BushCommand {
return message.util.send(`🔁 Successfully reloaded! (${new Date().getTime() - s.getTime()}ms)`);
} catch (e) {
return message.util.send(
- `An error occurred while reloading:\n${await this.client.util.codeblock(
- typeof e === 'object' ? e?.stack : e,
- 2048 - 34,
- 'js'
- )}`
+ `An error occurred while reloading:\n${await this.client.util.codeblock(e?.stack || e, 2048 - 34, 'js')}`
);
}
}
diff --git a/src/commands/dev/setLevel.ts b/src/commands/dev/setLevel.ts
index 2a807f8..871a9de 100644
--- a/src/commands/dev/setLevel.ts
+++ b/src/commands/dev/setLevel.ts
@@ -36,13 +36,13 @@ export default class SetLevelCommand extends BushCommand {
ownerOnly: true,
slashOptions: [
{
- type: /* 'USER' */ 'USER',
+ type: 'USER',
name: 'user',
description: 'The user to change the level of',
required: true
},
{
- type: /* 'INTEGER' */ 'INTEGER',
+ type: 'INTEGER',
name: 'level',
description: 'The level to set the user to',
required: true
diff --git a/src/commands/moderation/kick.ts b/src/commands/moderation/kick.ts
index f88819b..f8bb5a1 100644
--- a/src/commands/moderation/kick.ts
+++ b/src/commands/moderation/kick.ts
@@ -76,13 +76,13 @@ export default class KickCommand extends BushCommand {
// });
// await modlogEnry.save();
// } catch (e) {
- // this.client.console.error(`KickCommand`, `Error saving to database. ${typeof e === 'object' ? e?.stack : e}`);
+ // this.client.console.error(`KickCommand`, `Error saving to database. ${e?.stack || e}`);
// yield `${this.client.util.emojis.error} Error saving to database. Please report this to a developer.`;
// return;
// }
// try {
// await user.send(`You were kicked in ${message.guild.name} with reason \`${reason || 'No reason given'}\``);
- // } catch (e) {
+ // } catch {
// yield `${this.client.util.emojis.warn} Unable to dm user`;
// }
// try {
diff --git a/src/commands/moderation/mute.ts b/src/commands/moderation/mute.ts
index 8ac77a7..5e5cdba 100644
--- a/src/commands/moderation/mute.ts
+++ b/src/commands/moderation/mute.ts
@@ -9,6 +9,11 @@ export default class MuteCommand extends BushCommand {
super('mute', {
aliases: ['mute'],
category: 'moderation',
+ description: {
+ content: 'Mute a user.',
+ usage: 'mute <member> <reason> [--time]',
+ examples: ['mute @user bad boi --time 1h']
+ },
args: [
{
id: 'user',
@@ -23,30 +28,25 @@ export default class MuteCommand extends BushCommand {
type: 'contentWithDuration',
match: 'rest',
prompt: {
- start: 'Why would you like to mute this user?',
- retry: '{error} Choose a mute reason and duration.',
+ start: 'Why should this user be muted and for how long?',
+ retry: '{error} Choose a valid mute reason and duration.',
optional: true
}
}
],
clientPermissions: ['MANAGE_ROLES'],
userPermissions: ['MANAGE_MESSAGES'],
- description: {
- content: 'Mute a user.',
- usage: 'mute <member> <reason> [--time]',
- examples: ['mute @user bad boi --time 1h']
- },
slashOptions: [
{
type: 'USER',
name: 'user',
- description: 'The user to mute.',
+ description: 'What user would you like to mute?',
required: true
},
{
type: 'STRING',
name: 'reason',
- description: 'Why is the user is getting muted, and how long should they be muted for?',
+ description: 'Why should this user be muted and for how long?',
required: false
}
],
@@ -76,7 +76,7 @@ export default class MuteCommand extends BushCommand {
return message.util.reply(`${error} You cannot mute yourself.`);
}
- let time;
+ let time: number;
if (reason) {
time =
typeof reason === 'string'
diff --git a/src/commands/moderation/warn.ts b/src/commands/moderation/warn.ts
index d70c9f0..9df5891 100644
--- a/src/commands/moderation/warn.ts
+++ b/src/commands/moderation/warn.ts
@@ -47,13 +47,13 @@ export default class WarnCommand extends BushCommand {
reason
});
await entry.save();
- } catch (e) {
+ } catch {
await message.util.send('Error saving to database, please contact the developers');
return;
}
try {
await member.send(`You were warned in ${message.guild.name} for reason "${reason}".`);
- } catch (e) {
+ } catch {
await message.util.send('Error messaging user, warning still saved.');
return;
}
diff --git a/src/lib/extensions/discord-akairo/BushArgumentOptions.ts b/src/lib/extensions/discord-akairo/BushArgumentOptions.ts
deleted file mode 100644
index bbbc04b..0000000
--- a/src/lib/extensions/discord-akairo/BushArgumentOptions.ts
+++ /dev/null
@@ -1,59 +0,0 @@
-import { ArgumentOptions, ArgumentTypeCaster } from 'discord-akairo';
-
-type BushArgumentType =
- | 'string'
- | 'lowercase'
- | 'uppercase'
- | 'charCodes'
- | 'number'
- | 'integer'
- | 'bigint'
- | 'emojint'
- | 'url'
- | 'date'
- | 'color'
- | 'user'
- | 'users'
- | 'member'
- | 'members'
- | 'relevant'
- | 'relevants'
- | 'channel'
- | 'channels'
- | 'textChannel'
- | 'textChannels'
- | 'voiceChannel'
- | 'voiceChannels'
- | 'categoryChannel'
- | 'categoryChannels'
- | 'newsChannel'
- | 'newsChannels'
- | 'storeChannel'
- | 'storeChannels'
- | 'role'
- | 'roles'
- | 'emoji'
- | 'emojis'
- | 'guild'
- | 'guilds'
- | 'message'
- | 'guildMessage'
- | 'relevantMessage'
- | 'invite'
- | 'userMention'
- | 'memberMention'
- | 'channelMention'
- | 'roleMention'
- | 'emojiMention'
- | 'commandAlias'
- | 'command'
- | 'inhibitor'
- | 'listener'
- | 'duration'
- | (string | string[])[]
- | RegExp
- | string;
-
-export interface BushArgumentOptions extends ArgumentOptions {
- type?: BushArgumentType | ArgumentTypeCaster;
-}
diff --git a/src/lib/extensions/discord-akairo/BushClient.ts b/src/lib/extensions/discord-akairo/BushClient.ts
index ed5c90a..b7441bf 100644
--- a/src/lib/extensions/discord-akairo/BushClient.ts
+++ b/src/lib/extensions/discord-akairo/BushClient.ts
@@ -15,6 +15,29 @@ import * as path from 'path';
import { exit } from 'process';
import readline from 'readline';
import { Sequelize } from 'sequelize';
+import { BushClientUtil, BushCommandHandler, BushInhibitorHandler, BushListenerHandler, BushTaskHandler } from '.';
+import {
+ BushButtonInteraction,
+ BushCategoryChannel,
+ BushCommandInteraction,
+ BushDMChannel,
+ BushGuild,
+ BushGuildEmoji,
+ BushGuildMember,
+ BushMessage,
+ BushMessageReaction,
+ BushNewsChannel,
+ BushPresence,
+ BushRole,
+ BushSelectMenuInteraction,
+ BushStoreChannel,
+ BushTextChannel,
+ BushThreadChannel,
+ BushThreadMember,
+ BushUser,
+ BushVoiceChannel,
+ BushVoiceState
+} from '../';
import { contentWithDurationTypeCaster } from '../../../arguments/contentWithDuration';
import { durationTypeCaster } from '../../../arguments/duration';
import * as config from '../../../config/options';
@@ -24,31 +47,6 @@ 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 './BushInhinitorHandler';
-import { BushListenerHandler } from './BushListenerHandler';
-import { BushTaskHandler } from './BushTaskHandler';
export type BotConfig = typeof config;
export type BushReplyMessageType = string | MessagePayload | ReplyMessageOptions;
@@ -57,6 +55,7 @@ export type BushSendMessageType = string | MessagePayload | MessageOptions;
export type BushThreadMemberResolvable = BushThreadMember | BushUserResolvable;
export type BushUserResolvable = BushUser | Snowflake | BushMessage | BushGuildMember | BushThreadMember;
export type BushGuildMemberResolvable = BushGuildMember | BushUserResolvable;
+export type BushRoleResolvable = BushRole | Snowflake;
const rl = readline.createInterface({
input: process.stdin,
@@ -216,11 +215,7 @@ export class BushClient extends AkairoClient {
loaders[loader].loadAll();
await this.logger.success('Startup', `Successfully loaded <<${loader}>>.`, false);
} catch (e) {
- await this.logger.error(
- 'Startup',
- `Unable to load loader <<${loader}>> with error:\n${typeof e === 'object' ? e?.stack : e}`,
- false
- );
+ await this.logger.error('Startup', `Unable to load loader <<${loader}>> with error:\n${e?.stack || e}`, false);
}
}
await this.dbPreInit();
@@ -258,7 +253,7 @@ export class BushClient extends AkairoClient {
await this._init();
await this.login(this.token);
} catch (e) {
- await this.console.error('Start', chalk.red(e.stack), false);
+ await this.console.error('Start', chalk.red(e?.stack || e), false);
exit(2);
}
}
diff --git a/src/lib/extensions/discord-akairo/BushClientUtil.ts b/src/lib/extensions/discord-akairo/BushClientUtil.ts
index 5a22efc..126ed90 100644
--- a/src/lib/extensions/discord-akairo/BushClientUtil.ts
+++ b/src/lib/extensions/discord-akairo/BushClientUtil.ts
@@ -153,7 +153,7 @@ export class BushClientUtil extends ClientUtil {
try {
const res: hastebinRes = await got.post(`${url}/documents`, { body: content }).json();
return `${url}/${res.key}`;
- } catch (e) {
+ } catch {
this.client.console.error('Haste', `Unable to upload haste to ${url}`);
}
}
@@ -512,7 +512,7 @@ export class BushClientUtil extends ClientUtil {
}
row[key] = newValue;
this.client.cache.global[key] = newValue;
- return await row.save().catch((e) => this.client.logger.error('insertOrRemoveFromGlobal', e));
+ return await row.save().catch((e) => this.client.logger.error('insertOrRemoveFromGlobal', e?.stack || e));
}
/**
@@ -543,25 +543,12 @@ export class BushClientUtil extends ClientUtil {
const regex = BushConstants.TimeUnits[unit].match;
const match = regex.exec(contentWithoutTime);
const value = Number(match?.groups?.[unit] || 0);
- // this.client.console.debug(unit + ': ' + value);
duration += value * BushConstants.TimeUnits[unit].value;
if (remove) contentWithoutTime = contentWithoutTime.replace(regex, '');
- // this.client.console.debug(contentWithoutTime);
}
- //^(?:(?<years>-?(?:\d+)?\.?\d+) *(?:years?|y))?\s*(?:(?<months>-?(?:\d+)?\.?\d+) *(?:months?|mon|mo?))?\s*(?:(?<weeks>-?(?:\d+)?\.?\d+) *(?:weeks?|w))?\s*(?:(?<days>-?(?:\d+)?\.?\d+) *(?:days?|d))?\s*(?:(?<hours>-?(?:\d+)?\.?\d+) *(?:hours?|hrs?|h))?\s*(?:(?<minutes>-?(?:\d+)?\\.?\\d+) *(?:minutes?|mins?))?\s*(?:(?<seconds>-?(?:\d+)?\\.?\d+) *(?:seconds?|secs?|s))?\s*(?:(?<milliseconds>-?(?:\d+)?\.?\d+) *(?:milliseconds?|msecs?|ms))?$
- // const regexString = Object.entries(BushConstants.TimeUnits)
- // .map(([name, { label }]) => String.raw`(?: (?<${name}>-?(?:\d+)?\.?\d+) *${label})`)
- // .join(' |');
- // const match = new RegExp(`^${regexString}$`, 'img').exec(' ' + content + ' ');
- // if (!match) return null;
- // console.
- // const contentWithoutTime = content.replace(new RegExp(`^${regexString}$`, 'img'), '');
- // for (const key in match.groups) {
- // const value = Number(match.groups[key] || 0);
- // duration += value * BushConstants.TimeUnits[key].value;
- // }
-
+ // remove the space added earlier
+ if (contentWithoutTime.startsWith(' ')) contentWithoutTime.replace(' ', '');
return { duration, contentWithoutTime };
}
@@ -616,8 +603,8 @@ export class BushClientUtil extends ClientUtil {
duration: duration,
guild
});
- return modLogEntry.save().catch((err) => {
- this.client.console.error('createModLogEntry', err);
+ return modLogEntry.save().catch((e) => {
+ this.client.console.error('createModLogEntry', e?.stack || e);
return null;
});
}
@@ -649,8 +636,8 @@ export class BushClientUtil extends ClientUtil {
const guild = this.client.guilds.resolveID(options.guild);
const entry = dbModel.build({ user, guild, expires, modlog: options.modlog });
- return await entry.save().catch((err) => {
- this.client.console.error('createPunishmentEntry', err);
+ return await entry.save().catch((e) => {
+ this.client.console.error('createPunishmentEntry', e?.stack || e);
return null;
});
}
diff --git a/src/lib/extensions/discord-akairo/BushCommand.ts b/src/lib/extensions/discord-akairo/BushCommand.ts
index 101c9d3..90c68df 100644
--- a/src/lib/extensions/discord-akairo/BushCommand.ts
+++ b/src/lib/extensions/discord-akairo/BushCommand.ts
@@ -1,13 +1,75 @@
/* eslint-disable @typescript-eslint/explicit-module-boundary-types */
/* eslint-disable @typescript-eslint/no-explicit-any */
-import { ArgumentGenerator, ArgumentOptions, ArgumentPromptOptions, Command, CommandOptions } from 'discord-akairo';
+import {
+ ArgumentGenerator,
+ ArgumentOptions,
+ ArgumentPromptOptions,
+ ArgumentTypeCaster,
+ Command,
+ CommandOptions
+} from 'discord-akairo';
import { Snowflake } from 'discord.js';
import { BushMessage } from '../discord.js/BushMessage';
import { BushClient } from './BushClient';
import { BushCommandHandler } from './BushCommandHandler';
import { BushSlashMessage } from './BushSlashMessage';
+type BushArgumentType =
+ | 'string'
+ | 'lowercase'
+ | 'uppercase'
+ | 'charCodes'
+ | 'number'
+ | 'integer'
+ | 'bigint'
+ | 'emojint'
+ | 'url'
+ | 'date'
+ | 'color'
+ | 'user'
+ | 'users'
+ | 'member'
+ | 'members'
+ | 'relevant'
+ | 'relevants'
+ | 'channel'
+ | 'channels'
+ | 'textChannel'
+ | 'textChannels'
+ | 'voiceChannel'
+ | 'voiceChannels'
+ | 'categoryChannel'
+ | 'categoryChannels'
+ | 'newsChannel'
+ | 'newsChannels'
+ | 'storeChannel'
+ | 'storeChannels'
+ | 'role'
+ | 'roles'
+ | 'emoji'
+ | 'emojis'
+ | 'guild'
+ | 'guilds'
+ | 'message'
+ | 'guildMessage'
+ | 'relevantMessage'
+ | 'invite'
+ | 'userMention'
+ | 'memberMention'
+ | 'channelMention'
+ | 'roleMention'
+ | 'emojiMention'
+ | 'commandAlias'
+ | 'command'
+ | 'inhibitor'
+ | 'listener'
+ | 'duration'
+ | (string | string[])[]
+ | RegExp
+ | string;
+
export interface BushArgumentOptions extends ArgumentOptions {
+ type?: BushArgumentType | ArgumentTypeCaster;
id: string;
description?: string;
prompt?: ArgumentPromptOptions;
diff --git a/src/lib/extensions/discord-akairo/BushInhinitorHandler.ts b/src/lib/extensions/discord-akairo/BushInhibitorHandler.ts
index 2a947da..2a947da 100644
--- a/src/lib/extensions/discord-akairo/BushInhinitorHandler.ts
+++ b/src/lib/extensions/discord-akairo/BushInhibitorHandler.ts
diff --git a/src/lib/extensions/discord-akairo/index.ts b/src/lib/extensions/discord-akairo/index.ts
new file mode 100644
index 0000000..fd92de2
--- /dev/null
+++ b/src/lib/extensions/discord-akairo/index.ts
@@ -0,0 +1,13 @@
+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';
diff --git a/src/lib/extensions/discord.js/BushGuildMember.ts b/src/lib/extensions/discord.js/BushGuildMember.ts
index 2fefcdd..7a63012 100644
--- a/src/lib/extensions/discord.js/BushGuildMember.ts
+++ b/src/lib/extensions/discord.js/BushGuildMember.ts
@@ -1,5 +1,5 @@
/* eslint-disable @typescript-eslint/no-unused-vars */
-import { GuildMember } from 'discord.js';
+import { GuildMember, RoleResolvable } from 'discord.js';
import { ModLogType } from '../../models';
import { BushClient, BushUserResolvable } from '../discord-akairo/BushClient';
import { BushGuild } from './BushGuild';
@@ -14,10 +14,16 @@ interface BushTimedPunishmentOptions extends BushPunishmentOptions {
duration?: number;
}
+interface BushPunishmentRoleOptions extends BushTimedPunishmentOptions {
+ role: RoleResolvable;
+}
+
type PunishmentResponse = 'success';
type WarnResponse = PunishmentResponse;
+type PunishmentRoleResponse = PunishmentResponse;
+
type MuteResponse =
| PunishmentResponse
| 'missing permissions'
@@ -52,6 +58,10 @@ export class BushGuildMember extends GuildMember {
throw 'not implemented';
}
+ public punishRole(options: BushPunishmentRoleOptions): Promise<PunishmentRoleResponse> {
+ throw 'not implemented';
+ }
+
public async mute(options: BushTimedPunishmentOptions): Promise<MuteResponse> {
//checks
if (!this.guild.me.permissions.has('MANAGE_ROLES')) return 'missing permissions';
diff --git a/src/lib/extensions/discord.js/index.ts b/src/lib/extensions/discord.js/index.ts
new file mode 100644
index 0000000..766500d
--- /dev/null
+++ b/src/lib/extensions/discord.js/index.ts
@@ -0,0 +1,35 @@
+export * from './BushActivity';
+export * from './BushApplicationCommand';
+export * from './BushApplicationCommandManager';
+export * from './BushApplicationCommandPermissionsManager';
+export * from './BushButtonInteraction';
+export * from './BushCategoryChannel';
+export * from './BushCommandInteraction';
+export * from './BushDMChannel';
+export * from './BushEmoji';
+export * from './BushGuild';
+export * from './BushGuildApplicationCommandManager';
+export * from './BushGuildChannel';
+export * from './BushGuildEmoji';
+export * from './BushGuildEmojiRoleManager';
+export * from './BushGuildMember';
+// export * from './BushGuildMemberManager';
+export * from './BushMessage';
+export * from './BushMessageManager';
+export * from './BushMessageReaction';
+export * from './BushNewsChannel';
+export * from './BushPresence';
+export * from './BushReactionEmoji';
+export * from './BushRole';
+export * from './BushSelectMenuInteraction';
+export * from './BushStageChannel';
+export * from './BushStageInstance';
+export * from './BushStoreChannel';
+export * from './BushTextChannel';
+export * from './BushThreadChannel';
+export * from './BushThreadManager';
+export * from './BushThreadMember';
+export * from './BushThreadMemberManager';
+export * from './BushUser';
+export * from './BushVoiceChannel';
+export * from './BushVoiceState';
diff --git a/src/lib/extensions/index.ts b/src/lib/extensions/index.ts
new file mode 100644
index 0000000..318adcc
--- /dev/null
+++ b/src/lib/extensions/index.ts
@@ -0,0 +1,3 @@
+export * from './discord-akairo/index';
+export * from './discord.js/index';
+export * from './global';
diff --git a/src/lib/index.ts b/src/lib/index.ts
new file mode 100644
index 0000000..6a1433c
--- /dev/null
+++ b/src/lib/index.ts
@@ -0,0 +1,3 @@
+export * from './extensions';
+export * from './models';
+export * from './utils';
diff --git a/src/lib/utils/BushLogger.ts b/src/lib/utils/BushLogger.ts
index 915d8f1..184b100 100644
--- a/src/lib/utils/BushLogger.ts
+++ b/src/lib/utils/BushLogger.ts
@@ -3,7 +3,7 @@
import chalk from 'chalk';
import { MessageEmbed } from 'discord.js';
import { inspect } from 'util';
-import { BushClient, BushSendMessageType } from '../extensions/discord-akairo/BushClient';
+import { BushClient, BushSendMessageType } from '..';
export class BushLogger {
private client: BushClient;
diff --git a/src/lib/utils/index.ts b/src/lib/utils/index.ts
new file mode 100644
index 0000000..b0319e5
--- /dev/null
+++ b/src/lib/utils/index.ts
@@ -0,0 +1,5 @@
+export * from './AllowedMentions';
+export * from './BushCache';
+export * from './BushConstants';
+export * from './BushLogger';
+export * from './CanvasProgressBar';
diff --git a/src/listeners/commands/commandError.ts b/src/listeners/commands/commandError.ts
index 20132dd..d80a2bc 100644
--- a/src/listeners/commands/commandError.ts
+++ b/src/listeners/commands/commandError.ts
@@ -22,7 +22,7 @@ export default class CommandErrorListener extends BushListener {
**Channel:** ${message.channel} (${message.channel?.id})
**Message:** [link](${message.url})`
)
- .addField('Error', await this.client.util.codeblock(`${typeof error === 'object' ? error?.stack : error}`, 1024, 'js'))
+ .addField('Error', await this.client.util.codeblock(`${error?.stack || error}`, 1024, 'js'))
.setColor(this.client.util.colors.error)
.setTimestamp();
@@ -41,23 +41,17 @@ export default class CommandErrorListener extends BushListener {
);
await message.util.send({ embeds: [errorUserEmbed] }).catch((e) => {
const channel = message.channel.type === 'dm' ? message.channel.recipient.tag : message.channel.name;
- this.client.console.warn(
- 'CommandError',
- `Failed to send user error embed in <<${channel}>>:\n` + typeof e === 'object' ? e?.stack : e
- );
+ this.client.console.warn('CommandError', `Failed to send user error embed in <<${channel}>>:\n` + e?.stack || e);
});
} else {
const errorDevEmbed = new MessageEmbed()
.setTitle('A Command Error Occurred')
.setColor(this.client.util.colors.error)
.setTimestamp()
- .setDescription(await this.client.util.codeblock(`${error?.stack}`, 2048, 'js'));
+ .setDescription(await this.client.util.codeblock(`${error?.stack || error}`, 2048, 'js'));
await message.util.send({ embeds: [errorDevEmbed] }).catch((e) => {
const channel = message.channel.type === 'dm' ? message.channel.recipient.tag : message.channel.name;
- this.client.console.warn(
- 'CommandError',
- `Failed to send owner error stack in <<${channel}>>.` + typeof e === 'object' ? e?.stack : e
- );
+ this.client.console.warn('CommandError', `Failed to send owner error stack in <<${channel}>>.` + e?.stack || e);
});
}
}
@@ -65,10 +59,7 @@ export default class CommandErrorListener extends BushListener {
this.client.console.error(
'CommandError',
`an error occurred with the <<${command}>> command in <<${channel}>> triggered by <<${message?.author?.tag}>>:\n` +
- typeof error ===
- 'object'
- ? error?.stack
- : error,
+ error?.stack || error,
false
);
}
diff --git a/src/listeners/commands/slashCommandError.ts b/src/listeners/commands/slashCommandError.ts
index b172670..6bbb462 100644
--- a/src/listeners/commands/slashCommandError.ts
+++ b/src/listeners/commands/slashCommandError.ts
@@ -21,7 +21,7 @@ export default class SlashCommandErrorListener extends BushListener {
**Channel:** ${message.channel || message.interaction.user?.tag} ${message.channel ? `(${message.channel?.id})` : ''}
**Message:** [link](https://discord.com/${message.guild?.id}/${message.channel?.id}/${message.id})`
)
- .addField('Error', await this.client.util.codeblock(`${typeof error === 'object' ? error?.stack : error}`, 1024, 'js'))
+ .addField('Error', await this.client.util.codeblock(`${error?.stack || error}`, 1024, 'js'))
.setColor(this.client.util.colors.error)
.setTimestamp();
@@ -40,22 +40,16 @@ export default class SlashCommandErrorListener extends BushListener {
`Oh no! While running the command \`${command.id}\`, an error occurred. Please give the developers code \`${errorNo}\`.`
);
await message.util.send({ embeds: [errorUserEmbed] }).catch((e) => {
- this.client.console.warn(
- 'SlashError',
- `Failed to send user error embed in <<${channel}>>:\n` + typeof e === 'object' ? e?.stack : e
- );
+ this.client.console.warn('SlashError', `Failed to send user error embed in <<${channel}>>:\n` + e?.stack || e);
});
} else {
const errorDevEmbed = new MessageEmbed()
.setTitle('A Slash Command Error Occurred')
.setColor(this.client.util.colors.error)
.setTimestamp()
- .setDescription(await this.client.util.codeblock(`${error?.stack}`, 2048, 'js'));
+ .setDescription(await this.client.util.codeblock(`${error?.stack || error}`, 2048, 'js'));
await message.util.send({ embeds: [errorDevEmbed] }).catch((e) => {
- this.client.console.warn(
- 'SlashError',
- `Failed to send owner error stack in <<${channel}>>.` + typeof e === 'object' ? e?.stack : e
- );
+ this.client.console.warn('SlashError', `Failed to send owner error stack in <<${channel}>>.` + e?.stack || e);
});
}
}
@@ -63,10 +57,7 @@ export default class SlashCommandErrorListener extends BushListener {
this.client.console.error(
'SlashError',
`an error occurred with the <<${command}>> command in <<${channel}>> triggered by <<${message?.author?.tag}>>:\n` +
- typeof error ===
- 'object'
- ? error?.stack
- : error,
+ error?.stack || error,
false
);
}
diff --git a/src/listeners/message/level.ts b/src/listeners/message/level.ts
index 1d8d5e6..08ac933 100644
--- a/src/listeners/message/level.ts
+++ b/src/listeners/message/level.ts
@@ -29,7 +29,7 @@ export default class LevelListener extends BushListener {
const xpToGive = Level.genRandomizedXp();
user.xp += xpToGive;
const success = await user.save().catch((e) => {
- this.client.logger.error('LevelMessageListener', e);
+ this.client.logger.error('LevelMessageListener', e?.stack || e);
return false;
});
if (success) this.client.logger.verbose(`LevelMessageListener`, `Gave <<${xpToGive}>> XP to <<${message.author.tag}>>.`);
diff --git a/src/listeners/other/consoleListener.ts b/src/listeners/other/consoleListener.ts
index 98f44e2..b3d30ad 100644
--- a/src/listeners/other/consoleListener.ts
+++ b/src/listeners/other/consoleListener.ts
@@ -1,3 +1,4 @@
+/* eslint-disable @typescript-eslint/no-var-requires */
/* eslint-disable @typescript-eslint/no-unused-vars */
import { BushListener } from '../../lib/extensions/discord-akairo/BushListener';
@@ -10,26 +11,37 @@ export default class ConsoleListener extends BushListener {
}
public async exec(line: string): Promise<void> {
- const bot = this.client;
- if (line.startsWith('eval ')) {
+ if (line.startsWith('eval ') || line.startsWith('ev ')) {
+ const bot = this.client,
+ config = this.client.config,
+ client = this.client,
+ { Ban, Global, Guild, Level, ModLog, StickyRole } = await import('../../lib/models/index.js'),
+ {
+ ButtonInteraction,
+ Collector,
+ CommandInteraction,
+ Interaction,
+ Message,
+ MessageActionRow,
+ MessageAttachment,
+ MessageButton,
+ MessageCollector,
+ MessageComponentInteractionCollector,
+ MessageEmbed,
+ MessageSelectMenu,
+ ReactionCollector,
+ Util
+ } = require('discord.js');
try {
- const input = line.replace('eval ', '');
+ const input = line.replace('eval ', '').replace('ev ', '');
let output = eval(input);
output = await output;
console.log(output);
} catch (e) {
- console.error(e);
- }
- }
- if (line.startsWith('ev ')) {
- try {
- const input = line.replace('ev ', '');
- let output = eval(input);
- output = await output;
- console.log(output);
- } catch (e) {
- console.error(e);
+ console.error(e?.stack || e);
}
+ } else if (line.startsWith('stop')) {
+ process.exit(0);
}
}
}
diff --git a/src/listeners/other/promiseRejection.ts b/src/listeners/other/promiseRejection.ts
index 06a8e1e..228c65d 100644
--- a/src/listeners/other/promiseRejection.ts
+++ b/src/listeners/other/promiseRejection.ts
@@ -9,12 +9,12 @@ export default class PromiseRejectionListener extends BushListener {
}
public async exec(error: Error): Promise<void> {
- this.client.console.error('PromiseRejection', 'An unhanded promise rejection occurred:\n' + error.stack, false);
+ this.client.console.error('PromiseRejection', `An unhanded promise rejection occurred:\n${error?.stack || error}`, false);
this.client.console.channelError({
embeds: [
{
title: 'Unhandled promise rejection',
- fields: [{ name: 'error', value: await this.client.util.codeblock(error.stack, 1024, 'js') }],
+ fields: [{ name: 'error', value: await this.client.util.codeblock(`${error?.stack || error}`, 1024, 'js') }],
color: this.client.util.colors.error
}
]