aboutsummaryrefslogtreecommitdiff
path: root/src/commands/moderation
diff options
context:
space:
mode:
Diffstat (limited to 'src/commands/moderation')
-rw-r--r--src/commands/moderation/_lockdown.ts23
-rw-r--r--src/commands/moderation/activePunishments.ts76
-rw-r--r--src/commands/moderation/ban.ts73
-rw-r--r--src/commands/moderation/evidence.ts32
-rw-r--r--src/commands/moderation/hideCase.ts24
-rw-r--r--src/commands/moderation/kick.ts49
-rw-r--r--src/commands/moderation/modlog.ts46
-rw-r--r--src/commands/moderation/mute.ts49
-rw-r--r--src/commands/moderation/purge.ts57
-rw-r--r--src/commands/moderation/removeReactionEmoji.ts48
-rw-r--r--src/commands/moderation/role.ts123
-rw-r--r--src/commands/moderation/slowmode.ts44
-rw-r--r--src/commands/moderation/unban.ts42
-rw-r--r--src/commands/moderation/unmute.ts49
-rw-r--r--src/commands/moderation/warn.ts49
15 files changed, 381 insertions, 403 deletions
diff --git a/src/commands/moderation/_lockdown.ts b/src/commands/moderation/_lockdown.ts
index 029db29..08d4011 100644
--- a/src/commands/moderation/_lockdown.ts
+++ b/src/commands/moderation/_lockdown.ts
@@ -5,27 +5,21 @@ export default class LockdownCommand extends BushCommand {
super('lockdown', {
aliases: ['lockdown', 'unlockdown'],
category: 'moderation',
- description: {
- content: 'Allows you to lockdown a channel or all configured channels..',
- usage: ['lockdown [--all]'],
- examples: ['lockdown', 'lockdown --all']
- },
+ description: 'Allows you to lockdown a channel or all configured channels..',
+ usage: ['lockdown [--all]'],
+ examples: ['lockdown', 'lockdown --all'],
args: [
{
id: 'all',
+ description: 'Whether or not to lock all channels',
match: 'flag',
- flag: '--all'
+ flag: '--all',
+ prompt: 'Would you like to lockdown all channels?',
+ slashType: 'BOOLEAN',
+ optional: true
}
],
slash: true,
- slashOptions: [
- {
- name: 'all',
- description: 'Would you like to lockdown all channels?',
- type: 'BOOLEAN',
- required: false
- }
- ],
channel: 'guild',
clientPermissions: (m) => util.clientSendAndPermCheck(m),
userPermissions: [],
@@ -34,6 +28,7 @@ export default class LockdownCommand extends BushCommand {
}
public override async exec(message: BushMessage | BushSlashMessage, args: { all: boolean }) {
+ // todo stop being lazy
return await message.util.reply('Unfortunately my developer is too lazy to implement this command.');
if (!args.all) {
if (!['GUILD_TEXT', 'GUILD_NEWS'].includes(message.channel!.type))
diff --git a/src/commands/moderation/activePunishments.ts b/src/commands/moderation/activePunishments.ts
new file mode 100644
index 0000000..d40f2ba
--- /dev/null
+++ b/src/commands/moderation/activePunishments.ts
@@ -0,0 +1,76 @@
+// import { BushCommand, ModLog, ModLogModel, type BushGuildMember, type BushMessage, type BushSlashMessage } from '#lib';
+// import { FindOptions, Op } from 'sequelize';
+
+// const punishmentTypes = ['ban', 'kick', 'mute', 'warn', 'role'] as const;
+
+// export default class ActivePunishmentsCommand extends BushCommand {
+// public constructor() {
+// super('active-punishments', {
+// aliases: ['active-punishments', 'ap'],
+// category: 'moderation',
+// description: 'Gets a list of all the active punishment in the server.',
+// usage: [`active-punishments [--moderator <user>] [--type <${punishmentTypes.map((v) => `'${v}'`).join('|')}>]`],
+// examples: ['active-punishments'],
+// args: [
+// {
+// id: 'moderator',
+// description: 'Only show active punishments by this moderator.',
+// type: 'user',
+// match: 'option',
+// prompt: 'Only show active punishments from what user?',
+// optional: true,
+// slashType: 'USER',
+// slashResolve: 'member'
+// },
+// {
+// id: 'type',
+// description: 'Only show active punishments of this type.',
+// customType: [...punishmentTypes],
+// readableType: punishmentTypes.map((v) => `'${v}'`).join('|'),
+// match: 'option',
+// optional: true,
+// slashType: 'STRING',
+// choices: punishmentTypes.map((v) => ({ name: v, value: v }))
+// }
+// ],
+// slash: true,
+// channel: 'guild',
+// hidden: true,
+// clientPermissions: (m) => util.clientSendAndPermCheck(m),
+// userPermissions: (m) => util.userGuildPermCheck(m, ['MANAGE_MESSAGES'])
+// });
+// }
+// public override async exec(
+// message: BushMessage | BushSlashMessage,
+// args: { moderator?: BushGuildMember; type: typeof punishmentTypes[number] }
+// ) {
+// const where: FindOptions<ModLogModel>['where'] = { guild: message.guild!.id };
+// if (args.moderator?.id) where.user = args.moderator.id;
+// if (args.type) {
+// switch (args.type) {
+// case 'ban':
+// where.type = { [Op.or]: ['PERM_BAN', 'TEMP_BAN', 'UNBAN'] };
+// break;
+// case 'kick':
+// where.type = { [Op.or]: ['KICK'] };
+// break;
+// case 'mute':
+// where.type = { [Op.or]: ['PERM_MUTE', 'TEMP_MUTE', 'UNMUTE'] };
+// break;
+// case 'warn':
+// where.type = { [Op.or]: ['WARN'] };
+// break;
+// case 'role':
+// where.type = { [Op.or]: ['PERM_PUNISHMENT_ROLE', 'TEMP_PUNISHMENT_ROLE', 'REMOVE_PUNISHMENT_ROLE'] };
+// break;
+// default:
+// return message.util.reply(`${util.emojis.error} You supplied an invalid case type to filter by.`);
+// }
+// }
+
+// const logs = await ModLog.findAll({
+// where,
+// order: [['createdAt', 'ASC']]
+// });
+// }
+// }
diff --git a/src/commands/moderation/ban.ts b/src/commands/moderation/ban.ts
index 7c0d010..3d68a97 100644
--- a/src/commands/moderation/ban.ts
+++ b/src/commands/moderation/ban.ts
@@ -6,73 +6,52 @@ export default class BanCommand extends BushCommand {
super('ban', {
aliases: ['ban', 'force-ban', 'dban'],
category: 'moderation',
- description: {
- content: 'Ban a member from the server.',
- usage: ['ban <member> <reason> [--delete]'],
- examples: ['ban ironm00n 1 day commands in #general --delete 7']
- },
+ description: 'Ban a member from the server.',
+ usage: ['ban <member> <reason> [--delete]'],
+ examples: ['ban ironm00n 1 day commands in #general --delete 7'],
args: [
{
id: 'user',
+ description: 'The user that will be banned.',
customType: util.arg.union('user', 'snowflake'),
- prompt: {
- start: 'What user would you like to ban?',
- retry: '{error} Choose a valid user to ban.'
- }
+ prompt: 'What user would you like to ban?',
+ retry: '{error} Choose a valid user to ban.',
+ slashType: 'USER'
},
{
id: 'reason',
+ description: 'The reason and duration of the ban.',
type: 'contentWithDuration',
match: 'restContent',
- prompt: {
- start: 'Why should this user be banned and for how long?',
- retry: '{error} Choose a valid ban reason and duration.',
- optional: true
- }
+ prompt: 'Why should this user be banned and for how long?',
+ retry: '{error} Choose a valid ban reason and duration.',
+ slashType: 'STRING',
+ optional: true
},
{
id: 'days',
+ description: 'The number of days of messages to delete when the user is banned, defaults to 0.',
flag: '--days',
match: 'option',
- customType: util.arg.range('integer', 0, 7, true)
+ prompt: "How many days of the user's messages would you like to delete?",
+ retry: '{error} Choose between 0 and 7 days to delete messages from the user for.',
+ customType: util.arg.range('integer', 0, 7, true),
+ optional: true,
+ slashType: 'INTEGER',
+ choices: [...Array(8).keys()].map((v) => ({ name: v.toString(), value: v }))
},
{
id: 'force',
+ description: 'Override permission checks.',
flag: '--force',
- match: 'flag'
+ match: 'flag',
+ optional: true,
+ slashType: false,
+ only: 'text',
+ ownerOnly: true
}
],
slash: true,
- slashOptions: [
- {
- name: 'user',
- description: 'What user would you like to ban?',
- type: 'USER',
- required: true
- },
- {
- name: 'reason',
- description: 'Why should this user be banned and for how long?',
- type: 'STRING',
- required: false
- },
- {
- name: 'days',
- description: "How many days of the user's messages would you like to delete?",
- type: 'INTEGER',
- required: false,
- choices: [
- { name: '0', value: 0 },
- { name: '1', value: 1 },
- { name: '2', value: 2 },
- { name: '3', value: 3 },
- { name: '4', value: 4 },
- { name: '5', value: 5 },
- { name: '6', value: 6 },
- { name: '7', value: 7 }
- ]
- }
- ],
channel: 'guild',
clientPermissions: ['BAN_MEMBERS'],
userPermissions: ['BAN_MEMBERS']
@@ -134,7 +113,7 @@ export default class BanCommand extends BushCommand {
});
const responseMessage = () => {
- const victim = util.format.bold(user.tag);
+ const victim = util.format.input(user.tag);
switch (responseCode) {
case 'missing permissions':
return `${util.emojis.error} Could not ban ${victim} because I am missing the **Ban Members** permission.`;
diff --git a/src/commands/moderation/evidence.ts b/src/commands/moderation/evidence.ts
index 0204d84..714a2e5 100644
--- a/src/commands/moderation/evidence.ts
+++ b/src/commands/moderation/evidence.ts
@@ -6,26 +6,28 @@ export default class EvidenceCommand extends BushCommand {
super('evidence', {
aliases: ['evidence'],
category: 'moderation',
- description: {
- content: 'Add evidence to a modlog case.',
- usage: ['evidence <case_id> <evidence>'],
- examples: ['evidence ']
- },
- slash: true,
- slashOptions: [
+ description: 'Add evidence to a modlog case.',
+ usage: ['evidence <case_id> <evidence>'],
+ examples: ['evidence 9210b1ea-91f5-4ea2-801b-02b394469c77 was spamming in #general'],
+ args: [
{
- name: 'case_id',
- description: 'What case would you like to modify the evidence of?',
- type: 'STRING',
- required: true
+ id: 'case_id',
+ description: 'The case to modify the evidence of.',
+ type: 'string',
+ prompt: 'What case would you like to modify the evidence of?',
+ slashType: 'STRING',
+ only: 'slash'
},
{
- name: 'evidence',
- description: 'What would you like to modify the evidence to?',
- type: 'STRING',
- required: true
+ id: 'evidence',
+ description: 'The value to set the evidence to.',
+ type: 'string',
+ prompt: 'What would you like to modify the evidence to?',
+ slashType: 'STRING',
+ only: 'slash'
}
],
+ slash: true,
channel: 'guild',
clientPermissions: (m) => util.clientSendAndPermCheck(m),
userPermissions: (m) => util.userGuildPermCheck(m, ['MANAGE_MESSAGES'])
diff --git a/src/commands/moderation/hideCase.ts b/src/commands/moderation/hideCase.ts
index 9c22e63..de7b310 100644
--- a/src/commands/moderation/hideCase.ts
+++ b/src/commands/moderation/hideCase.ts
@@ -5,30 +5,20 @@ export default class HideCaseCommand extends BushCommand {
super('hideCase', {
aliases: ['hide-case', 'hide_case', 'showcase', 'show_case', 'cover-up-mod-abuse', 'cover_up_mod_abuse'],
category: 'moderation',
- description: {
- content: 'Hide a particular modlog case from the modlog command unless the `--hidden` flag is specified',
- usage: ['hide-case <case_id>'],
- examples: ['hide-case 9210b1ea-91f5-4ea2-801b-02b394469c77']
- },
+ description: 'Hide a particular modlog case from the modlog command unless the `--hidden` flag is specified',
+ usage: ['hide-case <case_id>'],
+ examples: ['hide-case 9210b1ea-91f5-4ea2-801b-02b394469c77'],
args: [
{
id: 'case_id',
+ description: 'The id of the case to be hidden.',
type: 'string',
- prompt: {
- start: 'What modlog case would you like to hide?',
- retry: '{error} Choose a valid case id.'
- }
+ prompt: 'What modlog case would you like to hide?',
+ retry: '{error} Choose a valid case id.',
+ slashType: 'STRING'
}
],
slash: true,
- slashOptions: [
- {
- name: 'case_id',
- description: 'What modlog case would you like to hide?',
- type: 'STRING',
- required: true
- }
- ],
clientPermissions: (m) => util.clientSendAndPermCheck(m),
userPermissions: (m) => util.userGuildPermCheck(m, ['MANAGE_MESSAGES']),
channel: 'guild'
diff --git a/src/commands/moderation/kick.ts b/src/commands/moderation/kick.ts
index 1f1c2fb..9463154 100644
--- a/src/commands/moderation/kick.ts
+++ b/src/commands/moderation/kick.ts
@@ -5,51 +5,40 @@ export default class KickCommand extends BushCommand {
super('kick', {
aliases: ['kick'],
category: 'moderation',
- description: {
- content: 'Kick a user.',
- usage: ['kick <member> <reason>'],
- examples: ['kick @user bad']
- },
+ description: 'Kick a user.',
+ usage: ['kick <member> <reason>'],
+ examples: ['kick @user bad'],
args: [
{
id: 'user',
+ description: 'The user to kick.',
type: 'user',
- prompt: {
- start: 'What user would you like to kick?',
- retry: '{error} Choose a valid user to kick.'
- }
+ prompt: 'What user would you like to kick?',
+ retry: '{error} Choose a valid user to kick.',
+ slashType: 'USER'
},
{
id: 'reason',
+ description: 'The reason for the kick.',
type: 'string',
match: 'rest',
- prompt: {
- start: 'Why should this user be kicked?',
- retry: '{error} Choose a valid kick reason.',
- optional: true
- }
+ prompt: 'Why should this user be kicked?',
+ retry: '{error} Choose a valid kick reason.',
+ optional: true,
+ slashType: 'STRING'
},
{
id: 'force',
+ description: 'Override permission checks.',
flag: '--force',
- match: 'flag'
+ match: 'flag',
+ optional: true,
+ slashType: false,
+ only: 'text',
+ ownerOnly: true
}
],
slash: true,
- slashOptions: [
- {
- name: 'user',
- description: 'What user would you like to kick?',
- type: 'USER',
- required: true
- },
- {
- name: 'reason',
- description: 'Why should this user be kicked?',
- type: 'STRING',
- required: false
- }
- ],
clientPermissions: (m) => util.clientSendAndPermCheck(m, ['KICK_MEMBERS']),
userPermissions: ['KICK_MEMBERS']
});
@@ -77,7 +66,7 @@ export default class KickCommand extends BushCommand {
});
const responseMessage = () => {
- const victim = util.format.bold(member.user.tag);
+ const victim = util.format.input(member.user.tag);
switch (responseCode) {
case 'missing permissions':
return `${util.emojis.error} Could not kick ${victim} because I am missing the \`Kick Members\` permission.`;
diff --git a/src/commands/moderation/modlog.ts b/src/commands/moderation/modlog.ts
index 8bdee59..474eaa9 100644
--- a/src/commands/moderation/modlog.ts
+++ b/src/commands/moderation/modlog.ts
@@ -6,48 +6,36 @@ export default class ModlogCommand extends BushCommand {
super('modlog', {
aliases: ['modlog', 'modlogs'],
category: 'moderation',
- description: {
- content: "View a user's modlogs, or view a specific case.",
- usage: ['modlogs <search> [--hidden]'],
- examples: ['modlogs @Tyman']
- },
+ description: "View a user's modlogs, or view a specific case.",
+ usage: ['modlogs <search> [--hidden]'],
+ examples: ['modlogs @Tyman'],
args: [
{
id: 'search',
+ description: 'The case id or user to search for modlogs by.',
customType: util.arg.union('user', 'string'),
- prompt: {
- start: 'What case id or user would you like to see?',
- retry: '{error} Choose a valid case id or user.'
- }
+ prompt: 'What case id or user would you like to see?',
+ retry: '{error} Choose a valid case id or user.',
+ slashType: 'STRING'
},
{
id: 'hidden',
+ description: 'Show hidden modlogs.',
+ prompt: 'Would you like to see hidden modlogs?',
match: 'flag',
flag: ['--hidden', '-h'],
- default: false
+ default: false,
+ optional: true,
+ slashType: 'BOOLEAN'
}
],
- clientPermissions: (m) => util.clientSendAndPermCheck(m),
- userPermissions: (m) => util.userGuildPermCheck(m, ['MANAGE_MESSAGES']),
slash: true,
- slashOptions: [
- {
- name: 'search',
- description: 'What case id or user would you like to see?',
- type: 'STRING',
- required: true
- },
- {
- name: 'hidden',
- description: 'Would you like to see hidden modlogs?',
- type: 'BOOLEAN',
- required: false
- }
- ]
+ clientPermissions: (m) => util.clientSendAndPermCheck(m),
+ userPermissions: (m) => util.userGuildPermCheck(m, ['MANAGE_MESSAGES'])
});
}
- #generateModlogInfo(log: ModLog, showUser: boolean): string {
+ static generateModlogInfo(log: ModLog, showUser: boolean): string {
const trim = (str: string): string => (str.endsWith('\n') ? str.substring(0, str.length - 1).trim() : str.trim());
const modLog = [`**Case ID**: ${util.discord.escapeMarkdown(log.id)}`, `**Type**: ${log.type.toLowerCase()}`];
if (showUser) modLog.push(`**User**: <@!${log.user}>`);
@@ -75,7 +63,7 @@ export default class ModlogCommand extends BushCommand {
const niceLogs = logs
.filter((log) => !log.pseudo)
.filter((log) => !(log.hidden && hidden))
- .map((log) => this.#generateModlogInfo(log, false));
+ .map((log) => ModlogCommand.generateModlogInfo(log, false));
if (!logs.length || !niceLogs.length)
return message.util.reply(`${util.emojis.error} **${foundUser.tag}** does not have any modlogs.`);
const chunked: string[][] = util.chunk(niceLogs, 4);
@@ -96,7 +84,7 @@ export default class ModlogCommand extends BushCommand {
return message.util.reply(`${util.emojis.error} This modlog is from another server.`);
const embed = {
title: `Case ${entry.id}`,
- description: this.#generateModlogInfo(entry, true),
+ description: ModlogCommand.generateModlogInfo(entry, true),
color: util.colors.default
};
return await ButtonPaginator.send(message, [embed]);
diff --git a/src/commands/moderation/mute.ts b/src/commands/moderation/mute.ts
index 44e1db4..0584d97 100644
--- a/src/commands/moderation/mute.ts
+++ b/src/commands/moderation/mute.ts
@@ -5,51 +5,40 @@ export default class MuteCommand extends BushCommand {
super('mute', {
aliases: ['mute'],
category: 'moderation',
- description: {
- content: 'Mute a user.',
- usage: ['mute <member> [reason] [duration]'],
- examples: ['mute ironm00n 1 day commands in #general']
- },
+ description: 'Mute a user.',
+ usage: ['mute <member> [reason] [duration]'],
+ examples: ['mute ironm00n 1 day commands in #general'],
args: [
{
id: 'user',
+ description: 'The user to mute.',
type: 'user',
- prompt: {
- start: 'What user would you like to mute?',
- retry: '{error} Choose a valid user to mute.'
- }
+ prompt: 'What user would you like to mute?',
+ retry: '{error} Choose a valid user to mute.',
+ slashType: 'USER'
},
{
id: 'reason',
+ description: 'The reason for the mute.',
type: 'contentWithDuration',
match: 'rest',
- prompt: {
- start: 'Why should this user be muted and for how long?',
- retry: '{error} Choose a valid mute reason and duration.',
- optional: true
- }
+ prompt: 'Why should this user be muted and for how long?',
+ retry: '{error} Choose a valid mute reason and duration.',
+ optional: true,
+ slashType:'STRING'
},
{
id: 'force',
+ description: 'Override permission checks.',
flag: '--force',
- match: 'flag'
+ match: 'flag',
+ optional: true,
+ slashType: false,
+ only: 'text',
+ ownerOnly: true
}
],
slash: true,
- slashOptions: [
- {
- name: 'user',
- description: 'What user would you like to mute?',
- type: 'USER',
- required: true
- },
- {
- name: 'reason',
- description: 'Why should this user be muted and for how long?',
- type: 'STRING',
- required: false
- }
- ],
channel: 'guild',
clientPermissions: (m) => util.clientSendAndPermCheck(m, ['MANAGE_ROLES']),
userPermissions: (m) => util.userGuildPermCheck(m, ['MANAGE_MESSAGES'])
@@ -95,7 +84,7 @@ export default class MuteCommand extends BushCommand {
const responseMessage = () => {
const prefix = util.prefix(message);
- const victim = util.format.bold(member.user.tag);
+ const victim = util.format.input(member.user.tag);
switch (responseCode) {
case 'missing permissions':
return `${util.emojis.error} Could not mute ${victim} because I am missing the **Manage Roles** permission.`;
diff --git a/src/commands/moderation/purge.ts b/src/commands/moderation/purge.ts
index 4d8db08..6bc62de 100644
--- a/src/commands/moderation/purge.ts
+++ b/src/commands/moderation/purge.ts
@@ -1,4 +1,4 @@
-import { BushCommand, BushMessage } from '#lib';
+import { BushCommand, BushMessage, BushUser } from '#lib';
import { Collection, type Snowflake } from 'discord.js';
export default class PurgeCommand extends BushCommand {
@@ -6,61 +6,56 @@ export default class PurgeCommand extends BushCommand {
super('purge', {
aliases: ['purge'],
category: 'moderation',
- description: {
- content: 'A command to mass delete messages.',
- usage: ['purge <amount>'],
- examples: ['purge 20']
- },
+ description: 'A command to mass delete messages.',
+ usage: ['purge <amount> [--bot] [--user <user>]'],
+ examples: ['purge 20'],
args: [
{
id: 'amount',
+ description: 'The amount of messages to purge.',
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.'
- }
+ readableType: 'integer',
+ prompt: 'How many messages would you like to purge?',
+ retry: '{error} Please pick a number between 1 and 100.',
+ slashType: 'INTEGER',
+ minValue: 1,
+ maxValue: 100
},
{
id: 'bot',
+ description: 'Filter messages to only include those that are from bots.',
match: 'flag',
- flag: '--bot'
+ flag: '--bot',
+ prompt: 'Would you like to only delete messages that are from bots?',
+ slashType: 'BOOLEAN',
+ optional: true
},
{
id: 'user',
+ description: 'Filter messages to only include those that are from a specified user.',
match: 'option',
- flag: '--user'
+ type: 'user',
+ flag: '--user',
+ slashType: 'BOOLEAN',
+ optional: true
}
],
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: (m) => util.clientSendAndPermCheck(m, ['MANAGE_MESSAGES', 'EMBED_LINKS'], true),
userPermissions: ['MANAGE_MESSAGES'],
channel: 'guild'
});
}
- public override async exec(message: BushMessage, args: { amount: number; bot: boolean }) {
+ public override async exec(message: BushMessage, args: { amount: number; bot: boolean, user: BushUser }) {
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 messageFilter = (filterMessage: BushMessage): boolean => {
- const shouldFilter = new Array<boolean>();
- if (args.bot) {
- shouldFilter.push(filterMessage.author.bot);
- }
+ const shouldFilter: boolean[] = [];
+ if (args.bot) shouldFilter.push(filterMessage.author.bot);
+ if (args.user) shouldFilter.push(filterMessage.author.id === args.user.id);
+
return shouldFilter.filter((bool) => bool === false).length === 0 && filterMessage.id !== message.id;
};
const _messages = (await message.channel.messages.fetch({ limit: 100, before: message.id }))
diff --git a/src/commands/moderation/removeReactionEmoji.ts b/src/commands/moderation/removeReactionEmoji.ts
index 80f2c01..e847aba 100644
--- a/src/commands/moderation/removeReactionEmoji.ts
+++ b/src/commands/moderation/removeReactionEmoji.ts
@@ -1,35 +1,35 @@
import { BushCommand, type BushMessage } from '#lib';
-import { type Emoji, type Snowflake } from 'discord.js';
+import { Message, type Emoji, type Snowflake } from 'discord.js';
export default class RemoveReactionEmojiCommand extends BushCommand {
public constructor() {
super('removeReactionEmoji', {
aliases: ['remove-reaction-emoji', 'rre'],
category: 'moderation',
- description: {
- content: 'Deleted all the reactions of a certain emoji from a message.',
- usage: ['remove-reaction-emoji <message> <emoji>'],
- examples: ['remove-reaction-emoji 791413052347252786 <:omegaclown:782630946435366942>']
- },
+ description: 'Delete all the reactions of a certain emoji from a message.',
+ usage: ['remove-reaction-emoji <message> <emoji>'],
+ examples: ['remove-reaction-emoji 791413052347252786 <:omegaclown:782630946435366942>'],
args: [
{
- id: 'messageToRemoveFrom',
+ id: 'message',
+ description: 'The message to remove all the reactions of a certain emoji from.',
type: 'guildMessage',
- prompt: {
- start: 'What message would you like to remove a reaction from?',
- retry: '{error} Please pick a valid message.'
- }
+ prompt: 'What message would you like to remove a reaction from?',
+ retry: '{error} Please pick a valid message.',
+ slashType: 'STRING'
},
{
id: 'emoji',
+ description: 'The emoji to remove all the reactions of from a message.',
customType: util.arg.union('emoji', 'snowflake'),
+ readableType:'emoji|snowflake',
match: 'restContent',
- prompt: {
- start: 'What emoji would you like to remove?',
- retry: '{error} Please pick a valid emoji.'
- }
+ prompt: 'What emoji would you like to remove?',
+ retry: '{error} Please pick a valid emoji.',
+ slashType: 'STRING'
}
],
+ slash: true,
channel: 'guild',
clientPermissions: (m) => util.clientSendAndPermCheck(m, ['MANAGE_MESSAGES', 'EMBED_LINKS'], true),
userPermissions: ['MANAGE_MESSAGES', 'MANAGE_EMOJIS_AND_STICKERS'] // Can't undo the removal of 1000s of reactions
@@ -38,25 +38,27 @@ export default class RemoveReactionEmojiCommand extends BushCommand {
public override async exec(
message: BushMessage,
- { messageToRemoveFrom, emoji }: { messageToRemoveFrom: BushMessage; emoji: Emoji | Snowflake }
+ args: { message: BushMessage|Snowflake; emoji: Emoji | Snowflake }
) {
- const id = !['string'].includes(typeof emoji);
- const emojiID = !id ? `${emoji}` : (emoji as Emoji).id;
- const success = await messageToRemoveFrom.reactions.cache
+ const resolvedMessage = args.message instanceof Message ? args.message : await message.channel.messages.fetch(args.message )
+
+ const id = !(['string'] as const).includes(typeof args.emoji);
+ const emojiID = !id ? `${args.emoji}` : (args.emoji as Emoji).id;
+ const success = await resolvedMessage.reactions.cache
?.get(emojiID!)
?.remove()
?.catch(() => {});
if (success) {
return await message.util.reply(
- `${util.emojis.success} Removed all reactions of \`${id ? emojiID : emoji}\` from the message with the id of \`${
- messageToRemoveFrom.id
+ `${util.emojis.success} Removed all reactions of \`${id ? emojiID : args.emoji}\` from the message with the id of \`${
+ resolvedMessage.id
}\`.`
);
} else {
return await message.util.reply(
`${util.emojis.error} There was an error removing all reactions of \`${
- id ? emojiID : emoji
- }\` from the message with the id of \`${messageToRemoveFrom.id}\`.`
+ id ? emojiID : args.emoji
+ }\` from the message with the id of \`${resolvedMessage.id}\`.`
);
}
}
diff --git a/src/commands/moderation/role.ts b/src/commands/moderation/role.ts
index dd74bb4..7ca0a5d 100644
--- a/src/commands/moderation/role.ts
+++ b/src/commands/moderation/role.ts
@@ -1,47 +1,54 @@
import { AllowedMentions, BushCommand, type BushGuildMember, type BushMessage, type BushRole, type BushSlashMessage } from '#lib';
import { type ArgumentOptions, type Flag } from 'discord-akairo';
+import { Snowflake } from 'discord.js';
export default class RoleCommand extends BushCommand {
public constructor() {
super('role', {
aliases: ['role', 'rr', 'ar', 'ra'],
category: 'moderation',
- description: {
- content: "Manages users' roles.",
- usage: ['role <add|remove> <user> <role> [duration]'],
- examples: ['role add spammer nogiveaways 7days', 'ra tyman muted', 'rr tyman staff']
- },
- slash: true,
- slashOptions: [
+ description: "Manages users' roles.",
+ usage: ['role <add|remove> <member> <role> [duration]'],
+ examples: ['role add spammer nogiveaways 7days', 'ra tyman muted', 'rr tyman staff'],
+ args: [
{
- name: 'action',
- description: 'Would you like to add or remove a role?',
- type: 'STRING',
+ id: 'action',
+ description: 'Whether to add or remove a role for the the user.',
+ prompt: 'Would you like to add or remove a role?',
+ slashType: 'STRING',
choices: [
{ name: 'add', value: 'add' },
{ name: 'remove', value: 'remove' }
],
- required: true
+ only: 'slash'
},
{
- name: 'user',
- description: 'What user do you want to add/remove the role to/from?',
- type: 'USER',
- required: true
+ id: 'member',
+ description: 'The user to add/remove a role to/from.',
+ prompt: 'What user do you want to add/remove a role to/from?',
+ slashType: 'USER',
+ slashResolve: 'member',
+ optional: true,
+ only: 'slash'
},
{
- name: 'role',
+ id: 'role',
description: 'The role you would like to add/remove from the to/from.',
- type: 'ROLE',
- required: true
+ prompt: 'What role would you like to add/remove from the user?',
+ slashType: 'ROLE',
+ optional: true,
+ only: 'slash'
},
{
- name: 'duration',
- description: 'How long would you like to role to last?',
- type: 'STRING',
- required: false
+ id: 'duration',
+ description: 'The time before the role will be removed (ignored if removing a role).',
+ prompt: 'How long would you like to role to last?',
+ slashType: 'STRING',
+ optional: true,
+ only: 'slash'
}
],
+ slash: true,
channel: 'guild',
typing: true,
clientPermissions: (m) => util.clientSendAndPermCheck(m, ['MANAGE_ROLES', 'EMBED_LINKS'], true),
@@ -49,10 +56,10 @@ export default class RoleCommand extends BushCommand {
});
}
- override *args(message: BushMessage): IterableIterator<ArgumentOptions | Flag> {
- const action = ['rr'].includes(message.util.parsed?.alias ?? '')
+ override *args(message: BushMessage): Generator<ArgumentOptions | Flag> {
+ const action = (['rr'] as const).includes(message.util.parsed?.alias ?? '')
? 'remove'
- : ['ar', 'ra'].includes(message.util.parsed?.alias ?? '')
+ : (['ar', 'ra'] as const).includes(message.util.parsed?.alias ?? '')
? 'add'
: yield {
id: 'action',
@@ -63,7 +70,7 @@ export default class RoleCommand extends BushCommand {
}
};
- const user = yield {
+ const member = yield {
id: 'user',
type: 'member',
prompt: {
@@ -84,19 +91,21 @@ export default class RoleCommand extends BushCommand {
}
};
- return { action, user, role: (_role as any).role ?? _role, duration: (_role as any).duration };
+ const force = yield {
+ id: 'force',
+ description: 'Override permission checks and ban the user anyway.',
+ flag: '--force',
+ match: 'flag'
+ };
+
+ return { action, member: member, role: (_role as any).role ?? _role, duration: (_role as any).duration, force };
}
public override async exec(
message: BushMessage | BushSlashMessage,
- {
- action,
- user: member,
- role,
- duration
- }: { action: 'add' | 'remove'; user: BushGuildMember; role: BushRole; duration?: number | null }