aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--.gitignore3
-rw-r--r--.vscode/extensions.json6
-rw-r--r--ecosystem.config.js16
-rw-r--r--package.json1
-rw-r--r--src/bot.ts4
-rw-r--r--src/commands/dev/eval.ts (renamed from src/commands/owner/eval.ts)61
-rw-r--r--src/commands/dev/reload.ts (renamed from src/commands/owner/reload.ts)5
-rw-r--r--src/commands/dev/setLevel.ts (renamed from src/commands/owner/setlevel.ts)23
-rw-r--r--src/commands/info/botInfo.ts (renamed from src/commands/info/botinfo.ts)26
-rw-r--r--src/commands/info/help.ts52
-rw-r--r--src/commands/info/ping.ts35
-rw-r--r--src/commands/info/pronouns.ts6
-rw-r--r--src/commands/moderation/ban.ts84
-rw-r--r--src/commands/moderation/kick.ts40
-rw-r--r--src/commands/moderation/modlog.ts26
-rw-r--r--src/commands/moderation/role.ts112
-rw-r--r--src/commands/moderation/warn.ts22
-rw-r--r--src/commands/moulberry-bush/capePerms.ts (renamed from src/commands/moulberry-bush/capeperms.ts)34
-rw-r--r--src/commands/moulberry-bush/giveawayPing.ts (renamed from src/commands/moulberry-bush/giveawayping.ts)34
-rw-r--r--src/commands/moulberry-bush/level.ts8
-rw-r--r--src/commands/moulberry-bush/rule.ts67
-rw-r--r--src/commands/server-config/prefix.ts (renamed from src/commands/admin/prefix.ts)28
-rw-r--r--src/config/example-options.ts7
-rw-r--r--src/inhibitors/blacklist/blacklist.ts (renamed from src/inhibitors/blacklist/BlacklistInhibitor.ts)4
-rw-r--r--src/lib/extensions/BotInhibitor.ts6
-rw-r--r--src/lib/extensions/BotListener.ts6
-rw-r--r--src/lib/extensions/BotTask.ts6
-rw-r--r--src/lib/extensions/BushClient.ts (renamed from src/lib/extensions/BotClient.ts)37
-rw-r--r--src/lib/extensions/BushCommand.ts (renamed from src/lib/extensions/BotCommand.ts)10
-rw-r--r--src/lib/extensions/BushInhibitor.ts6
-rw-r--r--src/lib/extensions/BushListener.ts6
-rw-r--r--src/lib/extensions/BushTask.ts6
-rw-r--r--src/lib/extensions/Util.ts37
-rw-r--r--src/lib/models/Ban.ts5
-rw-r--r--src/lib/models/Guild.ts9
-rw-r--r--src/lib/models/Modlog.ts14
-rw-r--r--src/lib/utils/AllowedMentions.ts6
-rw-r--r--src/lib/utils/Console.ts93
-rw-r--r--src/lib/utils/Logger.ts12
-rw-r--r--src/listeners/client/ready.ts9
-rw-r--r--src/listeners/client/syncSlashCommands.ts (renamed from src/listeners/client/syncslashcommands.ts)6
-rw-r--r--src/listeners/commands/commandBlocked.ts (renamed from src/listeners/commands/commandblocked.ts)14
-rw-r--r--src/listeners/commands/commandError.ts (renamed from src/listeners/commands/error.ts)16
-rw-r--r--src/listeners/commands/commandStarted.ts20
-rw-r--r--src/listeners/commands/commandstarted.ts24
-rw-r--r--src/listeners/commands/slashCommandError.ts (renamed from src/listeners/commands/slashError.ts)16
-rw-r--r--src/listeners/guild/syncUnban.ts (renamed from src/listeners/guild/syncunban.ts)4
-rw-r--r--src/listeners/message/level.ts (renamed from src/listeners/message/levels.ts)12
-rw-r--r--src/tasks/unban.ts (renamed from src/tasks/Unban.ts)13
-rw-r--r--tsconfig.json9
50 files changed, 411 insertions, 695 deletions
diff --git a/.gitignore b/.gitignore
index d494511..7db86d9 100644
--- a/.gitignore
+++ b/.gitignore
@@ -256,5 +256,6 @@ src/config/options.ts
# Unused sqlite database, uses postgresql now but I am keeping it in here just in case
data.db
-
+# IRONM00N's Crap
src/config/options_old.ts
+src/config/options_pi.ts
diff --git a/.vscode/extensions.json b/.vscode/extensions.json
index 1fcdf78..5c4d931 100644
--- a/.vscode/extensions.json
+++ b/.vscode/extensions.json
@@ -1,7 +1,3 @@
{
- "recommendations": [
- "arcanis.vscode-zipfs",
- "dbaeumer.vscode-eslint",
- "esbenp.prettier-vscode"
- ]
+ "recommendations": ["arcanis.vscode-zipfs", "dbaeumer.vscode-eslint", "esbenp.prettier-vscode"]
}
diff --git a/ecosystem.config.js b/ecosystem.config.js
new file mode 100644
index 0000000..2e4b063
--- /dev/null
+++ b/ecosystem.config.js
@@ -0,0 +1,16 @@
+module.exports = {
+ apps: [
+ {
+ name: 'BushBot-Dev',
+ script: 'yarn',
+ args: 'start',
+ out_file: './combined-dev.log',
+ error_file: './combined-dev.log',
+ max_memory_restart: '2000M',
+ node_args: ['--max_old_space_size=2048'],
+ env: {
+ FORCE_COLOR: '3'
+ }
+ }
+ ]
+};
diff --git a/package.json b/package.json
index 3d2ae60..34d8580 100644
--- a/package.json
+++ b/package.json
@@ -70,6 +70,7 @@
]
},
"prettier": {
+ "printWidth": 170,
"useTabs": true,
"quoteProps": "consistent",
"singleQuote": true,
diff --git a/src/bot.ts b/src/bot.ts
index a7b555c..ee7ce92 100644
--- a/src/bot.ts
+++ b/src/bot.ts
@@ -1,5 +1,5 @@
-import { BotClient } from './lib/extensions/BotClient';
+import { BushClient } from './lib/extensions/BushClient';
import * as config from './config/options';
-const client: BotClient = new BotClient(config);
+const client: BushClient = new BushClient(config);
client.start();
diff --git a/src/commands/owner/eval.ts b/src/commands/dev/eval.ts
index a63b977..cfe75cc 100644
--- a/src/commands/owner/eval.ts
+++ b/src/commands/dev/eval.ts
@@ -1,18 +1,15 @@
/* eslint-disable @typescript-eslint/no-unused-vars */
-import { BotCommand } from '../../lib/extensions/BotCommand';
+import { BushCommand } from '../../lib/extensions/BushCommand';
import { MessageEmbed, Message } from 'discord.js';
import { inspect, promisify } from 'util';
import { exec } from 'child_process';
const clean = (text) => {
- if (typeof text === 'string')
- return text
- .replace(/`/g, '`' + String.fromCharCode(8203))
- .replace(/@/g, '@' + String.fromCharCode(8203));
+ if (typeof text === 'string') return text.replace(/`/g, '`' + String.fromCharCode(8203)).replace(/@/g, '@' + String.fromCharCode(8203));
else return text;
};
-export default class EvalCommand extends BotCommand {
+export default class EvalCommand extends BushCommand {
public constructor() {
super('eval', {
aliases: ['eval', 'ev'],
@@ -50,10 +47,7 @@ export default class EvalCommand extends BotCommand {
});
}
- public async exec(
- message: Message,
- { depth, code, silent }: { depth: number; code: string; silent: boolean }
- ): Promise<void> {
+ public async exec(message: Message, { depth, code, silent }: { depth: number; code: string; silent: boolean }): Promise<void> {
const embed: MessageEmbed = new MessageEmbed();
try {
@@ -70,58 +64,27 @@ export default class EvalCommand extends BotCommand {
output = eval(code);
output = await output;
if (typeof output !== 'string') output = inspect(output, { depth });
- output = output.replace(
- new RegExp(this.client.token, 'g'),
- '[token omitted]'
- );
+ output = output.replace(new RegExp(this.client.token, 'g'), '[token omitted]');
output = clean(output);
embed
.setTitle('✅ Evaled code successfully')
- .addField(
- '📥 Input',
- code.length > 1012
- ? 'Too large to display. Hastebin: ' +
- (await this.client.util.haste(code))
- : '```js\n' + code + '```'
- )
- .addField(
- '📤 Output',
- output.length > 1012
- ? 'Too large to display. Hastebin: ' +
- (await this.client.util.haste(output))
- : '```js\n' + output + '```'
- )
+ .addField('📥 Input', code.length > 1012 ? 'Too large to display. Hastebin: ' + (await this.client.util.haste(code)) : '```js\n' + code + '```')
+ .addField('📤 Output', output.length > 1012 ? 'Too large to display. Hastebin: ' + (await this.client.util.haste(output)) : '```js\n' + output + '```')
.setColor('#66FF00')
- .setFooter(
- message.author.username,
- message.author.displayAvatarURL({ dynamic: true })
- )
+ .setFooter(message.author.username, message.author.displayAvatarURL({ dynamic: true }))
.setTimestamp();
} catch (e) {
embed
.setTitle('❌ Code was not able to be evaled')
- .addField(
- '📥 Input',
- code.length > 1012
- ? 'Too large to display. Hastebin: ' +
- (await this.client.util.haste(code))
- : '```js\n' + code + '```'
- )
+ .addField('📥 Input', code.length > 1012 ? 'Too large to display. Hastebin: ' + (await this.client.util.haste(code)) : '```js\n' + code + '```')
.addField(
'📤 Output',
e.length > 1012
- ? 'Too large to display. Hastebin: ' +
- (await this.client.util.haste(e))
- : '```js\n' +
- e +
- '```Full stack:' +
- (await this.client.util.haste(e.stack))
+ ? 'Too large to display. Hastebin: ' + (await this.client.util.haste(e))
+ : '```js\n' + e + '```Full stack:' + (await this.client.util.haste(e.stack))
)
.setColor('#FF0000')
- .setFooter(
- message.author.username,
- message.author.displayAvatarURL({ dynamic: true })
- )
+ .setFooter(message.author.username, message.author.displayAvatarURL({ dynamic: true }))
.setTimestamp();
}
if (!silent) {
diff --git a/src/commands/owner/reload.ts b/src/commands/dev/reload.ts
index 8ba6160..36c6fd7 100644
--- a/src/commands/owner/reload.ts
+++ b/src/commands/dev/reload.ts
@@ -1,14 +1,15 @@
-import { BotCommand } from '../../lib/extensions/BotCommand';
+import { BushCommand } from '../../lib/extensions/BushCommand';
import { stripIndent } from 'common-tags';
import { Message } from 'discord.js';
import { CommandInteraction } from 'discord.js';
import { SlashCommandOption } from '../../lib/extensions/Util';
import { ApplicationCommandOptionType } from 'discord-api-types';
-export default class ReloadCommand extends BotCommand {
+export default class ReloadCommand extends BushCommand {
constructor() {
super('reload', {
aliases: ['reload'],
+ category: 'dev',
description: {
content: 'Reloads the bot',
usage: 'reload',
diff --git a/src/commands/owner/setlevel.ts b/src/commands/dev/setLevel.ts
index 6987385..3a1bc85 100644
--- a/src/commands/owner/setlevel.ts
+++ b/src/commands/dev/setLevel.ts
@@ -2,19 +2,20 @@ import { ApplicationCommandOptionType } from 'discord-api-types';
import { CommandInteraction } from 'discord.js';
import { User } from 'discord.js';
import { Message } from 'discord.js';
-import { BotCommand } from '../../lib/extensions/BotCommand';
+import { BushCommand } from '../../lib/extensions/BushCommand';
import { SlashCommandOption } from '../../lib/extensions/Util';
import { Level } from '../../lib/models';
import AllowedMentions from '../../lib/utils/AllowedMentions';
-export default class SetLevelCommand extends BotCommand {
+export default class SetLevelCommand extends BushCommand {
constructor() {
super('setlevel', {
aliases: ['setlevel'],
+ category: 'dev',
description: {
content: 'Sets the level of a user',
usage: 'setlevel <user> <level>',
- examples: ['setlevel @Moulberry 69']
+ examples: ['setlevel @Moulberry 69'] //nice
},
args: [
{
@@ -22,8 +23,7 @@ export default class SetLevelCommand extends BotCommand {
type: 'user',
prompt: {
start: 'What user would you like to change the level of?',
- retry:
- 'Invalid user. What user would you like to change the level of?'
+ retry: 'Invalid user. What user would you like to change the level of?'
}
},
{
@@ -67,22 +67,13 @@ export default class SetLevelCommand extends BotCommand {
return `Successfully set level of <@${user.id}> to \`${level}\` (\`${levelEntry.xp}\` XP)`;
}
- async exec(
- message: Message,
- { user, level }: { user: User; level: number }
- ): Promise<void> {
+ async exec(message: Message, { user, level }: { user: User; level: number }): Promise<void> {
await message.util.send(await this.setLevel(user, level), {
allowedMentions: AllowedMentions.none()
});
}
- async execSlash(
- message: CommandInteraction,
- {
- user,
- level
- }: { user: SlashCommandOption<void>; level: SlashCommandOption<number> }
- ): Promise<void> {
+ async execSlash(message: CommandInteraction, { user, level }: { user: SlashCommandOption<void>; level: SlashCommandOption<number> }): Promise<void> {
await message.reply(await this.setLevel(user.user, level.value), {
allowedMentions: AllowedMentions.none()
});
diff --git a/src/commands/info/botinfo.ts b/src/commands/info/botInfo.ts
index 8f5f055..ebbd0c9 100644
--- a/src/commands/info/botinfo.ts
+++ b/src/commands/info/botInfo.ts
@@ -1,11 +1,12 @@
import { MessageEmbed, Message, CommandInteraction } from 'discord.js';
-import { BotCommand } from '../../lib/extensions/BotCommand';
+import { BushCommand } from '../../lib/extensions/BushCommand';
import { duration } from 'moment';
-export default class BotInfoCommand extends BotCommand {
+export default class BotInfoCommand extends BushCommand {
constructor() {
super('botinfo', {
aliases: ['botinfo'],
+ category: 'info',
description: {
content: 'Shows information about the bot',
usage: 'botinfo',
@@ -15,15 +16,9 @@ export default class BotInfoCommand extends BotCommand {
}
private async generateEmbed(): Promise<MessageEmbed> {
- const owners = (await this.client.util.mapIDs(this.client.ownerID))
- .map((u) => u.tag)
- .join('\n');
- const currentCommit = (
- await this.client.util.shell('git rev-parse HEAD')
- ).stdout.replace('\n', '');
- const repoUrl = (
- await this.client.util.shell('git remote get-url origin')
- ).stdout.replace('\n', '');
+ const owners = (await this.client.util.mapIDs(this.client.ownerID)).map((u) => u.tag).join('\n');
+ const currentCommit = (await this.client.util.shell('git rev-parse HEAD')).stdout.replace('\n', '');
+ const repoUrl = (await this.client.util.shell('git remote get-url origin')).stdout.replace('\n', '');
const embed = new MessageEmbed()
.setTitle('Bot Info:')
.addFields([
@@ -34,9 +29,7 @@ export default class BotInfoCommand extends BotCommand {
},
{
name: 'Uptime',
- value: this.client.util.capitalize(
- duration(this.client.uptime, 'milliseconds').humanize()
- )
+ value: this.client.util.capitalize(duration(this.client.uptime, 'milliseconds').humanize())
},
{
name: 'User count',
@@ -45,10 +38,7 @@ export default class BotInfoCommand extends BotCommand {
},
{
name: 'Current commit',
- value: `[${currentCommit.substring(
- 0,
- 7
- )}](${repoUrl}/commit/${currentCommit})`
+ value: `[${currentCommit.substring(0, 7)}](${repoUrl}/commit/${currentCommit})`
}
])
.setTimestamp();
diff --git a/src/commands/info/help.ts b/src/commands/info/help.ts
index 116669c..7f6c8f4 100644
--- a/src/commands/info/help.ts
+++ b/src/commands/info/help.ts
@@ -1,14 +1,15 @@
import { Message, MessageEmbed } from 'discord.js';
-import { BotCommand } from '../../lib/extensions/BotCommand';
+import { BushCommand } from '../../lib/extensions/BushCommand';
import { stripIndent } from 'common-tags';
import { ApplicationCommandOptionType } from 'discord-api-types';
import { CommandInteraction } from 'discord.js';
import { SlashCommandOption } from '../../lib/extensions/Util';
-export default class HelpCommand extends BotCommand {
+export default class HelpCommand extends BushCommand {
constructor() {
super('help', {
aliases: ['help'],
+ category: 'info',
description: {
content: 'Shows the commands of the bot',
usage: 'help',
@@ -32,7 +33,7 @@ export default class HelpCommand extends BotCommand {
});
}
- private generateEmbed(command?: BotCommand): MessageEmbed {
+ private generateEmbed(command?: BushCommand): MessageEmbed {
const prefix = this.handler.prefix;
if (!command) {
const embed = new MessageEmbed()
@@ -42,15 +43,11 @@ export default class HelpCommand extends BotCommand {
For additional info on a command, type \`${prefix}help <command>\`
`
)
- .setFooter(
- `For more information about a command use "${this.client.config.prefix}help <command>"`
- )
+ .setFooter(`For more information about a command use "${this.client.config.prefix}help <command>"`)
.setTimestamp();
for (const category of this.handler.categories.values()) {
embed.addField(
- `${category.id.replace(/(\b\w)/gi, (lc): string =>
- lc.toUpperCase()
- )}`,
+ `${category.id.replace(/(\b\w)/gi, (lc): string => lc.toUpperCase())}`,
`${category
.filter((cmd): boolean => cmd.aliases.length > 0)
.map((cmd): string => `\`${cmd.aliases[0]}\``)
@@ -61,45 +58,22 @@ export default class HelpCommand extends BotCommand {
} else {
const embed = new MessageEmbed()
.setColor([155, 200, 200])
- .setTitle(
- `\`${command.description.usage ? command.description.usage : ''}\``
- )
- .addField(
- 'Description',
- `${command.description.content ? command.description.content : ''} ${
- command.ownerOnly ? '\n__Owner Only__' : ''
- }`
- );
+ .setTitle(`\`${command.description.usage ? command.description.usage : ''}\``)
+ .addField('Description', `${command.description.content ? command.description.content : ''} ${command.ownerOnly ? '\n__Owner Only__' : ''}`);
- if (command.aliases.length > 1)
- embed.addField('Aliases', `\`${command.aliases.join('` `')}\``, true);
- if (command.description.examples && command.description.examples.length)
- embed.addField(
- 'Examples',
- `\`${command.description.examples.join('`\n`')}\``,
- true
- );
+ if (command.aliases.length > 1) embed.addField('Aliases', `\`${command.aliases.join('` `')}\``, true);
+ if (command.description.examples && command.description.examples.length) embed.addField('Examples', `\`${command.description.examples.join('`\n`')}\``, true);
return embed;
}
}
- public async exec(
- message: Message,
- { command }: { command: BotCommand }
- ): Promise<void> {
+ public async exec(message: Message, { command }: { command: BushCommand }): Promise<void> {
await message.util.send(this.generateEmbed(command));
}
- public async execSlash(
- message: CommandInteraction,
- { command }: { command: SlashCommandOption<string> }
- ): Promise<void> {
+ public async execSlash(message: CommandInteraction, { command }: { command: SlashCommandOption<string> }): Promise<void> {
if (command) {
- await message.reply(
- this.generateEmbed(
- this.handler.findCommand(command.value) as BotCommand
- )
- );
+ await message.reply(this.generateEmbed(this.handler.findCommand(command.value) as BushCommand));
} else {
await message.reply(this.generateEmbed());
}
diff --git a/src/commands/info/ping.ts b/src/commands/info/ping.ts
index e51867f..b130e6d 100644
--- a/src/commands/info/ping.ts
+++ b/src/commands/info/ping.ts
@@ -1,12 +1,13 @@
import { CommandInteraction } from 'discord.js';
import { Message } from 'discord.js';
import { MessageEmbed } from 'discord.js';
-import { BotCommand } from '../../lib/extensions/BotCommand';
+import { BushCommand } from '../../lib/extensions/BushCommand';
-export default class PingCommand extends BotCommand {
+export default class PingCommand extends BushCommand {
constructor() {
super('ping', {
aliases: ['ping'],
+ category: 'info',
description: {
content: 'Gets the latency of the bot',
usage: 'ping',
@@ -17,23 +18,14 @@ export default class PingCommand extends BotCommand {
public async exec(message: Message): Promise<void> {
const sentMessage = await message.util.send('Pong!');
- const timestamp: number = message.editedTimestamp
- ? message.editedTimestamp
- : message.createdTimestamp;
- const botLatency = `\`\`\`\n ${Math.floor(
- sentMessage.createdTimestamp - timestamp
- )}ms \`\`\``;
- const apiLatency = `\`\`\`\n ${Math.round(
- message.client.ws.ping
- )}ms \`\`\``;
+ const timestamp: number = message.editedTimestamp ? message.editedTimestamp : message.createdTimestamp;
+ const botLatency = `\`\`\`\n ${Math.floor(sentMessage.createdTimestamp - timestamp)}ms \`\`\``;
+ const apiLatency = `\`\`\`\n ${Math.round(message.client.ws.ping)}ms \`\`\``;
const embed = new MessageEmbed()
.setTitle('Pong! 🏓')
.addField('Bot Latency', botLatency, true)
.addField('API Latency', apiLatency, true)
- .setFooter(
- message.author.username,
- message.author.displayAvatarURL({ dynamic: true })
- )
+ .setFooter(message.author.username, message.author.displayAvatarURL({ dynamic: true }))
.setTimestamp();
await sentMessage.edit({
content: null,
@@ -44,21 +36,14 @@ export default class PingCommand extends BotCommand {
public async execSlash(message: CommandInteraction): Promise<void> {
const timestamp1 = message.createdTimestamp;
await message.reply('Pong!');
- const timestamp2 = await message
- .fetchReply()
- .then((m) => (m as Message).createdTimestamp);
- const botLatency = `\`\`\`\n ${Math.floor(
- timestamp2 - timestamp1
- )}ms \`\`\``;
+ const timestamp2 = await message.fetchReply().then((m) => (m as Message).createdTimestamp);
+ const botLatency = `\`\`\`\n ${Math.floor(timestamp2 - timestamp1)}ms \`\`\``;
const apiLatency = `\`\`\`\n ${Math.round(this.client.ws.ping)}ms \`\`\``;
const embed = new MessageEmbed()
.setTitle('Pong! 🏓')
.addField('Bot Latency', botLatency, true)
.addField('API Latency', apiLatency, true)
- .setFooter(
- message.user.username,
- message.user.displayAvatarURL({ dynamic: true })
- )
+ .setFooter(message.user.username, message.user.displayAvatarURL({ dynamic: true }))
.setTimestamp();
await message.editReply({
content: null,
diff --git a/src/commands/info/pronouns.ts b/src/commands/info/pronouns.ts
index 97cca34..2c1d5f2 100644
--- a/src/commands/info/pronouns.ts
+++ b/src/commands/info/pronouns.ts
@@ -1,4 +1,4 @@
-import { BotCommand } from '../../lib/extensions/BotCommand';
+import { BushCommand } from '../../lib/extensions/BushCommand';
import { User, Message, MessageEmbed } from 'discord.js';
import got, { HTTPError } from 'got';
import { CommandInteraction } from 'discord.js';
@@ -30,11 +30,11 @@ export const pronounMapping = {
};
export type pronounsType = keyof typeof pronounMapping;
-export default class PronounsCommand extends BotCommand {
+export default class PronounsCommand extends BushCommand {
constructor() {
super('pronouns', {
aliases: ['pronouns', 'pronoun'],
- category: 'utilities',
+ category: 'info',
description: {
usage: 'pronouns <user>',
examples: ['pronouns IRONM00N'],
diff --git a/src/commands/moderation/ban.ts b/src/commands/moderation/ban.ts
index 556dd6b..e59a528 100644
--- a/src/commands/moderation/ban.ts
+++ b/src/commands/moderation/ban.ts
@@ -1,6 +1,6 @@
import { User } from 'discord.js';
import { Guild } from '../../lib/models';
-import { BotCommand } from '../../lib/extensions/BotCommand';
+import { BushCommand } from '../../lib/extensions/BushCommand';
import { Ban, Modlog, ModlogType } from '../../lib/models';
import moment from 'moment';
import { Message } from 'discord.js';
@@ -15,13 +15,13 @@ const durationAliases: Record<string, string[]> = {
minutes: ['m', 'min', 'mins', 'minutes', 'minute'],
months: ['mo', 'month', 'months']
};
-const durationRegex =
- /(?:(\d+)(d(?:ays?)?|h(?:ours?|rs?)?|m(?:inutes?|ins?)?|mo(?:nths?)?|w(?:eeks?|ks?)?)(?: |$))/g;
+const durationRegex = /(?:(\d+)(d(?:ays?)?|h(?:ours?|rs?)?|m(?:inutes?|ins?)?|mo(?:nths?)?|w(?:eeks?|ks?)?)(?: |$))/g;
-export default class PrefixCommand extends BotCommand {
+export default class BanCommand extends BushCommand {
constructor() {
super('ban', {
aliases: ['ban'],
+ category: 'moderation',
args: [
{
id: 'user',
@@ -44,13 +44,9 @@ export default class PrefixCommand extends BotCommand {
clientPermissions: ['BAN_MEMBERS'],
userPermissions: ['BAN_MEMBERS'],
description: {
- content:
- 'Ban a member and log it in modlogs (with optional time to unban)',
+ content: 'Ban a member and log it in modlogs (with optional time to unban)',
usage: 'ban <member> <reason> [--time]',
- examples: [
- 'ban @Tyman being cool',
- 'ban @Tyman being cool --time 7days'
- ]
+ examples: ['ban @Tyman being cool', 'ban @Tyman being cool --time 7days']
},
slashCommandOptions: [
{
@@ -68,19 +64,13 @@ export default class PrefixCommand extends BotCommand {
{
type: ApplicationCommandOptionType.STRING,
name: 'time',
- description:
- 'The time the user should be banned for (default permanent)',
+ description: 'The time the user should be banned for (default permanent)',
required: false
}
]
});
}
- async *genResponses(
- message: Message | CommandInteraction,
- user: User,
- reason?: string,
- time?: string
- ): AsyncIterable<string> {
+ async *genResponses(message: Message | CommandInteraction, user: User, reason?: string, time?: string): AsyncIterable<string> {
const duration = moment.duration();
let modlogEnry: Modlog;
let banEntry: Ban;
@@ -103,14 +93,9 @@ export default class PrefixCommand extends BotCommand {
return;
}
for (const part of parsed) {
- const translated = Object.keys(durationAliases).find((k) =>
- durationAliases[k].includes(part[2])
- );
+ const translated = Object.keys(durationAliases).find((k) => durationAliases[k].includes(part[2]));
translatedTime.push(part[1] + ' ' + translated);
- duration.add(
- Number(part[1]),
- translated as 'weeks' | 'days' | 'hours' | 'months' | 'minutes'
- );
+ duration.add(Number(part[1]), translated as 'weeks' | 'days' | 'hours' | 'months' | 'minutes');
}
modlogEnry = Modlog.build({
user: user.id,
@@ -118,10 +103,7 @@ export default class PrefixCommand extends BotCommand {
reason,
type: ModlogType.TEMPBAN,
duration: duration.asMilliseconds(),
- moderator:
- message instanceof CommandInteraction
- ? message.user.id
- : message.author.id
+ moderator: message instanceof CommandInteraction ? message.user.id : message.author.id
});
banEntry = Ban.build({
user: user.id,
@@ -136,10 +118,7 @@ export default class PrefixCommand extends BotCommand {
guild: message.guild.id,
reason,
type: ModlogType.BAN,
- moderator:
- message instanceof CommandInteraction
- ? message.user.id
- : message.author.id
+ moderator: message instanceof CommandInteraction ? message.user.id : message.author.id
});
banEntry = Ban.build({
user: user.id,
@@ -157,27 +136,17 @@ export default class PrefixCommand extends BotCommand {
}
try {
await user.send(
- `You were banned in ${message.guild.name} ${
- translatedTime.length >= 1
- ? `for ${translatedTime.join(', ')}`
- : 'permanently'
- } with reason \`${reason || 'No reason given'}\``
+ `You were banned in ${message.guild.name} ${translatedTime.length >= 1 ? `for ${translatedTime.join(', ')}` : 'permanently'} with reason \`${
+ reason || 'No reason given'
+ }\``
);
} catch (e) {
yield 'Error sending message to user';
}
await message.guild.members.ban(user, {
- reason: `Banned by ${
- message instanceof CommandInteraction
- ? message.user.tag
- : message.author.tag
- } with ${reason ? `reason ${reason}` : 'no reason'}`
+ reason: `Banned by ${message instanceof CommandInteraction ? message.user.tag : message.author.tag} with ${reason ? `reason ${reason}` : 'no reason'}`
});
- yield `Banned <@!${user.id}> ${
- translatedTime.length >= 1
- ? `for ${translatedTime.join(', ')}`
- : 'permanently'
- } with reason \`${reason || 'No reason given'}\``;
+ yield `Banned <@!${user.id}> ${translatedTime.length >= 1 ? `for ${translatedTime.join(', ')}` : 'permanently'} with reason \`${reason || 'No reason given'}\``;
} catch {
yield 'Error banning :/';
await banEntry.destroy();
@@ -185,16 +154,8 @@ export default class PrefixCommand extends BotCommand {
return;
}
}
- async exec(
- message: Message,
- { user, reason, time }: { user: User; reason?: string; time?: string }
- ): Promise<void> {
- for await (const response of this.genResponses(
- message,
- user,
- reason,
- time
- )) {
+ async exec(message: Message, { user, reason, time }: { user: User; reason?: string; time?: string }): Promise<void> {
+ for await (const response of this.genResponses(message, user, reason, time)) {
await message.util.send(response);
}
}
@@ -211,12 +172,7 @@ export default class PrefixCommand extends BotCommand {
time: SlashCommandOption<string>;
}
): Promise<void> {
- for await (const response of this.genResponses(
- message,
- user.user,
- reason?.value,
- time?.value
- )) {
+ for await (const response of this.genResponses(message, user.user, reason?.value, time?.value)) {
await message.reply(response);
}
}
diff --git a/src/commands/moderation/kick.ts b/src/commands/moderation/kick.ts
index f31047e..182485a 100644
--- a/src/commands/moderation/kick.ts
+++ b/src/commands/moderation/kick.ts
@@ -1,13 +1,14 @@
-import { BotCommand } from '../../lib/extensions/BotCommand';
+import { BushCommand } from '../../lib/extensions/BushCommand';
import { Guild, Modlog, ModlogType } from '../../lib/models';
import { GuildMember, Message } from 'discord.js';
import { ApplicationCommandOptionType } from 'discord-api-types';
import { CommandInteraction } from 'discord.js';
-export default class KickCommand extends BotCommand {
+export default class KickCommand extends BushCommand {
constructor() {
super('kick', {
aliases: ['kick'],
+ category: 'moderation',
args: [
{
id: 'user',
@@ -45,11 +46,7 @@ export default class KickCommand extends BotCommand {
});
}
- private async *genResponses(
- message: Message | CommandInteraction,
- user: GuildMember,
- reason?: string
- ): AsyncIterable<string> {
+ private async *genResponses(message: Message | CommandInteraction, user: GuildMember, reason?: string): AsyncIterable<string> {
let modlogEnry: Modlog;
// Create guild entry so postgres doesn't get mad when I try and add a modlog entry
await Guild.findOrCreate({
@@ -64,8 +61,7 @@ export default class KickCommand extends BotCommand {
modlogEnry = Modlog.build({
user: user.id,
guild: message.guild.id,
- moderator:
- message instanceof Message ? message.author.id : message.user.id,
+ moderator: message instanceof Message ? message.author.id : message.user.id,
type: ModlogType.KICK,
reason
});
@@ -76,43 +72,27 @@ export default class KickCommand extends BotCommand {
return;
}
try {
- await user.send(
- `You were kicked in ${message.guild.name} with reason \`${
- reason || 'No reason given'
- }\``
- );
+ await user.send(`You were kicked in ${message.guild.name} with reason \`${reason || 'No reason given'}\``);
} catch (e) {
yield 'Error sending message to user';
}
try {
- await user.kick(
- `Kicked by ${
- message instanceof Message ? message.author.tag : message.user.tag
- } with ${reason ? `reason ${reason}` : 'no reason'}`
- );
+ await user.kick(`Kicked by ${message instanceof Message ? message.author.tag : message.user.tag} with ${reason ? `reason ${reason}` : 'no reason'}`);
} catch {
yield 'Error kicking :/';
await modlogEnry.destroy();
return;
}
- yield `Kicked <@!${user.id}> with reason \`${
- reason || 'No reason given'
- }\``;
+ yield `Kicked <@!${user.id}> with reason \`${reason || 'No reason given'}\``;
}
- async exec(
- message: Message,
- { user, reason }: { user: GuildMember; reason?: string }
- ): Promise<void> {
+ async exec(message: Message, { user, reason }: { user: GuildMember; reason?: string }): Promise<void> {
for await (const response of this.genResponses(message, user, reason)) {
await message.util.send(response);
}
}
- async execSlash(
- message: CommandInteraction,
- { user, reason }: { user: GuildMember; reason?: string }
- ): Promise<void> {
+ async execSlash(message: CommandInteraction, { user, reason }: { user: GuildMember; reason?: string }): Promise<void> {
for await (const response of this.genResponses(message, user, reason)) {
await message.reply(response);
}
diff --git a/src/commands/moderation/modlog.ts b/src/commands/moderation/modlog.ts
index 320c6b4..806c00a 100644
--- a/src/commands/moderation/modlog.ts
+++ b/src/commands/moderation/modlog.ts
@@ -1,4 +1,4 @@
-import { BotCommand } from '../../lib/extensions/BotCommand';
+import { BushCommand } from '../../lib/extensions/BushCommand';
import { Message } from 'discord.js';
import { Modlog } from '../../lib/models';
import { MessageEmbed } from 'discord.js';
@@ -6,10 +6,11 @@ import moment from 'moment';
import { stripIndent } from 'common-tags';
import { Argument } from 'discord-akairo';
-export default class ModlogCommand extends BotCommand {
+export default class ModlogCommand extends BushCommand {
constructor() {
super('modlog', {
aliases: ['modlog', 'modlogs'],
+ category: 'moderation',
args: [
{
id: 'search',
@@ -52,10 +53,7 @@ export default class ModlogCommand extends BotCommand {
return { search, page };
}
}
- async exec(
- message: Message,
- { search, page }: { search: string; page: number }
- ): Promise<void> {
+ async exec(message: Message, { search, page }: { search: string; page: number }): Promise<void> {
const foundUser = await this.client.util.resolveUserAsync(search);
if (foundUser) {
const logs = await Modlog.findAll({
@@ -72,11 +70,7 @@ export default class ModlogCommand extends BotCommand {
Type: ${log.type.toLowerCase()}
User: <@!${log.user}> (${log.user})
Moderator: <@!${log.moderator}> (${log.moderator})
- Duration: ${
- log.duration
- ? moment.duration(log.duration, 'milliseconds').humanize()
- : 'N/A'
- }
+ Duration: ${log.duration ? moment.duration(log.duration, 'milliseconds').humanize() : 'N/A'}
Reason: ${log.reason || 'None given'}
${this.client.util.ordinal(logs.indexOf(log) + 1)} action
`);
@@ -86,9 +80,7 @@ export default class ModlogCommand extends BotCommand {
(e, i) =>
new MessageEmbed({
title: `Modlogs page ${i + 1}`,
- description: e.join(
- '\n-------------------------------------------------------\n'
- ),
+ description: e.join('\n-------------------------------------------------------\n'),
footer: {
text: `Page ${i + 1}/${chunked.length}`
}
@@ -118,11 +110,7 @@ export default class ModlogCommand extends BotCommand {
},
{
name: 'Duration',
- value: `${
- entry.duration
- ? moment.duration(entry.duration, 'milliseconds').humanize()
- : 'N/A'
- }`,
+ value: `${entry.duration ? moment.duration(entry.duration, 'milliseconds').humanize() : 'N/A'}`,
inline: true
},
{
diff --git a/src/commands/moderation/role.ts b/src/commands/moderation/role.ts
index 2a67e5b..0c7d7db 100644
--- a/src/commands/moderation/role.ts
+++ b/src/commands/moderation/role.ts
@@ -1,34 +1,20 @@
/* eslint-disable @typescript-eslint/no-empty-function */
-import { BotCommand } from '../../lib/extensions/BotCommand';
+import { BushCommand } from '../../lib/extensions/BushCommand';
import AllowedMentions from '../../lib/utils/AllowedMentions';
import { Message, Role, GuildMember } from 'discord.js';
import { ApplicationCommandOptionType } from 'discord-api-types';
-export default class RoleCommand extends BotCommand {
+export default class RoleCommand extends BushCommand {
private roleWhitelist: Record<string, string[]> = {
'Partner': ['*', 'Admin Perms', 'Sr. Moderator', 'Moderator'],
- 'Suggester': [
- '*',
- 'Admin Perms',
- 'Sr. Moderator',
- 'Moderator',
- 'Helper',
- 'Trial Helper',
- 'Contributor'
- ],
+ 'Suggester': ['*', 'Admin Perms', 'Sr. Moderator', 'Moderator', 'Helper', 'Trial Helper', 'Contributor'],
'Level Locked': ['*', 'Admin Perms', 'Sr. Moderator', 'Moderator'],
'No Files': ['*', 'Admin Perms', 'Sr. Moderator', 'Moderator'],
'No Reactions': ['*', 'Admin Perms', 'Sr. Moderator', 'Moderator'],
'No Links': ['*', 'Admin Perms', 'Sr. Moderator', 'Moderator'],
'No Bots': ['*', 'Admin Perms', 'Sr. Moderator', 'Moderator'],
'No VC': ['*', 'Admin Perms', 'Sr. Moderator', 'Moderator'],
- 'No Giveaways': [
- '*',
- 'Admin Perms',
- 'Sr. Moderator',
- 'Moderator',
- 'Helper'
- ],
+ 'No Giveaways': ['*', 'Admin Perms', 'Sr. Moderator', 'Moderator', 'Helper'],
'No Support': ['*', 'Admin Perms', 'Sr. Moderator', 'Moderator'],
'Giveaway Donor': ['*', 'Admin Perms', 'Sr. Moderator', 'Moderator'],
'Giveaway (200m)': ['*', 'Admin Perms', 'Sr. Moderator', 'Moderator'],
@@ -42,7 +28,7 @@ export default class RoleCommand extends BotCommand {
constructor() {
super('role', {
aliases: ['role', 'addrole', 'removerole'],
- category: "Moulberry's Bush",
+ category: 'moderation',
description: {
content: "Manages users' roles.",
usage: 'role <add|remove> <user> <role>',
@@ -87,66 +73,38 @@ export default class RoleCommand extends BotCommand {
});
}
- public async exec(
- message: Message,
- { user, role }: { user: GuildMember; role: Role }
- ): Promise<unknown> {
- if (
- !message.member.permissions.has('MANAGE_ROLES') &&
- !this.client.ownerID.includes(message.author.id)
- ) {
- const mappedRole = this.client.util.moulberryBushRoleMap.find(
- (m) => m.id === role.id
- );
+ public async exec(message: Message, { user, role }: { user: GuildMember; role: Role }): Promise<unknown> {
+ if (!message.member.permissions.has('MANAGE_ROLES') && !this.client.ownerID.includes(message.author.id)) {
+ const mappedRole = this.client.util.moulberryBushRoleMap.find((m) => m.id === role.id);
if (!mappedRole || !this.roleWhitelist[mappedRole.name]) {
- return message.util.reply(
- `<:error:837123021016924261> <@&${role.id}> is not whitelisted, and you do not have manage roles permission.`,
- {
- allowedMentions: AllowedMentions.none()
- }
- );
+ return message.util.reply(`<:error:837123021016924261> <@&${role.id}> is not whitelisted, and you do not have manage roles permission.`, {
+ allowedMentions: AllowedMentions.none()
+ });
}
const allowedRoles = this.roleWhitelist[mappedRole.name].map((r) => {
- return this.client.util.moulberryBushRoleMap.find((m) => m.name === r)
- .id;
+ return this.client.util.moulberryBushRoleMap.find((m) => m.name === r).id;
});
- if (
- !message.member.roles.cache.some((role) =>
- allowedRoles.includes(role.id)
- )
- ) {
- return message.util.reply(
- `<:error:837123021016924261> <@&${role.id}> is whitelisted, but you do not have any of the roles required to manage it.`,
- {
- allowedMentions: AllowedMentions.none()
- }
- );
+ if (!message.member.roles.cache.some((role) => allowedRoles.includes(role.id))) {
+ return message.util.reply(`<:error:837123021016924261> <@&${role.id}> is whitelisted, but you do not have any of the roles required to manage it.`, {
+ allowedMentions: AllowedMentions.none()
+ });
}
}
if (!this.client.ownerID.includes(message.author.id)) {
if (role.comparePositionTo(message.member.roles.highest) >= 0) {
- return message.util.reply(
- `<:error:837123021016924261> <@&${role.id}> is higher or equal to your highest role.`,
- {
- allowedMentions: AllowedMentions.none()
- }
- );
+ return message.util.reply(`<:error:837123021016924261> <@&${role.id}> is higher or equal to your highest role.`, {
+ allowedMentions: AllowedMentions.none()
+ });
}
if (role.comparePositionTo(message.guild.me.roles.highest) >= 0) {
- return message.util.reply(
- `<:error:837123021016924261> <@&${role.id}> is higher or equal to my highest role.`,
- {
- allowedMentions: AllowedMentions.none()
- }
- );
+ return message.util.reply(`<:error:837123021016924261> <@&${role.id}> is higher or equal to my highest role.`, {
+ allowedMentions: AllowedMentions.none()
+ });
}
if (role.managed) {
- await message.util.reply(
- `<:error:837123021016924261> <@&${role.id}> is managed by an integration and cannot be managed.`,
- {
- allowedMentions: AllowedMentions.none()
- }
- );
+ await message.util.reply(`<:error:837123021016924261> <@&${role.id}> is managed by an integration and cannot be managed.`, {
+ allowedMentions: AllowedMentions.none()
+ });
}
}
// No checks if the user has MANAGE_ROLES
@@ -154,28 +112,16 @@ export default class RoleCommand extends BotCommand {
try {
await user.roles.remove(role.id);
} catch {
- return message.util.reply(
- `<:error:837123021016924261> Could not remove <@&${role.id}> from <@${user.id}>.`,
- { allowedMentions: AllowedMentions.none() }
- );
+ return message.util.reply(`<:error:837123021016924261> Could not remove <@&${role.id}> from <@${user.id}>.`, { allowedMentions: AllowedMentions.none() });
}
- return message.util.reply(
- `<:checkmark:837109864101707807> Successfully removed <@&${role.id}> from <@${user.id}>!`,
- { allowedMentions: AllowedMentions.none() }
- );
+ return message.util.reply(`<:checkmark:837109864101707807> Successfully removed <@&${role.id}> from <@${user.id}>!`, { allowedMentions: AllowedMentions.none() });
} else {
try {
await user.roles.add(role.id);
} catch {
- return message.util.reply(
- `<:error:837123021016924261> Could not add <@&${role.id}> to <@${user.id}>.`,
- { allowedMentions: AllowedMentions.none() }
- );
+ return message.util.reply(`<:error:837123021016924261> Could not add <@&${role.id}> to <@${user.id}>.`, { allowedMentions: AllowedMentions.none() });
}
- return message.util.reply(
- `<:checkmark:837109864101707807> Successfully added <@&${role.id}> to <@${user.id}>!`,
- { allowedMentions: AllowedMentions.none() }
- );
+ return message.util.reply(`<:checkmark:837109864101707807> Successfully added <@&${role.id}> to <@${user.id}>!`, { allowedMentions: AllowedMentions.none() });
}
}
}
diff --git a/src/commands/moderation/warn.ts b/src/commands/moderation/warn.ts
index 41e0032..3410d81 100644
--- a/src/commands/moderation/warn.ts
+++ b/src/commands/moderation/warn.ts
@@ -1,11 +1,12 @@
import { GuildMember, Message } from 'discord.js';
-import { BotCommand } from '../../lib/extensions/BotCommand';
+import { BushCommand } from '../../lib/extensions/BushCommand';
import { Guild, Modlog, ModlogType } from '../../lib/models';
-export default class WarnCommand extends BotCommand {
+export default class WarnCommand extends BushCommand {
public constructor() {
super('warn', {
aliases: ['warn'],
+ category: 'moderation',
userPermissions: ['MANAGE_MESSAGES'],
args: [
{
@@ -24,10 +25,7 @@ export default class WarnCommand extends BotCommand {
}
});
}
- public async exec(
- message: Message,
- { member, reason }: { member: GuildMember; reason: string }
- ): Promise<void> {
+ public async exec(message: Message, { member, reason }: { member: GuildMember; reason: string }): Promise<void> {
// Create guild entry so postgres doesn't get mad when I try and add a modlog entry
await Guild.findOrCreate({
where: {
@@ -47,21 +45,15 @@ export default class WarnCommand extends BotCommand {
});
await entry.save();
} catch (e) {
- await message.util.send(
- 'Error saving to database, please contact the developers'
- );
+ 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}".`
- );
+ await member.send(`You were warned in ${message.guild.name} for reason "${reason}".`);
} catch (e) {
await message.util.send('Error messaging user, warning still saved.');
return;
}
- await message.util.send(
- `${member.user.tag} was warned for reason "${reason}".`
- );
+ await message.util.send(`${member.user.tag} was warned for reason "${reason}".`);
}
}
diff --git a/src/commands/moulberry-bush/capeperms.ts b/src/commands/moulberry-bush/capePerms.ts
index 5b3dc10..79f9d6b 100644
--- a/src/commands/moulberry-bush/capeperms.ts
+++ b/src/commands/moulberry-bush/capePerms.ts
@@ -3,7 +3,7 @@ import { MessageEmbed } from 'discord.js';
import { CommandInteraction } from 'discord.js';
import { Message } from 'discord.js';
import got from 'got';
-import { BotCommand } from '../../lib/extensions/BotCommand';
+import { BushCommand } from '../../lib/extensions/BushCommand';
import { SlashCommandOption } from '../../lib/extensions/Util';
interface Capeperms {
@@ -15,7 +15,7 @@ interface User {
perms: string[];
}
-export default class CapePermsCommand extends BotCommand {
+export default class CapePermissionsCommand extends BushCommand {
private nameMap = {
patreon1: 'Patreon Tier 1',
patreon2: 'Patreon Tier 2',
@@ -45,7 +45,7 @@ export default class CapePermsCommand extends BotCommand {
};
public constructor() {
super('capeperms', {
- aliases: ['capeperms', 'capeperm'],
+ aliases: ['capeperms', 'capeperm', 'capepermissions', 'capepermission'],
category: "Moulberry's Bush",
description: {
content: 'A command to see what capes someone has access to.',
@@ -58,8 +58,7 @@ export default class CapePermsCommand extends BotCommand {
type: 'string',
prompt: {
start: 'Who would you like to see the cape permissions of?',
- retry:
- '<:error:837123021016924261> Choose someone to see the capes their available capes.',
+ retry: '<:error:837123021016924261> Choose someone to see the capes their available capes.',
optional: false
}
}
@@ -70,8 +69,7 @@ export default class CapePermsCommand extends BotCommand {
{
type: ApplicationCommandOptionType.STRING,
name: 'user',
- description:
- 'The username of the player to see the cape permissions of',
+ description: 'The username of the player to see the cape permissions of',
required: true
}
]
@@ -86,9 +84,7 @@ export default class CapePermsCommand extends BotCommand {
}
try {
- capeperms = await got
- .get('http://moulberry.codes/permscapes.json')
- .json();
+ capeperms = await got.get('http://moulberry.codes/permscapes.json').json();
} catch (error) {
capeperms = null;
}
@@ -97,30 +93,20 @@ export default class CapePermsCommand extends BotCommand {
} else {
if (capeperms?.perms) {
const foundUser = capeperms.perms.find((u) => u._id === uuid);
- if (foundUser == null)
- return `<:error:837123021016924261> \`${user}\` does not appear to have any capes.`;
+ if (foundUser == null) return `<:error:837123021016924261> \`${user}\` does not appear to have any capes.`;
const userPerm: string[] = foundUser.perms;
- const embed = this.client.util
- .createEmbed(this.client.util.colors.default)
- .setTitle(`${user}'s Capes`)
- .setDescription(userPerm.join('\n'));
+ const embed = this.client.util.createEmbed(this.client.util.colors.default).setTitle(`${user}'s Capes`).setDescription(userPerm.join('\n'));
return embed;
} else {
return `<:error:837123021016924261> There was an error finding cape perms for ${user}.`;
}
}
}
- public async exec(
- message: Message,
- { user }: { user: string }
- ): Promise<void> {
+ public async exec(message: Message, { user }: { user: string }): Promise<void> {
await message.reply(await this.getResponse(user));
}
- public async execSlash(
- message: CommandInteraction,
- { user }: { user: SlashCommandOption<string> }
- ): Promise<void> {
+ public async execSlash(message: CommandInteraction, { user }: { user: SlashCommandOption<string> }): Promise<void> {
await message.reply(await this.getResponse(user.value));
}
}
diff --git a/src/commands/moulberry-bush/giveawayping.ts b/src/commands/moulberry-bush/giveawayPing.ts
index d99f475..e11585a 100644
--- a/src/commands/moulberry-bush/giveawayping.ts
+++ b/src/commands/moulberry-bush/giveawayPing.ts
@@ -1,10 +1,10 @@
-import { BotCommand } from '../../lib/extensions/BotCommand';
+import { BushCommand } from '../../lib/extensions/BushCommand';
import AllowedMentions from '../../lib/utils/AllowedMentions';
import { Message, WebhookClient } from 'discord.js';
import { TextChannel } from 'discord.js';
import { NewsChannel } from 'discord.js';
-export default class GiveawayPingCommand extends BotCommand {
+export default class GiveawayPingCommand extends BushCommand {
constructor() {
super('giveawayping', {
aliases: ['giveawayping', 'giveawaypong'],
@@ -15,14 +15,7 @@ export default class GiveawayPingCommand extends BotCommand {
examples: ['giveawayping']
},
clientPermissions: ['MANAGE_MESSAGES'],
- userPermissions: [
- 'SEND_MESSAGES',
- 'MANAGE_GUILD',
- 'MANAGE_MESSAGES',
- 'BAN_MEMBERS',
- 'KICK_MEMBERS',
- 'VIEW_CHANNEL'
- ],
+ userPermissions: ['SEND_MESSAGES', 'MANAGE_GUILD', 'MANAGE_MESSAGES', 'BAN_MEMBERS', 'KICK_MEMBERS', 'VIEW_CHANNEL'],
channel: 'guild',
ignoreCooldown: [],
ignorePermissions: [],
@@ -32,25 +25,14 @@ export default class GiveawayPingCommand extends BotCommand {
});
}
public async exec(message: Message): Promise<unknown> {
- if (message.guild.id !== '516977525906341928')
- return message.reply(
- "<:error:837123021016924261> This command may only be run in Moulberry's Bush."
- );
- if (
- !['767782084981817344', '833855738501267456'].includes(message.channel.id)
- )
- return message.reply(
- '<:error:837123021016924261> This command may only be run in giveaway channels.'
- );
+ if (message.guild.id !== '516977525906341928') return message.reply("<:error:837123021016924261> This command may only be run in Moulberry's Bush.");
+ if (!['767782084981817344', '833855738501267456'].includes(message.channel.id))
+ return message.reply('<:error:837123021016924261> This command may only be run in giveaway channels.');
await message.delete().catch(() => undefined);
- const webhooks = await (
- message.channel as TextChannel | NewsChannel
- ).fetchWebhooks();
+ const webhooks = await (message.channel as TextChannel | NewsChannel).fetchWebhooks();
let webhookClient: WebhookClient;
if (webhooks.size < 1) {
- const webhook = await (
- message.channel as TextChannel | NewsChannel
- ).createWebhook('Giveaway ping webhook');
+ const webhook = await (message.channel as TextChannel | NewsChannel).createWebhook('Giveaway ping webhook');
webhookClient = new WebhookClient(webhook.id, webhook.token);
} else {
const webhook = webhooks.first();
diff --git a/src/commands/moulberry-bush/level.ts b/src/commands/moulberry-bush/level.ts
index 046940a..554219d 100644
--- a/src/commands/moulberry-bush/level.ts
+++ b/src/commands/moulberry-bush/level.ts
@@ -3,7 +3,7 @@ import { Message } from 'discord.js';
import { CommandInteractionOption } from 'discord.js';
import { CommandInteraction } from 'discord.js';
import { User } from 'discord.js';
-import { BotCommand } from '../../lib/extensions/BotCommand';
+import { BushCommand } from '../../lib/extensions/BushCommand';
import { Level } from '../../lib/models';
import canvas from 'canvas';
import { MessageAttachment } from 'discord.js';
@@ -11,10 +11,11 @@ import { join } from 'path';
import got from 'got/dist/source';
import { CanvasProgressBar } from '../../lib/extensions/Util';
-export default class LevelCommand extends BotCommand {
+export default class LevelCommand extends BushCommand {
constructor() {
super('level', {
aliases: ['level', 'rank'],
+ category: "Moulberry's Bush",
description: {
content: 'Shows the level of a user',
usage: 'level [user]',
@@ -26,8 +27,7 @@ export default class LevelCommand extends BotCommand {
type: 'user',
prompt: {
start: 'What user would you like to see the level of?',
- retry:
- 'Invalid user. What user would you like to see the level of?',
+ retry: 'Invalid user. What user would you like to see the level of?',
optional: true
}
}
diff --git a/src/commands/moulberry-bush/rule.ts b/src/commands/moulberry-bush/rule.ts
index bd8b08a..e3f9e34 100644
--- a/src/commands/moulberry-bush/rule.ts
+++ b/src/commands/moulberry-bush/rule.ts
@@ -1,11 +1,11 @@
import { Argument } from 'discord-akairo';
import { Message, MessageEmbed, User } from 'discord.js';
-import { BotCommand } from '../../lib/extensions/BotCommand';
+import { BushCommand } from '../../lib/extensions/BushCommand';
import { ApplicationCommandOptionType } from 'discord-api-types';
import { CommandInteraction } from 'discord.js';
import { SlashCommandOption } from '../../lib/extensions/Util';
-export default class RuleCommand extends BotCommand {
+export default class RuleCommand extends BushCommand {
private rules = [
{
title: "Follow Discord's TOS",
@@ -19,28 +19,23 @@ export default class RuleCommand extends BotCommand {
},
{
title: 'No Spamming',
- description:
- 'Including but not limited to: any messages that do not contribute to the conversation, repeated messages, randomly tagging users, and chat flood.'
+ description: 'Including but not limited to: any messages that do not contribute to the conversation, repeated messages, randomly tagging users, and chat flood.'
},
{
title: 'English',
- description:
- 'The primary language of the server is English, please keep all discussions in English.'
+ description: 'The primary language of the server is English, please keep all discussions in English.'
},
{
title: 'Safe for Work',
- description:
- 'Please keep NSFW and NSFL content out of this server, avoid borderline images as well as keeping your status and profile picture SFW.'
+ description: 'Please keep NSFW and NSFL content out of this server, avoid borderline images as well as keeping your status and profile picture SFW.'
},
{
title: 'No Advertising',
- description:
- 'Do not promote anything without prior approval from a staff member, this includes DM advertising.'
+ description: 'Do not promote anything without prior approval from a staff member, this includes DM advertising.'
},
{
title: 'Impersonation',
- description:
- 'Do not try to impersonate others for the express intent of being deceitful, defamation , and/or personal gain.'
+ description: 'Do not try to impersonate others for the express intent of being deceitful, defamation , and/or personal gain.'
},
{
title: 'Swearing',
@@ -48,23 +43,19 @@ export default class RuleCommand extends BotCommand {
},
{
title: 'Only ping @emergency in emergencies',
- description:
- 'Pinging <@&833802660209229854> for no reason will result in severe punishment. <@&833802660209229854> is only to be pinged in true emergencies.'
+ description: 'Pinging <@&833802660209229854> for no reason will result in severe punishment. <@&833802660209229854> is only to be pinged in true emergencies.'
},
{
title: 'No Backseat Moderating',
- description:
- 'If you see a rule being broken be broken, please report it using: `-report <user> [evidence]`.'
+ description: 'If you see a rule being broken be broken, please report it using: `-report <user> [evidence]`.'
},
{
title: 'Staff may moderate at their discretion',
- description:
- 'If there are loopholes in our rules, the staff team may moderate based on what they deem appropriate. The staff team holds final discretion.'
+ description: 'If there are loopholes in our rules, the staff team may moderate based on what they deem appropriate. The staff team holds final discretion.'
},
{
title: "Sending media that are able to crash a user's Discord",
- description:
- "Sending videos, GIFs, emojis, etc. that are able to crash someone's discord will result in a **permanent** mute that cannot be appealed."
+ description: "Sending videos, GIFs, emojis, etc. that are able to crash someone's discord will result in a **permanent** mute that cannot be appealed."
}
];
@@ -117,35 +108,20 @@ export default class RuleCommand extends BotCommand {
]
});
}
- private getResponse(
- message: Message | CommandInteraction,
- rule?: number,
- user?: User
- ): string | MessageEmbed | [string, MessageEmbed] {
- if (
- message.guild.id !== '516977525906341928' &&
- !this.client.ownerID.includes(
- message instanceof Message ? message.author.id : message.user.id
- )
- ) {
+ private getResponse(message: Message | CommandInteraction, rule?: number, user?: User): string | MessageEmbed | [string, MessageEmbed] {
+ if (message.guild.id !== '516977525906341928' && !this.client.ownerID.includes(message instanceof Message ? message.author.id : message.user.id)) {
return "<:no:787549684196704257> This command can only be run in Moulberry's Bush.";
}
let rulesEmbed = new MessageEmbed().setColor('ef3929');
if (message instanceof Message) {
- rulesEmbed = rulesEmbed.setFooter(
- `Triggered by ${message.author.tag}`,
- message.author.avatarURL({ dynamic: true })
- );
+ rulesEmbed = rulesEmbed.setFooter(`Triggered by ${message.author.tag}`, message.author.avatarURL({ dynamic: true }));
}
if (rule) {
const foundRule = this.rules[rule - 1];
rulesEmbed.addField(`${rule}) ${foundRule.title}`, foundRule.description);
} else {
for (const curRule of this.rules) {
- rulesEmbed.addField(
- `${this.rules.indexOf(curRule) + 1}) ${curRule.title}`,
- curRule.description
- );
+ rulesEmbed.addField(`${this.rules.indexOf(curRule) + 1}) ${curRule.title}`, curRule.description);
}
}
if (!user) {
@@ -154,10 +130,7 @@ export default class RuleCommand extends BotCommand {
return [`<@!${user.id}>`, rulesEmbed];
}
}
- public async exec(
- message: Message,
- { rule, user }: { rule?: number; user?: User }
- ): Promise<void> {
+ public async exec(message: Message, { rule, user }: { rule?: number; user?: User }): Promise<void> {
const response = this.getResponse(message, rule, user);
if (Array.isArray(response)) {
await message.util.send(response[0], {
@@ -169,13 +142,7 @@ export default class RuleCommand extends BotCommand {
await message.delete().catch(() => undefined);
}
- public async execSlash(
- message: CommandInteraction,
- {
- rule,
- user
- }: { rule?: SlashCommandOption<number>; user?: SlashCommandOption<void> }
- ): Promise<void> {
+ public async execSlash(message: CommandInteraction, { rule, user }: { rule?: SlashCommandOption<number>; user?: SlashCommandOption<void> }): Promise<void> {
const response = this.getResponse(message, rule?.value, user?.user);
if (Array.isArray(response)) {
await message.reply(response[0], {
diff --git a/src/commands/admin/prefix.ts b/src/commands/server-config/prefix.ts
index 112f6b8..c60f8fb 100644
--- a/src/commands/admin/prefix.ts
+++ b/src/commands/server-config/prefix.ts
@@ -1,13 +1,14 @@
import { ApplicationCommandOptionType } from 'discord-api-types';
import { CommandInteraction, Message, Guild as DiscordGuild } from 'discord.js';
-import { BotCommand } from '../../lib/extensions/BotCommand';
+import { BushCommand } from '../../lib/extensions/BushCommand';
import { SlashCommandOption } from '../../lib/extensions/Util';
import { Guild } from '../../lib/models';
-export default class PrefixCommand extends BotCommand {
+export default class PrefixCommand extends BushCommand {
constructor() {
super('prefix', {
aliases: ['prefix'],
+ category: 'server config',
args: [
{
id: 'prefix'
@@ -15,8 +16,7 @@ export default class PrefixCommand extends BotCommand {
],
userPermissions: ['MANAGE_GUILD'],
description: {
- content:
- 'Set the prefix of the current server (resets to default if prefix is not given)',
+ content: 'Set the prefix of the current server (resets to default if prefix is not given)',
usage: 'prefix [prefix]',
examples: ['prefix', 'prefix +']
},
@@ -32,8 +32,13 @@ export default class PrefixCommand extends BotCommand {
}
async changePrefix(guild: DiscordGuild, prefix?: string): Promise<void> {
+ let row = await Guild.findByPk(guild.id);
+ if (!row) {
+ row = Guild.build({
+ id: guild.id
+ });
+ }
if (prefix) {
- const row = await Guild.findByPk(guild.id);
row.prefix = prefix;
await row.save();
} else {
@@ -48,23 +53,16 @@ export default class PrefixCommand extends BotCommand {
if (prefix) {
await message.util.send(`Sucessfully set prefix to \`${prefix}\``);
} else {
- await message.util.send(
- `Sucessfully reset prefix to \`${this.client.config.prefix}\``
- );
+ await message.util.send(`Sucessfully reset prefix to \`${this.client.config.prefix}\``);
}
}
- async execSlash(
- message: CommandInteraction,
- { prefix }: { prefix?: SlashCommandOption<string> }
- ): Promise<void> {
+ async execSlash(message: CommandInteraction, { prefix }: { prefix?: SlashCommandOption<string> }): Promise<void> {
await this.changePrefix(message.guild, prefix?.value);
if (prefix) {
await message.reply(`Sucessfully set prefix to \`${prefix.value}\``);
} else {
- await message.reply(
- `Sucessfully reset prefix to \`${this.client.config.prefix}\``
- );
+ await message.reply(`Sucessfully reset prefix to \`${this.client.config.prefix}\``);
}
}
}
diff --git a/src/config/example-options.ts b/src/config/example-options.ts
index f835321..ebd8c21 100644
--- a/src/config/example-options.ts
+++ b/src/config/example-options.ts
@@ -18,7 +18,6 @@ export const channels = {
dm: 'id here',
command: 'id here'
};
-export const verbose = false;
// Database specific
export const db = {
@@ -27,3 +26,9 @@ export const db = {
username: 'username here',
password: 'password here'
};
+
+// Logging
+export const logging: { info: boolean; verbose: boolean } = {
+ info: false,
+ verbose: true
+};
diff --git a/src/inhibitors/blacklist/BlacklistInhibitor.ts b/src/inhibitors/blacklist/blacklist.ts
index 82db4c2..309815f 100644
--- a/src/inhibitors/blacklist/BlacklistInhibitor.ts
+++ b/src/inhibitors/blacklist/blacklist.ts
@@ -1,6 +1,6 @@
-import { BotInhibitor } from '../../lib/extensions/BotInhibitor';
+import { BushInhibitor } from '../../lib/extensions/BushInhibitor';
-export default class BlacklistInhibitor extends BotInhibitor {
+export default class BlacklistInhibitor extends BushInhibitor {
constructor() {
super('blacklist', {
reason: 'blacklist'
diff --git a/src/lib/extensions/BotInhibitor.ts b/src/lib/extensions/BotInhibitor.ts
deleted file mode 100644
index 960aade..0000000
--- a/src/lib/extensions/BotInhibitor.ts
+++ /dev/null
@@ -1,6 +0,0 @@
-import { Inhibitor } from 'discord-akairo';
-import { BotClient } from './BotClient';
-
-export class BotInhibitor extends Inhibitor {
- public client: BotClient;
-}
diff --git a/src/lib/extensions/BotListener.ts b/src/lib/extensions/BotListener.ts
deleted file mode 100644
index 9ec17b2..0000000
--- a/src/lib/extensions/BotListener.ts
+++ /dev/null
@@ -1,6 +0,0 @@
-import { Listener } from 'discord-akairo';
-import { BotClient } from './BotClient';
-
-export class BotListener extends Listener {
- public client: BotClient;
-}
diff --git a/src/lib/extensions/BotTask.ts b/src/lib/extensions/BotTask.ts
deleted file mode 100644
index 4d5cdcd..0000000
--- a/src/lib/extensions/BotTask.ts
+++ /dev/null
@@ -1,6 +0,0 @@
-import { Task } from 'discord-akairo';
-import { BotClient } from './BotClient';
-
-export class BotTask extends Task {
- public client: BotClient;
-}
diff --git a/src/lib/extensions/BotClient.ts b/src/lib/extensions/BushClient.ts
index 13c8a76..8a0fc8c 100644
--- a/src/lib/extensions/BotClient.ts
+++ b/src/lib/extensions/BushClient.ts
@@ -1,10 +1,4 @@
-import {
- AkairoClient,
- CommandHandler,
- InhibitorHandler,
- ListenerHandler,
- TaskHandler
-} from 'discord-akairo';
+import { AkairoClient, CommandHandler, InhibitorHandler, ListenerHandler, TaskHandler } from 'discord-akairo';
import { Guild } from 'discord.js';
import * as path from 'path';
import { Sequelize } from 'sequelize';
@@ -18,7 +12,7 @@ import chalk from 'chalk';
export type BotConfig = typeof config;
-export class BotClient extends AkairoClient {
+export class BushClient extends AkairoClient {
public config: BotConfig;
public listenerHandler: ListenerHandler;
public inhibitorHandler: InhibitorHandler;
@@ -89,17 +83,12 @@ export class BotClient extends AkairoClient {
});
this.util = new Util(this);
- this.db = new Sequelize(
- this.config.dev ? 'bushbot-dev' : 'bushbot',
- this.config.db.username,
- this.config.db.password,
- {
- dialect: 'postgres',
- host: this.config.db.host,
- port: this.config.db.port,
- logging: false
- }
- );
+ this.db = new Sequelize(this.config.dev ? 'bushbot-dev' : 'bushbot', this.config.db.username, this.config.db.password, {
+ dialect: 'postgres',
+ host: this.config.db.host,
+ port: this.config.db.port,
+ logging: false
+ });
this.logger = new Logger(this);
}
@@ -122,15 +111,9 @@ export class BotClient extends AkairoClient {
for (const loader of Object.keys(loaders)) {
try {
loaders[loader].loadAll();
- this.logger.log(
- chalk.green('Successfully loaded ' + chalk.cyan(loader) + '.')
- );
+ this.logger.log(chalk.green('Successfully loaded ' + chalk.cyan(loader) + '.'));
} catch (e) {
- console.error(
- chalk.red(
- 'Unable to load loader ' + chalk.cyan(loader) + ' with error ' + e
- )
- );
+ console.error(chalk.red('Unable to load loader ' + chalk.cyan(loader) + ' with error ' + e));
}
}
this.taskHandler.startAll();
diff --git a/src/lib/extensions/BotCommand.ts b/src/lib/extensions/BushCommand.ts
index c5d31e9..4f9dc6e 100644
--- a/src/lib/extensions/BotCommand.ts
+++ b/src/lib/extensions/BushCommand.ts
@@ -1,8 +1,8 @@
import { Command, CommandOptions } from 'discord-akairo';
import { APIApplicationCommandOption } from 'discord-api-types';
-import { BotClient } from './BotClient';
+import { BushClient } from './BushClient';
-export interface BotCommandOptions extends CommandOptions {
+export interface BushCommandOptions extends CommandOptions {
slashCommandOptions?: APIApplicationCommandOption[];
description: {
content: string;
@@ -11,9 +11,9 @@ export interface BotCommandOptions extends CommandOptions {
};
}
-export class BotCommand extends Command {
- public client: BotClient;
- constructor(id: string, options?: BotCommandOptions) {
+export class BushCommand extends Command {
+ public client: BushClient;
+ constructor(id: string, options?: BushCommandOptions) {
super(id, options);
this.options = options;
}
diff --git a/src/lib/extensions/BushInhibitor.ts b/src/lib/extensions/BushInhibitor.ts
new file mode 100644
index 0000000..d9a9b68
--- /dev/null
+++ b/src/lib/extensions/BushInhibitor.ts
@@ -0,0 +1,6 @@
+import { Inhibitor } from 'discord-akairo';
+import { BushClient } from './BushClient';
+
+export class BushInhibitor extends Inhibitor {
+ public client: BushClient;
+}
diff --git a/src/lib/extensions/BushListener.ts b/src/lib/extensions/BushListener.ts
new file mode 100644
index 0000000..6a13210
--- /dev/null
+++ b/src/lib/extensions/BushListener.ts
@@ -0,0 +1,6 @@
+import { Listener } from 'discord-akairo';
+import { BushClient } from './BushClient';
+
+export class BushListener extends Listener {
+ public client: BushClient;
+}
diff --git a/src/lib/extensions/BushTask.ts b/src/lib/extensions/BushTask.ts
new file mode 100644
index 0000000..21655e9
--- /dev/null
+++ b/src/lib/extensions/BushTask.ts
@@ -0,0 +1,6 @@
+import { Task } from 'discord-akairo';
+import { BushClient } from './BushClient';
+
+export class BushTask extends Task {
+ public client: BushClient;
+}
diff --git a/src/lib/extensions/Util.ts b/src/lib/extensions/Util.ts
index 5e9d5e7..3e6882a 100644
--- a/src/lib/extensions/Util.ts
+++ b/src/lib/extensions/Util.ts
@@ -1,16 +1,11 @@
import { ClientUtil } from 'discord-akairo';
-import { BotClient } from './BotClient';
+import { BushClient } from './BushClient';
import { promisify } from 'util';
import { exec } from 'child_process';
import got from 'got';
import { MessageEmbed, GuildMember, User } from 'discord.js';
import { CommandInteractionOption } from 'discord.js';
-import {
- ApplicationCommandOptionType,
- APIInteractionDataResolvedGuildMember,
- APIInteractionDataResolvedChannel,
- APIRole
-} from 'discord-api-types';
+import { ApplicationCommandOptionType, APIInteractionDataResolvedGuildMember, APIInteractionDataResolvedChannel, APIRole } from 'discord-api-types';
import { GuildChannel } from 'discord.js';
import { Role } from 'discord.js';
import chalk from 'chalk';
@@ -57,9 +52,9 @@ export interface SlashCommandOption<T> {
export class Util extends ClientUtil {
/**
* The client of this ClientUtil
- * @type {BotClient}
+ * @type {BushClient}
*/
- public client: BotClient;
+ public client: BushClient;
/**
* The hastebin urls used to post to hastebin, attempts to post in order
* @type {string[]}
@@ -83,7 +78,7 @@ export class Util extends ClientUtil {
* Creates this client util
* @param client The client to initialize with
*/
- constructor(client: BotClient) {
+ constructor(client: BushClient) {
super(client);
}
@@ -125,9 +120,7 @@ export class Util extends ClientUtil {
public async haste(content: string): Promise<string> {
for (const url of this.hasteURLs) {
try {
- const res: hastebinRes = await got
- .post(`${url}/documents`, { body: content })
- .json();
+ const res: hastebinRes = await got.post(`${url}/documents`, { body: content }).json();
return `${url}/${res.key}`;
} catch (e) {
// pass
@@ -220,28 +213,18 @@ export class Util extends ClientUtil {
/**
* A simple utility to create and embed with the needed style for the bot
*/
- public createEmbed(
- color?: string,
- author?: User | GuildMember
- ): MessageEmbed {
+ public createEmbed(color?: string, author?: User | GuildMember): MessageEmbed {
if (author instanceof GuildMember) {
author = author.user; // Convert to User if GuildMember
}
let embed = new MessageEmbed().setTimestamp();
- if (author)
- embed = embed.setAuthor(
- author.username,
- author.displayAvatarURL({ dynamic: true }),
- `https://discord.com/users/${author.id}`
- );
+ if (author) embed = embed.setAuthor(author.username, author.displayAvatarURL({ dynamic: true }), `https://discord.com/users/${author.id}`);
if (color) embed = embed.setColor(color);
return embed;
}
public async mcUUID(username: string): Promise<string> {
- const apiRes = (await got
- .get(`https://api.ashcon.app/mojang/v2/user/${username}`)
- .json()) as uuidRes;
+ const apiRes = (await got.get(`https://api.ashcon.app/mojang/v2/user/${username}`).json()) as uuidRes;
return apiRes.uuid.replace(/-/g, '');
}
@@ -281,7 +264,7 @@ export class Util extends ClientUtil {
name: botCommand.id,
description: botCommand.description.content,
options: botCommand.options.slashCommandOptions
- };
+ };botCommand
if (found?.id && !force) {
if (slashdata.description !== found.description) {
diff --git a/src/lib/models/Ban.ts b/src/lib/models/Ban.ts
index ab7b38d..66c1be9 100644
--- a/src/lib/models/Ban.ts
+++ b/src/lib/models/Ban.ts
@@ -20,10 +20,7 @@ export interface BanModelCreationAttributes {
modlog: string;
}
-export class Ban
- extends BaseModel<BanModel, BanModelCreationAttributes>
- implements BanModel
-{
+export class Ban extends BaseModel<BanModel, BanModelCreationAttributes> implements BanModel {
/**
* The ID of this ban (no real use just for a primary key)
*/
diff --git a/src/lib/models/Guild.ts b/src/lib/models/Guild.ts
index 1cb3abb..7902461 100644
--- a/src/lib/models/Guild.ts
+++ b/src/lib/models/Guild.ts
@@ -1,5 +1,5 @@
import { DataTypes, Optional, Sequelize } from 'sequelize';
-import { BotClient } from '../extensions/BotClient';
+import { BushClient } from '../extensions/BushClient';
import { BaseModel } from './BaseModel';
export interface GuildModel {
@@ -8,13 +8,10 @@ export interface GuildModel {
}
export type GuildModelCreationAttributes = Optional<GuildModel, 'prefix'>;
-export class Guild
- extends BaseModel<GuildModel, GuildModelCreationAttributes>
- implements GuildModel
-{
+export class Guild extends BaseModel<GuildModel, GuildModelCreationAttributes> implements GuildModel {
id: string;
prefix: string;
- static initModel(seqeulize: Sequelize, client: BotClient): void {
+ static initModel(seqeulize: Sequelize, client: BushClient): void {
Guild.init(
{
id: {
diff --git a/src/lib/models/Modlog.ts b/src/lib/models/Modlog.ts
index 7e24ba6..3917a88 100644
--- a/src/lib/models/Modlog.ts
+++ b/src/lib/models/Modlog.ts
@@ -32,10 +32,7 @@ export interface ModlogModelCreationAttributes {
guild: string;
}
-export class Modlog
- extends BaseModel<ModlogModel, ModlogModelCreationAttributes>
- implements ModlogModel
-{
+export class Modlog extends BaseModel<ModlogModel, ModlogModelCreationAttributes> implements ModlogModel {
id: string;
type: ModlogType;
user: string;
@@ -54,14 +51,7 @@ export class Modlog
defaultValue: uuidv4
},
type: {
- type: new DataTypes.ENUM(
- 'BAN',
- 'TEMPBAN',
- 'MUTE',
- 'TEMPMUTE',
- 'KICK',
- 'WARN'
- ),
+ type: new DataTypes.ENUM('BAN', 'TEMPBAN', 'MUTE', 'TEMPMUTE', 'KICK', 'WARN'),
allowNull: false
},
user: {
diff --git a/src/lib/utils/AllowedMentions.ts b/src/lib/utils/AllowedMentions.ts
index 47e440b..68c44d7 100644
--- a/src/lib/utils/AllowedMentions.ts
+++ b/src/lib/utils/AllowedMentions.ts
@@ -34,11 +34,7 @@ export default class AllowedMentions {
}
public toObject(): MessageMentionOptions {
return {
- parse: [
- ...(this.users ? ['users'] : []),
- ...(this.roles ? ['roles'] : []),
- ...(this.everyone ? ['everyone'] : [])
- ] as MessageMentionTypes[]
+ parse: [...(this.users ? ['users'] : []), ...(this.roles ? ['roles'] : []), ...(this.everyone ? ['everyone'] : [])] as MessageMentionTypes[]
};
}
}
diff --git a/src/lib/utils/Console.ts b/src/lib/utils/Console.ts
new file mode 100644
index 0000000..b74ea07
--- /dev/null
+++ b/src/lib/utils/Console.ts
@@ -0,0 +1,93 @@
+// import chalk from 'chalk';
+// import { BushClient } from '../extensions/BushClient';
+
+// export class CustomConsole {
+// private client: BushClient;
+// public constructor(client: BushClient) {
+// this.client = client;
+// }
+
+// private parseColors(content: any, color: 'blueBright' | 'blackBright' | 'redBright' | 'yellowBright' | 'greenBright'): string | any {
+// if (typeof content === 'string') {
+// const newContent: Array<string> = content.split(/<<|>>/);
+// const tempParsedArray: Array<string> = [];
+// newContent.forEach((value, index) => {
+// if (index % 2 !== 0) {
+// tempParsedArray.push(chalk[color](value));
+// } else {
+// tempParsedArray.push(value);
+// }
+// });
+// return tempParsedArray.join('');
+// } else {
+// return content;
+// }
+// }
+
+// private timeStamp(): string {
+// const now = new Date();
+// const hours = now.getHours();
+// const minute = now.getMinutes();
+// let hour = hours;
+// let amOrPm: 'AM' | 'PM' = 'AM';
+// if (hour > 12) {
+// amOrPm = 'PM';
+// hour = hour - 12;
+// }
+
+// return `${hour >= 10 ? hour : `0${hour}`}:${minute >= 10 ? minute : `0${minute}`} ${amOrPm}`;
+// }
+
+// /**
+// * Logs debug information.
+// * @param content - The content to log.
+// */
+// public debug(content: any): void {
+// console.log(`${chalk.bgGrey(this.timeStamp())} ${chalk.grey('[Debug]')}`, content);
+// }
+
+// /**
+// * Logs verbose information. Highlight information by surrounding it in `<<>>`.
+// * @param header - The header displayed before the content, displayed in grey.
+// * @param content - The content to log, highlights displayed in bright black.
+// */
+// public verbose(header: string, content: string): void {
+// return console.info(`${chalk.bgGrey(this.timeStamp())} ${chalk.grey(`[${header}]`)} ` + this.parseColors(content, 'blackBright'));
+// }
+
+// /**
+// * Logs information. Highlight information by surrounding it in `<<>>`.
+// * @param header - The header displayed before the content, displayed in cyan.
+// * @param content - The content to log, highlights displayed in bright blue.
+// */
+// public info(header: string, content: string): void {
+// return console.info(`${chalk.bgCyan(this.timeStamp())} ${chalk.cyan(`[${header}]`)} ` + this.parseColors(content, 'blueBright'));
+// }
+
+// /**
+// * Logs warnings. Highlight information by surrounding it in `<<>>`.
+// * @param header - The header displayed before the content, displayed in yellow.
+// * @param content - The content to log, highlights displayed in bright yellow.
+// */
+// public warn(header: string, content: string): void {
+// return console.warn(`${chalk.bgYellow(this.timeStamp())} ${chalk.yellow(`[${header}]`)} ` + this.parseColors(content, 'yellowBright'));
+// }
+
+// /**
+// * Logs errors. Highlight information by surrounding it in `<<>>`.
+// * @param header - The header displayed before the content, displayed in bright red.
+// * @param content - The content to log, highlights displayed in bright red.
+// */
+// public error(header: string, content: string): void {
+// return console.error(`${chalk.bgRedBright(this.timeStamp())} ${chalk.redBright(`[${header}]`)} ` + this.parseColors(content, 'redBright'));
+// }
+
+// /**
+// * Logs successes. Highlight information by surrounding it in `<<>>`.
+// * @param header - The header displayed before the content, displayed in green.
+// * @param content - The content to log, highlights displayed in bright green.
+// */
+// public success(header: string, content: string): void {
+// return console.log(`${chalk.bgGreen(this.timeStamp())} ${chalk.greenBright(`[${header}]`)} ` + this.parseColors(content, 'greenBright'));
+// }
+// }
diff --git a/src/lib/utils/Logger.ts b/src/lib/utils/Logger.ts
index f38365e..96837b6 100644
--- a/src/lib/utils/Logger.ts
+++ b/src/lib/utils/Logger.ts
@@ -1,10 +1,10 @@
import { TextChannel } from 'discord.js';
-import { BotClient } from '../extensions/BotClient';
+import { BushClient } from '../extensions/BushClient';
import chalk from 'chalk';
export class Logger {
- private client: BotClient;
- public constructor(client: BotClient) {
+ private client: BushClient;
+ public constructor(client: BushClient) {
this.client = client;
}
private stripColor(text: string): string {
@@ -15,9 +15,7 @@ export class Logger {
);
}
public getChannel(channel: 'log' | 'error' | 'dm'): Promise<TextChannel> {
- return this.client.channels.fetch(
- this.client.config.channels[channel]
- ) as Promise<TextChannel>;
+ return this.client.channels.fetch(this.client.config.channels[channel]) as Promise<TextChannel>;
}
public async log(message: string, sendChannel = false): Promise<void> {
console.log(chalk`{bgCyan LOG} ` + message);
@@ -28,7 +26,7 @@ export class Logger {
}
public async verbose(message: string, sendChannel = false): Promise<void> {
- if (!this.client.config.verbose) return;
+ if (!this.client.config.logging.verbose) return;
console.log(chalk`{bgMagenta VERBOSE} ` + message);
if (sendChannel) {
const channel = await this.getChannel('log');
diff --git a/src/listeners/client/ready.ts b/src/listeners/client/ready.ts
index fc43f3c..d4b2808 100644
--- a/src/listeners/client/ready.ts
+++ b/src/listeners/client/ready.ts
@@ -1,7 +1,7 @@
import chalk from 'chalk';
-import { BotListener } from '../../lib/extensions/BotListener';
+import { BushListener } from '../../lib/extensions/BushListener';
-export default class CommandBlockedListener extends BotListener {
+export default class ReadyListener extends BushListener {
public constructor() {
super('ready', {
emitter: 'client',
@@ -10,9 +10,6 @@ export default class CommandBlockedListener extends BotListener {
}
public async exec(): Promise<void> {
- await this.client.logger.log(
- chalk`{green Sucessfully logged in as {cyan ${this.client.user.tag}}.}`,
- true
- );
+ await this.client.logger.log(chalk`{green Sucessfully logged in as {cyan ${this.client.user.tag}}.}`, true);
}
}
diff --git a/src/listeners/client/syncslashcommands.ts b/src/listeners/client/syncSlashCommands.ts
index febdd1b..7835136 100644
--- a/src/listeners/client/syncslashcommands.ts
+++ b/src/listeners/client/syncSlashCommands.ts
@@ -1,8 +1,8 @@
-import { BotListener } from '../../lib/extensions/BotListener';
+import { BushListener } from '../../lib/extensions/BushListener';
-export default class CreateSlashCommands extends BotListener {
+export default class SyncSlashCommandsListener extends BushListener {
constructor() {
- super('createslashcommands', {
+ super('syncslashcommands', {
emitter: 'client',
event: 'ready'
});
diff --git a/src/listeners/commands/commandblocked.ts b/src/listeners/commands/commandBlocked.ts
index 82e53a9..916f7cd 100644
--- a/src/listeners/commands/commandblocked.ts
+++ b/src/listeners/commands/commandBlocked.ts
@@ -1,8 +1,8 @@
-import { BotListener } from '../../lib/extensions/BotListener';
+import { BushListener } from '../../lib/extensions/BushListener';
import { Command } from 'discord-akairo';
import { Message } from 'discord.js';
-export default class CommandBlockedListener extends BotListener {
+export default class CommandBlockedListener extends BushListener {
public constructor() {
super('commandBlocked', {
emitter: 'commandHandler',
@@ -10,16 +10,10 @@ export default class CommandBlockedListener extends BotListener {
});
}
- public async exec(
- message: Message,
- command: Command,
- reason: string
- ): Promise<void> {
+ public async exec(message: Message, command: Command, reason: string): Promise<void> {
switch (reason) {
case 'owner': {
- await message.util.send(
- `You must be an owner to run command \`${message.util.parsed.command}\``
- );
+ await message.util.send(`You must be an owner to run command \`${message.util.parsed.command}\``);
break;
}
case 'blacklist': {
diff --git a/src/listeners/commands/error.ts b/src/listeners/commands/commandError.ts
index 37179e7..0e52140 100644
--- a/src/listeners/commands/error.ts
+++ b/src/listeners/commands/commandError.ts
@@ -1,22 +1,18 @@
-import { BotCommand } from '../../lib/extensions/BotCommand';
-import { BotListener } from '../../lib/extensions/BotListener';
+import { BushCommand } from '../../lib/extensions/BushCommand';
+import { BushListener } from '../../lib/extensions/BushListener';
import { stripIndents } from 'common-tags';
import { Message } from 'discord.js';
import { MessageEmbed } from 'discord.js';
import { TextChannel } from 'discord.js';
-export default class CommandErrorListener extends BotListener {
+export default class CommandErrorListener extends BushListener {
constructor() {
super('error', {
emitter: 'commandHandler',
event: 'error'
});
}
- async exec(
- error: Error,
- message: Message,
- command?: BotCommand
- ): Promise<void> {
+ async exec(error: Error, message: Message, command?: BushCommand): Promise<void> {
const errorNumber = Math.floor(Math.random() * 6969696969) + 69; // hehe funy numbers
const errorDevEmbed = this.client.util
.createEmbed(this.client.util.colors.error)
@@ -39,9 +35,7 @@ export default class CommandErrorListener extends BotListener {
`
);
}
- const channel = (await this.client.channels.fetch(
- this.client.config.channels.log
- )) as TextChannel;
+ const channel = (await this.client.channels.fetch(this.client.config.channels.log)) as TextChannel;
await channel.send(errorDevEmbed);
if (errorUserEmbed) await message.reply(errorUserEmbed);
}
diff --git a/src/listeners/commands/commandStarted.ts b/src/listeners/commands/commandStarted.ts
new file mode 100644
index 0000000..1c5b0c7
--- /dev/null
+++ b/src/listeners/commands/commandStarted.ts
@@ -0,0 +1,20 @@
+import chalk from 'chalk';
+import { Message, DMChannel } from 'discord.js';
+import { BushCommand } from '../../lib/extensions/BushCommand';
+import { BushListener } from '../../lib/extensions/BushListener';
+
+export default class CommandStartedListener extends BushListener {
+ constructor() {
+ super('logCommands', {
+ emitter: 'commandHandler',
+ event: 'commandStarted'
+ });
+ }
+ exec(message: Message, command: BushCommand): void {
+ this.client.logger.verbose(
+ chalk`{cyan {green ${message.author.tag}} is running {green ${command.aliases[0]}} in {green ${
+ message.channel instanceof DMChannel ? 'DMs' : `#${message.channel.name} (Server: ${message.guild.name})`
+ }}.}`
+ );
+ }
+}
diff --git a/src/listeners/commands/commandstarted.ts b/src/listeners/commands/commandstarted.ts
deleted file mode 100644
index 15eea9d..0000000
--- a/src/listeners/commands/commandstarted.ts
+++ /dev/null
@@ -1,24 +0,0 @@
-import chalk from 'chalk';
-import { Message, DMChannel } from 'discord.js';
-import { BotCommand } from '../../lib/extensions/BotCommand';
-import { BotListener } from '../../lib/extensions/BotListener';
-
-export default class CommandStartedListener extends BotListener {
- constructor() {
- super('logCommands', {
- emitter: 'commandHandler',
- event: 'commandStarted'
- });
- }
- exec(message: Message, command: BotCommand): void {
- this.client.logger.verbose(
- chalk`{cyan {green ${message.author.tag}} is running {green ${
- command.aliases[0]
- }} in {green ${
- message.channel instanceof DMChannel
- ? 'DMs'
- : `#${message.channel.name} (Server: ${message.guild.name})`
- }}.}`
- );
- }
-}
diff --git a/src/listeners/commands/slashError.ts b/src/listeners/commands/slashCommandError.ts
index 3b174a3..e4c3bb0 100644
--- a/src/listeners/commands/slashError.ts
+++ b/src/listeners/commands/slashCommandError.ts
@@ -1,22 +1,18 @@
-import { BotCommand } from '../../lib/extensions/BotCommand';
-import { BotListener } from '../../lib/extensions/BotListener';
+import { BushCommand } from '../../lib/extensions/BushCommand';
+import { BushListener } from '../../lib/extensions/BushListener';
import { stripIndents } from 'common-tags';
import { MessageEmbed } from 'discord.js';
import { TextChannel } from 'discord.js';
import { CommandInteraction } from 'discord.js';
-export default class CommandErrorListener extends BotListener {
+export default class SlashCommandErrorListener extends BushListener {
constructor() {
super('slashError', {
emitter: 'commandHandler',
event: 'slashError'
});
}
- async exec(
- error: Error,
- message: CommandInteraction,
- command: BotCommand
- ): Promise<void> {
+ async exec(error: Error, message: CommandInteraction, command: BushCommand): Promise<void> {
const errorNumber = Math.floor(Math.random() * 6969696969) + 69; // hehe funy numbers
const errorDevEmbed = this.client.util
.createEmbed(this.client.util.colors.error)
@@ -39,9 +35,7 @@ export default class CommandErrorListener extends BotListener {
`
);
}
- const channel = (await this.client.channels.fetch(
- this.client.config.channels.log
- )) as TextChannel;
+ const channel = (await this.client.channels.fetch(this.client.config.channels.log)) as TextChannel;
await channel.send(errorDevEmbed);
if (errorUserEmbed) await message.reply(errorUserEmbed);
}
diff --git a/src/listeners/guild/syncunban.ts b/src/listeners/guild/syncUnban.ts
index 14f8820..81a08f8 100644
--- a/src/listeners/guild/syncunban.ts
+++ b/src/listeners/guild/syncUnban.ts
@@ -1,8 +1,8 @@
import { User, Guild } from 'discord.js';
-import { BotListener } from '../../lib/extensions/BotListener';
+import { BushListener } from '../../lib/extensions/BushListener';
import { Ban } from '../../lib/models';
-export default class CommandBlockedListener extends BotListener {
+export default class SyncUnbanListener extends BushListener {
public constructor() {
super('guildBanRemove', {
emitter: 'client',
diff --git a/src/listeners/message/levels.ts b/src/listeners/message/level.ts
index 9a5fbe8..1e93055 100644
--- a/src/listeners/message/levels.ts
+++ b/src/listeners/message/level.ts
@@ -1,9 +1,9 @@
import chalk from 'chalk';
import { Message } from 'discord.js';
-import { BotListener } from '../../lib/extensions/BotListener';
+import { BushListener } from '../../lib/extensions/BushListener';
import { Level } from '../../lib/models';
-export default class LevelListener extends BotListener {
+export default class LevelListener extends BushListener {
private levelCooldowns: Set<string> = new Set();
private blacklistedChannels = ['702456294874808330'];
constructor() {
@@ -16,9 +16,9 @@ export default class LevelListener extends BotListener {
if (message.author.bot) return;
if (message.util?.parsed?.command) return;
if (this.levelCooldowns.has(message.author.id)) return;
- if (!this.client.config.dev && message.guild.id != '516977525906341928')
- return;
+ if (!this.client.config.dev && message.guild.id != '516977525906341928') return;
if (this.blacklistedChannels.includes(message.channel.id)) return;
+ if (!['DEFAULT', 'REPLY'].includes(message.type)) return; //checks for join messages, slash commands, booster messages etc
const [user] = await Level.findOrBuild({
where: {
id: message.author.id
@@ -30,9 +30,7 @@ export default class LevelListener extends BotListener {
const xpToGive = Level.genRandomizedXp();
user.xp += xpToGive;
await user.save();
- await this.client.logger.verbose(
- chalk`{cyan Gave XP to {green ${message.author.tag}}: {green ${xpToGive}xp}.}`
- );
+ await this.client.logger.verbose(chalk`{cyan Gave XP to {green ${message.author.tag}}: {green ${xpToGive}xp}.}`);
this.levelCooldowns.add(message.author.id);
setTimeout(() => this.levelCooldowns.delete(message.author.id), 60_000);
}
diff --git a/src/tasks/Unban.ts b/src/tasks/unban.ts
index c6f9a01..564a2a3 100644
--- a/src/tasks/Unban.ts
+++ b/src/tasks/unban.ts
@@ -1,10 +1,10 @@
import chalk from 'chalk';
import { DiscordAPIError } from 'discord.js';
import { Op } from 'sequelize';
-import { BotTask } from '../lib/extensions/BotTask';
+import { BushTask } from '../lib/extensions/BushTask';
import { Ban } from '../lib/models';
-export default class UnbanTask extends BotTask {
+export default class UnbanTask extends BushTask {
constructor() {
super('unban', {
delay: 30_000, // 1/2 min
@@ -23,9 +23,7 @@ export default class UnbanTask extends BotTask {
]
}
});
- this.client.logger.verbose(
- chalk.cyan(`Queried bans, found ${rows.length} expired bans.`)
- );
+ this.client.logger.verbose(chalk.cyan(`Queried bans, found ${rows.length} expired bans.`));
for (const row of rows) {
const guild = this.client.guilds.cache.get(row.guild);
if (!guild) {
@@ -33,10 +31,7 @@ export default class UnbanTask extends BotTask {
continue;
}
try {
- await guild.members.unban(
- row.user,
- `Unbanning user because tempban expired`
- );
+ await guild.members.unban(row.user, `Unbanning user because tempban expired`);
} catch (e) {
if (e instanceof DiscordAPIError) {
// Member not banned, ignore
diff --git a/tsconfig.json b/tsconfig.json
index e51e0b3..4177350 100644
--- a/tsconfig.json
+++ b/tsconfig.json
@@ -3,14 +3,7 @@
"module": "commonjs",
"target": "esNext",
"outDir": "dist",
- "lib": [
- "ESNext",
- "ESNext.Array",
- "ESNext.AsyncIterable",
- "ESNext.Intl",
- "ESNext.Symbol",
- "DOM"
- ],
+ "lib": ["ESNext", "ESNext.Array", "ESNext.AsyncIterable", "ESNext.Intl", "ESNext.Symbol", "DOM"],
"sourceMap": false,
"inlineSourceMap": true,
"inlineSources": true,