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