aboutsummaryrefslogtreecommitdiff
path: root/src/commands/moderation
diff options
context:
space:
mode:
Diffstat (limited to 'src/commands/moderation')
-rw-r--r--src/commands/moderation/_lockdown.ts1
-rw-r--r--src/commands/moderation/ban.ts3
-rw-r--r--src/commands/moderation/evidence.ts60
-rw-r--r--src/commands/moderation/kick.ts2
-rw-r--r--src/commands/moderation/modlog.ts12
-rw-r--r--src/commands/moderation/mute.ts1
-rw-r--r--src/commands/moderation/purge.ts70
-rw-r--r--src/commands/moderation/unban.ts2
-rw-r--r--src/commands/moderation/unmute.ts3
-rw-r--r--src/commands/moderation/warn.ts1
10 files changed, 147 insertions, 8 deletions
diff --git a/src/commands/moderation/_lockdown.ts b/src/commands/moderation/_lockdown.ts
index 374e8f1..32dbd5b 100644
--- a/src/commands/moderation/_lockdown.ts
+++ b/src/commands/moderation/_lockdown.ts
@@ -31,6 +31,7 @@ export default class LockdownCommand extends BushCommand {
userPermissions: ['SEND_MESSAGES']
});
}
+
public override async exec(message: BushMessage | BushSlashMessage, { all }: { all: boolean }): Promise<unknown> {
return await message.util.reply('no');
if (!all) {
diff --git a/src/commands/moderation/ban.ts b/src/commands/moderation/ban.ts
index cfa3e31..bda0e2b 100644
--- a/src/commands/moderation/ban.ts
+++ b/src/commands/moderation/ban.ts
@@ -80,7 +80,8 @@ export default class BanCommand extends BushCommand {
userPermissions: ['BAN_MEMBERS']
});
}
- override async exec(
+
+ public override async exec(
message: BushMessage | BushSlashMessage,
{
user,
diff --git a/src/commands/moderation/evidence.ts b/src/commands/moderation/evidence.ts
new file mode 100644
index 0000000..96c3944
--- /dev/null
+++ b/src/commands/moderation/evidence.ts
@@ -0,0 +1,60 @@
+import { BushCommand, BushMessage, BushSlashMessage } from '@lib';
+
+export default class EvidenceCommand extends BushCommand {
+ public constructor() {
+ super('evidence', {
+ aliases: ['evidence'],
+ category: 'moderation',
+ description: {
+ content: 'Add evidence to a modlog case.',
+ usage: 'evidence <caseID> <evidence>',
+ examples: ['evidence ']
+ },
+ args: [
+ {
+ id: 'required_argument',
+ type: 'string',
+ prompt: {
+ start: 'What would you like to set your first argument to be?',
+ retry: '{error} Pick a valid argument.',
+ optional: false
+ }
+ },
+ {
+ id: 'optional_argument',
+ type: 'string',
+ prompt: {
+ start: 'What would you like to set your second argument to be?',
+ retry: '{error} Pick a valid argument.',
+ optional: true
+ }
+ }
+ ],
+ slash: true,
+ slashOptions: [
+ {
+ name: 'required_argument',
+ description: 'What would you like to set your first argument to be?',
+ type: 'STRING',
+ required: true
+ },
+ {
+ name: 'optional_argument',
+ description: 'What would you like to set your second argument to be?',
+ type: 'STRING',
+ required: false
+ }
+ ],
+ superUserOnly: true,
+ ownerOnly: true,
+ channel: 'guild',
+ hidden: true,
+ clientPermissions: ['SEND_MESSAGES'],
+ userPermissions: ['SEND_MESSAGES']
+ });
+ }
+
+ public override async exec(message: BushMessage | BushSlashMessage): Promise<unknown> {
+ return await message.util.reply(`${util.emojis.error} Do not use the template command.`);
+ }
+}
diff --git a/src/commands/moderation/kick.ts b/src/commands/moderation/kick.ts
index c425124..2fc133e 100644
--- a/src/commands/moderation/kick.ts
+++ b/src/commands/moderation/kick.ts
@@ -55,7 +55,7 @@ export default class KickCommand extends BushCommand {
});
}
- override async exec(
+ public override async exec(
message: BushMessage | BushSlashMessage,
{ user, reason, force }: { user: BushUser; reason?: string; force: boolean }
): Promise<unknown> {
diff --git a/src/commands/moderation/modlog.ts b/src/commands/moderation/modlog.ts
index 8f727a5..84bb5b5 100644
--- a/src/commands/moderation/modlog.ts
+++ b/src/commands/moderation/modlog.ts
@@ -34,7 +34,7 @@ export default class ModlogCommand extends BushCommand {
});
}
- private generateModlogInfo(log: ModLog) {
+ #generateModlogInfo(log: ModLog): string {
const modLog = [
`**Case ID**: ${log.id}`,
`**Type**: ${log.type.toLowerCase()}`,
@@ -43,10 +43,14 @@ export default class ModlogCommand extends BushCommand {
];
if (log.duration) modLog.push(`**Duration**: ${util.humanizeDuration(log.duration)}`);
modLog.push(`**Reason**: ${log.reason || 'No Reason Specified.'}`);
+ if (log.evidence) modLog.push(`**Evidence:** ${log.evidence}`);
return modLog.join(`\n`);
}
- override async exec(message: BushMessage | BushSlashMessage, { search }: { search: BushUser | string }): Promise<unknown> {
+ public override async exec(
+ message: BushMessage | BushSlashMessage,
+ { search }: { search: BushUser | string }
+ ): Promise<unknown> {
const foundUser = search instanceof User ? search : await util.resolveUserAsync(search);
if (foundUser) {
const logs = await ModLog.findAll({
@@ -59,7 +63,7 @@ export default class ModlogCommand extends BushCommand {
if (!logs.length) return message.util.reply(`${util.emojis.error} **${foundUser.tag}** does not have any modlogs.`);
const niceLogs: string[] = [];
for (const log of logs) {
- niceLogs.push(this.generateModlogInfo(log));
+ niceLogs.push(this.#generateModlogInfo(log));
}
const chunked: string[][] = util.chunk(niceLogs, 3);
const embedPages = chunked.map(
@@ -76,7 +80,7 @@ export default class ModlogCommand extends BushCommand {
if (!entry) return message.util.send(`${util.emojis.error} That modlog does not exist.`);
const embed = new MessageEmbed({
title: `Case ${entry.id}`,
- description: this.generateModlogInfo(entry),
+ description: this.#generateModlogInfo(entry),
color: util.colors.default
});
return await util.buttonPaginate(message, [embed]);
diff --git a/src/commands/moderation/mute.ts b/src/commands/moderation/mute.ts
index df8e235..9f66558 100644
--- a/src/commands/moderation/mute.ts
+++ b/src/commands/moderation/mute.ts
@@ -56,6 +56,7 @@ export default class MuteCommand extends BushCommand {
userPermissions: ['MANAGE_MESSAGES']
});
}
+
public override async exec(
message: BushMessage | BushSlashMessage,
{ user, reason, force }: { user: BushUser; reason?: { duration: number; contentWithoutTime: string }; force: boolean }
diff --git a/src/commands/moderation/purge.ts b/src/commands/moderation/purge.ts
new file mode 100644
index 0000000..f4a53a8
--- /dev/null
+++ b/src/commands/moderation/purge.ts
@@ -0,0 +1,70 @@
+import { BushCommand, BushMessage } from '../../lib';
+
+export default class PurgeCommand extends BushCommand {
+ public constructor() {
+ super('purge', {
+ aliases: ['purge'],
+ category: 'moderation',
+ description: {
+ content: 'A command to mass delete messages.',
+ usage: 'purge <amount>',
+ examples: ['Purge 20']
+ },
+ args: [
+ {
+ id: 'amount',
+ customType: util.arg.range('integer', 1, 100, true),
+ prompt: {
+ start: 'How many messages would you like to purge?',
+ retry: '{error} Please pick a number between 1 and 100.'
+ }
+ },
+ {
+ id: 'bot',
+ match: 'flag',
+ flag: '--bot'
+ },
+ { id: 'user', match: 'option', flag: '--user' }
+ ],
+ slash: true,
+ slashOptions: [
+ { name: 'amount', description: 'How many messages would you like to purge?', type: 'INTEGER', required: true },
+ {
+ name: 'bot',
+ description: 'Would you like to only delete messages that are from bots?',
+ type: 'BOOLEAN',
+ required: false
+ }
+ ],
+ clientPermissions: ['MANAGE_MESSAGES', 'SEND_MESSAGES', 'EMBED_LINKS'],
+ userPermissions: ['MANAGE_MESSAGES'],
+ channel: 'guild'
+ });
+ }
+
+ public override async exec(message: BushMessage, args: { amount: number; bot: boolean }): Promise<unknown> {
+ if (message.channel.type === 'DM') return message.util.reply(`${util.emojis.error} You cannot run this command in dms.`);
+ if (args.amount > 100 || args.amount < 1) return message.util.reply(`${util.emojis.error} `);
+
+ const messages = (await message.channel.messages.fetch({ limit: args.amount })).filter((message) => filter(message));
+ const filter = (filterMessage: BushMessage): boolean => {
+ const shouldFilter = new Array<boolean>();
+ if (args.bot) {
+ shouldFilter.push(filterMessage.author.bot);
+ }
+ };
+
+ const purged = await message.channel.bulkDelete(messages, true).catch(() => {});
+ if (!purged) return message.util.reply(`${util.emojis.error} Failed to purge messages.`).catch(() => {});
+ else {
+ await message.util
+ .send(`${util.emojis.success} Successfully purged **${purged.size}** messages.`)
+ .then(async (purgeMessage: BushMessage) => {
+ if (!message.util.isSlash) {
+ await util.sleep(5);
+ await purgeMessage.delete().catch(() => {});
+ }
+ });
+ }
+ }
+}
diff --git a/src/commands/moderation/unban.ts b/src/commands/moderation/unban.ts
index 522c715..545d75c 100644
--- a/src/commands/moderation/unban.ts
+++ b/src/commands/moderation/unban.ts
@@ -51,7 +51,7 @@ export default class UnbanCommand extends BushCommand {
userPermissions: ['BAN_MEMBERS']
});
}
- override async exec(
+ public override async exec(
message: BushMessage | BushSlashMessage,
{ user, reason }: { user: BushUser; reason?: string }
): Promise<unknown> {
diff --git a/src/commands/moderation/unmute.ts b/src/commands/moderation/unmute.ts
index 6cdb08b..918c27f 100644
--- a/src/commands/moderation/unmute.ts
+++ b/src/commands/moderation/unmute.ts
@@ -50,7 +50,8 @@ export default class UnmuteCommand extends BushCommand {
userPermissions: ['MANAGE_MESSAGES']
});
}
- override async exec(
+
+ public override async exec(
message: BushMessage | BushSlashMessage,
{ user, reason }: { user: BushUser; reason?: string }
): Promise<unknown> {
diff --git a/src/commands/moderation/warn.ts b/src/commands/moderation/warn.ts
index 1067033..1aa14c3 100644
--- a/src/commands/moderation/warn.ts
+++ b/src/commands/moderation/warn.ts
@@ -54,6 +54,7 @@ export default class WarnCommand extends BushCommand {
userPermissions: ['MANAGE_MESSAGES']
});
}
+
public override async exec(
message: BushMessage | BushSlashMessage,
{ user, reason, force }: { user: BushUser; reason: string; force: boolean }