aboutsummaryrefslogtreecommitdiff
path: root/src/commands/moderation
diff options
context:
space:
mode:
authorIRONM00N <64110067+IRONM00N@users.noreply.github.com>2022-06-16 14:32:18 -0400
committerIRONM00N <64110067+IRONM00N@users.noreply.github.com>2022-06-16 14:32:18 -0400
commit0e87bbd3940d89defcb04926587b35c8f4d1947f (patch)
treee50860d4dc25a11d4c3977b583284c4bcad1b077 /src/commands/moderation
parent661e4c9935aeb8760dafc7ced4bbec6cc356a033 (diff)
downloadtanzanite-0e87bbd3940d89defcb04926587b35c8f4d1947f.tar.gz
tanzanite-0e87bbd3940d89defcb04926587b35c8f4d1947f.tar.bz2
tanzanite-0e87bbd3940d89defcb04926587b35c8f4d1947f.zip
remove util classes, move config out of src
Diffstat (limited to 'src/commands/moderation')
-rw-r--r--src/commands/moderation/_activePunishments.ts6
-rw-r--r--src/commands/moderation/ban.ts35
-rw-r--r--src/commands/moderation/block.ts33
-rw-r--r--src/commands/moderation/evidence.ts34
-rw-r--r--src/commands/moderation/hideCase.ts21
-rw-r--r--src/commands/moderation/kick.ts21
-rw-r--r--src/commands/moderation/lockdown.ts31
-rw-r--r--src/commands/moderation/massBan.ts23
-rw-r--r--src/commands/moderation/massEvidence.ts29
-rw-r--r--src/commands/moderation/modlog.ts46
-rw-r--r--src/commands/moderation/mute.ts38
-rw-r--r--src/commands/moderation/purge.ts23
-rw-r--r--src/commands/moderation/removeReactionEmoji.ts27
-rw-r--r--src/commands/moderation/role.ts36
-rw-r--r--src/commands/moderation/slowmode.ts27
-rw-r--r--src/commands/moderation/timeout.ts28
-rw-r--r--src/commands/moderation/unban.ts21
-rw-r--r--src/commands/moderation/unblock.ts30
-rw-r--r--src/commands/moderation/unlockdown.ts14
-rw-r--r--src/commands/moderation/unmute.ts27
-rw-r--r--src/commands/moderation/untimeout.ts23
-rw-r--r--src/commands/moderation/warn.ts21
22 files changed, 367 insertions, 227 deletions
diff --git a/src/commands/moderation/_activePunishments.ts b/src/commands/moderation/_activePunishments.ts
index 92b4242..80cecf2 100644
--- a/src/commands/moderation/_activePunishments.ts
+++ b/src/commands/moderation/_activePunishments.ts
@@ -37,8 +37,8 @@
// slash: true,
// channel: 'guild',
// hidden: true,
-// clientPermissions: (m) => util.clientSendAndPermCheck(m),
-// userPermissions: (m) => util.userGuildPermCheck(m, [PermissionFlagsBits.ManageMessages])
+// clientPermissions: (m) => clientSendAndPermCheck(m),
+// userPermissions: (m) => userGuildPermCheck(m, [PermissionFlagsBits.ManageMessages])
// });
// }
@@ -66,7 +66,7 @@
// 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.`);
+// return message.util.reply(`${emojis.error} You supplied an invalid case type to filter by.`);
// }
// }
diff --git a/src/commands/moderation/ban.ts b/src/commands/moderation/ban.ts
index f4bd52b..e301fb2 100644
--- a/src/commands/moderation/ban.ts
+++ b/src/commands/moderation/ban.ts
@@ -1,8 +1,13 @@
import {
AllowedMentions,
+ Arg,
banResponse,
BushCommand,
+ castDurationContent,
+ emojis,
+ format,
Moderation,
+ resolveNonCachedUser,
type ArgType,
type CommandMessage,
type OptArgType,
@@ -23,7 +28,7 @@ export default class BanCommand extends BushCommand {
{
id: 'user',
description: 'The user that will be banned.',
- type: util.arg.union('user', 'snowflake'),
+ type: Arg.union('user', 'snowflake'),
readableType: 'user|snowflake',
prompt: 'What user would you like to ban?',
retry: '{error} Choose a valid user to ban.',
@@ -46,7 +51,7 @@ export default class BanCommand extends BushCommand {
match: 'option',
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.',
- type: util.arg.range('integer', 0, 7, true),
+ type: Arg.range('integer', 0, 7, true),
readableType: 'integer [0, 7]',
optional: true,
slashType: ApplicationCommandOptionType.Integer,
@@ -82,12 +87,12 @@ export default class BanCommand extends BushCommand {
assert(message.inGuild());
assert(message.member);
- const { duration, content } = await util.castDurationContent(args.reason_and_duration, message);
+ const { duration, content } = await castDurationContent(args.reason_and_duration, message);
args.days ??= message.util.parsed?.alias === 'dban' ? 1 : 0;
const member = message.guild.members.cache.get(typeof args.user === 'string' ? args.user : args.user.id);
- const user = member?.user ?? (await util.resolveNonCachedUser(typeof args.user === 'string' ? args.user : args.user.id));
- if (!user) return message.util.reply(`${util.emojis.error} Invalid user.`);
+ const user = member?.user ?? (await resolveNonCachedUser(typeof args.user === 'string' ? args.user : args.user.id));
+ if (!user) return message.util.reply(`${emojis.error} Invalid user.`);
const useForce = args.force && message.author.isOwner();
const canModerateResponse = member ? await Moderation.permissionCheck(message.member, member, 'ban', true, useForce) : true;
@@ -97,7 +102,7 @@ export default class BanCommand extends BushCommand {
}
if (!Number.isInteger(args.days) || args.days! < 0 || args.days! > 7) {
- return message.util.reply(`${util.emojis.error} The delete days must be an integer between 0 and 7.`);
+ return message.util.reply(`${emojis.error} The delete days must be an integer between 0 and 7.`);
}
const opts = { reason: content, moderator: message.member, duration: duration, deleteDays: args.days };
@@ -105,24 +110,24 @@ export default class BanCommand extends BushCommand {
const responseCode = member ? await member.bushBan(opts) : await message.guild.bushBan({ user, ...opts });
const responseMessage = (): string => {
- const victim = util.format.input(user.tag);
+ const victim = format.input(user.tag);
switch (responseCode) {
case banResponse.ALREADY_BANNED:
- return `${util.emojis.error} ${victim} is already banned.`;
+ return `${emojis.error} ${victim} is already banned.`;
case banResponse.MISSING_PERMISSIONS:
- return `${util.emojis.error} Could not ban ${victim} because I am missing the **Ban Members** permission.`;
+ return `${emojis.error} Could not ban ${victim} because I am missing the **Ban Members** permission.`;
case banResponse.ACTION_ERROR:
- return `${util.emojis.error} An error occurred while trying to ban ${victim}.`;
+ return `${emojis.error} An error occurred while trying to ban ${victim}.`;
case banResponse.PUNISHMENT_ENTRY_ADD_ERROR:
- return `${util.emojis.error} While banning ${victim}, there was an error creating a ban entry, please report this to my developers.`;
+ return `${emojis.error} While banning ${victim}, there was an error creating a ban entry, please report this to my developers.`;
case banResponse.MODLOG_ERROR:
- return `${util.emojis.error} While banning ${victim}, there was an error creating a modlog entry, please report this to my developers.`;
+ return `${emojis.error} While banning ${victim}, there was an error creating a modlog entry, please report this to my developers.`;
case banResponse.DM_ERROR:
- return `${util.emojis.warn} Banned ${victim} however I could not send them a dm.`;
+ return `${emojis.warn} Banned ${victim} however I could not send them a dm.`;
case banResponse.SUCCESS:
- return `${util.emojis.success} Successfully banned ${victim}.`;
+ return `${emojis.success} Successfully banned ${victim}.`;
default:
- return `${util.emojis.error} An error occurred: ${util.format.input(responseCode)}}`;
+ return `${emojis.error} An error occurred: ${format.input(responseCode)}}`;
}
};
return await message.util.reply({ content: responseMessage(), allowedMentions: AllowedMentions.none() });
diff --git a/src/commands/moderation/block.ts b/src/commands/moderation/block.ts
index 16beb6f..fc93fb1 100644
--- a/src/commands/moderation/block.ts
+++ b/src/commands/moderation/block.ts
@@ -2,7 +2,12 @@ import {
AllowedMentions,
blockResponse,
BushCommand,
+ castDurationContent,
+ clientSendAndPermCheck,
+ emojis,
+ format,
Moderation,
+ userGuildPermCheck,
type ArgType,
type CommandMessage,
type OptArgType,
@@ -51,8 +56,8 @@ export default class BlockCommand extends BushCommand {
],
slash: true,
channel: 'guild',
- clientPermissions: (m) => util.clientSendAndPermCheck(m, [PermissionFlagsBits.ManageChannels]),
- userPermissions: (m) => util.userGuildPermCheck(m, [PermissionFlagsBits.ManageMessages]),
+ clientPermissions: (m) => clientSendAndPermCheck(m, [PermissionFlagsBits.ManageChannels]),
+ userPermissions: (m) => userGuildPermCheck(m, [PermissionFlagsBits.ManageMessages]),
lock: 'channel'
});
}
@@ -70,13 +75,13 @@ export default class BlockCommand extends BushCommand {
assert(message.channel);
if (!message.channel.isTextBased())
- return message.util.send(`${util.emojis.error} This command can only be used in text based channels.`);
+ return message.util.send(`${emojis.error} This command can only be used in text based channels.`);
- const { duration, content } = await util.castDurationContent(args.reason_and_duration, message);
+ const { duration, content } = await castDurationContent(args.reason_and_duration, message);
const member = await message.guild.members.fetch(args.user.id).catch(() => null);
if (!member)
- return await message.util.reply(`${util.emojis.error} The user you selected is not in the server or is not a valid user.`);
+ return await message.util.reply(`${emojis.error} The user you selected is not in the server or is not a valid user.`);
const useForce = args.force && message.author.isOwner();
const canModerateResponse = await Moderation.permissionCheck(message.member, member, 'block', true, useForce);
@@ -93,24 +98,24 @@ export default class BlockCommand extends BushCommand {
});
const responseMessage = (): string => {
- const victim = util.format.input(member.user.tag);
+ const victim = format.input(member.user.tag);
switch (responseCode) {
case blockResponse.MISSING_PERMISSIONS:
- return `${util.emojis.error} Could not block ${victim} because I am missing the **Manage Channel** permission.`;
+ return `${emojis.error} Could not block ${victim} because I am missing the **Manage Channel** permission.`;
case blockResponse.INVALID_CHANNEL:
- return `${util.emojis.error} Could not block ${victim}, you can only block users in text or thread channels.`;
+ return `${emojis.error} Could not block ${victim}, you can only block users in text or thread channels.`;
case blockResponse.ACTION_ERROR:
- return `${util.emojis.error} An unknown error occurred while trying to block ${victim}.`;
+ return `${emojis.error} An unknown error occurred while trying to block ${victim}.`;
case blockResponse.MODLOG_ERROR:
- return `${util.emojis.error} There was an error creating a modlog entry, please report this to my developers.`;
+ return `${emojis.error} There was an error creating a modlog entry, please report this to my developers.`;
case blockResponse.PUNISHMENT_ENTRY_ADD_ERROR:
- return `${util.emojis.error} There was an error creating a punishment entry, please report this to my developers.`;
+ return `${emojis.error} There was an error creating a punishment entry, please report this to my developers.`;
case blockResponse.DM_ERROR:
- return `${util.emojis.warn} Blocked ${victim} however I could not send them a dm.`;
+ return `${emojis.warn} Blocked ${victim} however I could not send them a dm.`;
case blockResponse.SUCCESS:
- return `${util.emojis.success} Successfully blocked ${victim}.`;
+ return `${emojis.success} Successfully blocked ${victim}.`;
default:
- return `${util.emojis.error} An error occurred: ${util.format.input(responseCode)}}`;
+ return `${emojis.error} An error occurred: ${format.input(responseCode)}}`;
}
};
return await message.util.reply({ content: responseMessage(), allowedMentions: AllowedMentions.none() });
diff --git a/src/commands/moderation/evidence.ts b/src/commands/moderation/evidence.ts
index f1fac0d..3c9e726 100644
--- a/src/commands/moderation/evidence.ts
+++ b/src/commands/moderation/evidence.ts
@@ -1,4 +1,16 @@
-import { BushCommand, ModLog, OptArgType, type ArgType, type CommandMessage, type SlashMessage } from '#lib';
+import {
+ BushCommand,
+ clientSendAndPermCheck,
+ emojis,
+ format,
+ ModLog,
+ OptArgType,
+ regex,
+ userGuildPermCheck,
+ type ArgType,
+ type CommandMessage,
+ type SlashMessage
+} from '#lib';
import assert from 'assert';
import { Argument, ArgumentGeneratorReturn } from 'discord-akairo';
import { ApplicationCommandOptionType, PermissionFlagsBits, type Message } from 'discord.js';
@@ -42,8 +54,8 @@ export default class EvidenceCommand extends BushCommand {
],
slash: true,
channel: 'guild',
- clientPermissions: (m) => util.clientSendAndPermCheck(m),
- userPermissions: (m) => util.userGuildPermCheck(m, [PermissionFlagsBits.ManageMessages])
+ clientPermissions: (m) => clientSendAndPermCheck(m),
+ userPermissions: (m) => userGuildPermCheck(m, [PermissionFlagsBits.ManageMessages])
});
}
@@ -89,18 +101,18 @@ export default class EvidenceCommand extends BushCommand {
assert(message.inGuild());
if (message.interaction && !caseID && !user)
- return message.util.send(`${util.emojis.error} You must provide either a user or a case ID.`);
+ return message.util.send(`${emojis.error} You must provide either a user or a case ID.`);
const entry = messageCommandTarget
- ? util.consts.regex.snowflake.test(messageCommandTarget)
+ ? regex.snowflake.test(messageCommandTarget)
? await ModLog.findOne({ where: { user: messageCommandTarget }, order: [['createdAt', 'DESC']] })
: await ModLog.findByPk(messageCommandTarget)
: caseID
? await ModLog.findByPk(caseID)
: await ModLog.findOne({ where: { user: user!.id }, order: [['createdAt', 'DESC']] });
- if (!entry || entry.pseudo) return message.util.send(`${util.emojis.error} Invalid modlog entry.`);
- if (entry.guild !== message.guild.id) return message.util.reply(`${util.emojis.error} This modlog is from another server.`);
+ if (!entry || entry.pseudo) return message.util.send(`${emojis.error} Invalid modlog entry.`);
+ if (entry.guild !== message.guild.id) return message.util.reply(`${emojis.error} This modlog is from another server.`);
const oldEntry = entry.evidence;
@@ -112,14 +124,12 @@ export default class EvidenceCommand extends BushCommand {
client.emit('bushUpdateModlog', message.member!, entry.id, 'evidence', oldEntry, entry.evidence);
- return message.util.reply(
- `${util.emojis.success} Successfully updated the evidence for case ${util.format.input(entry.id)}.`
- );
+ return message.util.reply(`${emojis.success} Successfully updated the evidence for case ${format.input(entry.id)}.`);
}
public static getEvidence(message: CommandMessage | SlashMessage, evidenceArg: OptArgType<'string'>): null | string {
if (evidenceArg && (message as Message).attachments?.size) {
- void message.util.reply(`${util.emojis.error} Please either attach an image or a reason not both.`);
+ void message.util.reply(`${emojis.error} Please either attach an image or a reason not both.`);
return null;
}
@@ -129,7 +139,7 @@ export default class EvidenceCommand extends BushCommand {
? (message as Message).attachments.first()?.url
: undefined;
if (!_evidence) {
- void message.util.reply(`${util.emojis.error} You must provide evidence for this modlog.`);
+ void message.util.reply(`${emojis.error} You must provide evidence for this modlog.`);
return null;
}
diff --git a/src/commands/moderation/hideCase.ts b/src/commands/moderation/hideCase.ts
index fc5baf4..0cc3de4 100644
--- a/src/commands/moderation/hideCase.ts
+++ b/src/commands/moderation/hideCase.ts
@@ -1,4 +1,13 @@
-import { BushCommand, ModLog, type CommandMessage, type SlashMessage } from '#lib';
+import {
+ BushCommand,
+ clientSendAndPermCheck,
+ emojis,
+ format,
+ ModLog,
+ userGuildPermCheck,
+ type CommandMessage,
+ type SlashMessage
+} from '#lib';
import assert from 'assert';
import { ApplicationCommandOptionType, PermissionFlagsBits } from 'discord.js';
@@ -21,8 +30,8 @@ export default class HideCaseCommand extends BushCommand {
}
],
slash: true,
- clientPermissions: (m) => util.clientSendAndPermCheck(m),
- userPermissions: (m) => util.userGuildPermCheck(m, [PermissionFlagsBits.ManageMessages]),
+ clientPermissions: (m) => clientSendAndPermCheck(m),
+ userPermissions: (m) => userGuildPermCheck(m, [PermissionFlagsBits.ManageMessages]),
channel: 'guild'
});
}
@@ -31,8 +40,8 @@ export default class HideCaseCommand extends BushCommand {
assert(message.inGuild());
const entry = await ModLog.findByPk(caseID);
- if (!entry || entry.pseudo) return message.util.send(`${util.emojis.error} Invalid entry.`);
- if (entry.guild !== message.guild.id) return message.util.reply(`${util.emojis.error} This modlog is from another server.`);
+ if (!entry || entry.pseudo) return message.util.send(`${emojis.error} Invalid entry.`);
+ if (entry.guild !== message.guild.id) return message.util.reply(`${emojis.error} This modlog is from another server.`);
const action = entry.hidden ? 'no longer hidden' : 'now hidden';
const oldEntry = entry.hidden;
entry.hidden = !entry.hidden;
@@ -40,6 +49,6 @@ export default class HideCaseCommand extends BushCommand {
client.emit('bushUpdateModlog', message.member!, entry.id, 'hidden', oldEntry, entry.hidden);
- return await message.util.reply(`${util.emojis.success} CaseID ${util.format.input(caseID)} is ${action}.`);
+ return await message.util.reply(`${emojis.success} CaseID ${format.input(caseID)} is ${action}.`);
}
}
diff --git a/src/commands/moderation/kick.ts b/src/commands/moderation/kick.ts
index a9a0336..bf079f3 100644
--- a/src/commands/moderation/kick.ts
+++ b/src/commands/moderation/kick.ts
@@ -1,6 +1,9 @@
import {
AllowedMentions,
BushCommand,
+ clientSendAndPermCheck,
+ emojis,
+ format,
kickResponse,
Moderation,
type ArgType,
@@ -50,7 +53,7 @@ export default class KickCommand extends BushCommand {
}
],
slash: true,
- clientPermissions: (m) => util.clientSendAndPermCheck(m, [PermissionFlagsBits.KickMembers]),
+ clientPermissions: (m) => clientSendAndPermCheck(m, [PermissionFlagsBits.KickMembers]),
userPermissions: [PermissionFlagsBits.KickMembers]
});
}
@@ -65,7 +68,7 @@ export default class KickCommand extends BushCommand {
const member = await message.guild.members.fetch(user.id);
if (!member)
- return await message.util.reply(`${util.emojis.error} The user you selected is not in the server or is not a valid user.`);
+ return await message.util.reply(`${emojis.error} The user you selected is not in the server or is not a valid user.`);
const useForce = force && message.author.isOwner();
const canModerateResponse = await Moderation.permissionCheck(message.member, member, 'kick', true, useForce);
@@ -79,20 +82,20 @@ export default class KickCommand extends BushCommand {
});
const responseMessage = (): string => {
- const victim = util.format.input(member.user.tag);
+ const victim = format.input(member.user.tag);
switch (responseCode) {
case kickResponse.MISSING_PERMISSIONS:
- return `${util.emojis.error} Could not kick ${victim} because I am missing the **Kick Members** permission.`;
+ return `${emojis.error} Could not kick ${victim} because I am missing the **Kick Members** permission.`;
case kickResponse.ACTION_ERROR:
- return `${util.emojis.error} An error occurred while trying to kick ${victim}.`;
+ return `${emojis.error} An error occurred while trying to kick ${victim}.`;
case kickResponse.MODLOG_ERROR:
- return `${util.emojis.error} While muting ${victim}, there was an error creating a modlog entry, please report this to my developers.`;
+ return `${emojis.error} While muting ${victim}, there was an error creating a modlog entry, please report this to my developers.`;
case kickResponse.DM_ERROR:
- return `${util.emojis.warn} Kicked ${victim} however I could not send them a dm.`;
+ return `${emojis.warn} Kicked ${victim} however I could not send them a dm.`;
case kickResponse.SUCCESS:
- return `${util.emojis.success} Successfully kicked ${victim}.`;
+ return `${emojis.success} Successfully kicked ${victim}.`;
default:
- return `${util.emojis.error} An error occurred: ${util.format.input(responseCode)}}`;
+ return `${emojis.error} An error occurred: ${format.input(responseCode)}}`;
}
};
return await message.util.reply({ content: responseMessage(), allowedMentions: AllowedMentions.none() });
diff --git a/src/commands/moderation/lockdown.ts b/src/commands/moderation/lockdown.ts
index 7d8211c..76d61d0 100644
--- a/src/commands/moderation/lockdown.ts
+++ b/src/commands/moderation/lockdown.ts
@@ -1,7 +1,12 @@
import {
AllowedMentions,
+ Arg,
BushCommand,
+ clientSendAndPermCheck,
+ colors,
ConfirmationPrompt,
+ emojis,
+ format,
type ArgType,
type CommandMessage,
type OptArgType,
@@ -31,7 +36,7 @@ export default class LockdownCommand extends BushCommand {
{
id: 'channel',
description: 'Specify a different channel to lockdown instead of the one you trigger the command in.',
- type: util.arg.union('textChannel', 'newsChannel', 'threadChannel', 'voiceChannel'),
+ type: Arg.union('textChannel', 'newsChannel', 'threadChannel', 'voiceChannel'),
prompt: 'What channel would you like to lockdown?',
slashType: ApplicationCommandOptionType.Channel,
channelTypes: [
@@ -65,7 +70,7 @@ export default class LockdownCommand extends BushCommand {
],
slash: true,
channel: 'guild',
- clientPermissions: (m) => util.clientSendAndPermCheck(m, [PermissionFlagsBits.ManageChannels]),
+ clientPermissions: (m) => clientSendAndPermCheck(m, [PermissionFlagsBits.ManageChannels]),
userPermissions: [PermissionFlagsBits.ManageChannels],
lock: 'channel'
});
@@ -95,7 +100,7 @@ export default class LockdownCommand extends BushCommand {
if (message.util.isSlashMessage(message)) await message.interaction.deferReply();
if (args.channel && args.all)
- return await message.util.reply(`${util.emojis.error} You can't specify a channel and set all to true at the same time.`);
+ return await message.util.reply(`${emojis.error} You can't specify a channel and set all to true at the same time.`);
const channel = args.channel ?? message.channel;
@@ -108,14 +113,14 @@ export default class LockdownCommand extends BushCommand {
)
)
return await message.util.reply(
- `${util.emojis.error} You can only ${action} text channels, news channels, and thread channels.`
+ `${emojis.error} You can only ${action} text channels, news channels, and thread channels.`
);
if (args.all) {
const confirmation = await ConfirmationPrompt.send(message, {
content: `Are you sure you want to ${action} all channels?`
});
- if (!confirmation) return message.util.sendNew(`${util.emojis.error} Lockdown cancelled.`);
+ if (!confirmation) return message.util.sendNew(`${emojis.error} Lockdown cancelled.`);
}
const response = await message.guild.lockdown({
@@ -128,33 +133,33 @@ export default class LockdownCommand extends BushCommand {
if (response instanceof Collection) {
return await message.util.sendNew({
- content: `${util.emojis.error} The following channels failed to ${action}:`,
+ content: `${emojis.error} The following channels failed to ${action}:`,
embeds: [
{
description: response.map((e, c) => `<#${c}> : ${e.message}`).join('\n'),
- color: util.colors.warn
+ color: colors.warn
}
]
});
} else {
let messageResponse;
if (response === 'all not chosen and no channel specified') {
- messageResponse = `${util.emojis.error} You must specify a channel to ${action}.`;
+ messageResponse = `${emojis.error} You must specify a channel to ${action}.`;
} else if (response.startsWith('invalid channel configured: ')) {
const channels = response.replace('invalid channel configured: ', '');
const actionFormatted = `${action.replace('down', '')}ed`;
- messageResponse = `${util.emojis.error} Some of the channels configured to be ${actionFormatted} cannot be resolved: ${channels}}`;
+ messageResponse = `${emojis.error} Some of the channels configured to be ${actionFormatted} cannot be resolved: ${channels}}`;
} else if (response === 'no channels configured') {
- messageResponse = `${util.emojis.error} The all option is selected but there are no channels configured to be locked down.`;
+ messageResponse = `${emojis.error} The all option is selected but there are no channels configured to be locked down.`;
} else if (response === 'moderator not found') {
- messageResponse = `${util.emojis.error} For some reason I could not resolve you?`;
+ messageResponse = `${emojis.error} For some reason I could not resolve you?`;
} else if (response.startsWith('success: ')) {
const num = Number.parseInt(response.replace('success: ', ''));
- messageResponse = `${util.emojis.success} Successfully ${
+ messageResponse = `${emojis.success} Successfully ${
action === 'lockdown' ? 'locked down' : 'unlocked'
} **${num}** channel${num > 0 ? 's' : ''}.`;
} else {
- return `${util.emojis.error} An error occurred: ${util.format.input(response)}}`;
+ return `${emojis.error} An error occurred: ${format.input(response)}}`;
}
assert(messageResponse);
diff --git a/src/commands/moderation/massBan.ts b/src/commands/moderation/massBan.ts
index a25c64f..ab9fbc8 100644
--- a/src/commands/moderation/massBan.ts
+++ b/src/commands/moderation/massBan.ts
@@ -1,7 +1,13 @@
import {
+ Arg,
BanResponse,
banResponse,
BushCommand,
+ clientSendAndPermCheck,
+ colors,
+ emojis,
+ overflowEmbed,
+ regex,
type ArgType,
type CommandMessage,
type OptArgType,
@@ -45,7 +51,7 @@ export default class MassBanCommand extends BushCommand {
match: 'option',
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.',
- type: util.arg.range('integer', 0, 7, true),
+ type: Arg.range('integer', 0, 7, true),
optional: true,
slashType: ApplicationCommandOptionType.Integer,
choices: [...Array(8).keys()].map((v) => ({ name: v.toString(), value: v }))
@@ -54,7 +60,7 @@ export default class MassBanCommand extends BushCommand {
quoted: true,
slash: true,
channel: 'guild',
- clientPermissions: (m) => util.clientSendAndPermCheck(m),
+ clientPermissions: (m) => clientSendAndPermCheck(m),
userPermissions: [PermissionFlagsBits.BanMembers],
lock: 'user'
});
@@ -69,14 +75,13 @@ export default class MassBanCommand extends BushCommand {
args.days ??= message.util.parsed?.alias?.includes('dban') ? 1 : 0;
const ids = args.users.split(/\n| /).filter((id) => id.length > 0);
- if (ids.length === 0) return message.util.send(`${util.emojis.error} You must provide at least one user id.`);
+ if (ids.length === 0) return message.util.send(`${emojis.error} You must provide at least one user id.`);
for (const id of ids) {
- if (!client.constants.regex.snowflake.test(id))
- return message.util.send(`${util.emojis.error} ${id} is not a valid snowflake.`);
+ if (!regex.snowflake.test(id)) return message.util.send(`${emojis.error} ${id} is not a valid snowflake.`);
}
if (!Number.isInteger(args.days) || args.days! < 0 || args.days! > 7) {
- return message.util.reply(`${util.emojis.error} The delete days must be an integer between 0 and 7.`);
+ return message.util.reply(`${emojis.error} The delete days must be an integer between 0 and 7.`);
}
const promises = ids.map((id) =>
@@ -99,13 +104,13 @@ export default class MassBanCommand extends BushCommand {
const id = ids[i];
const status = res[i];
const isSuccess = success(status);
- const emoji = isSuccess ? util.emojis.success : util.emojis.error;
+ const emoji = isSuccess ? emojis.success : emojis.error;
return `${emoji} ${id}${isSuccess ? '' : ` - ${status}`}`;
});
- const embeds = util.overflowEmbed(
+ const embeds = overflowEmbed(
{
- color: util.colors.DarkRed,
+ color: colors.DarkRed,
title: 'Mass Ban Results'
},
lines
diff --git a/src/commands/moderation/massEvidence.ts b/src/commands/moderation/massEvidence.ts
index 468d43c..ffe85d2 100644
--- a/src/commands/moderation/massEvidence.ts
+++ b/src/commands/moderation/massEvidence.ts
@@ -1,4 +1,16 @@
-import { BushCommand, ModLog, type ArgType, type CommandMessage, type OptArgType, type SlashMessage } from '#lib';
+import {
+ BushCommand,
+ clientSendAndPermCheck,
+ colors,
+ emojis,
+ ModLog,
+ overflowEmbed,
+ regex,
+ type ArgType,
+ type CommandMessage,
+ type OptArgType,
+ type SlashMessage
+} from '#lib';
import assert from 'assert';
import { ApplicationCommandOptionType, PermissionFlagsBits } from 'discord.js';
import { EvidenceCommand } from '../index.js';
@@ -37,7 +49,7 @@ export default class MassEvidenceCommand extends BushCommand {
quoted: true,
slash: true,
channel: 'guild',
- clientPermissions: (m) => util.clientSendAndPermCheck(m),
+ clientPermissions: (m) => clientSendAndPermCheck(m),
userPermissions: [PermissionFlagsBits.ManageMessages],
lock: 'user'
});
@@ -53,10 +65,9 @@ export default class MassEvidenceCommand extends BushCommand {
if (!evidence) return;
const ids = args.users.split(/\n| /).filter((id) => id.length > 0);
- if (ids.length === 0) return message.util.send(`${util.emojis.error} You must provide at least one user id.`);
+ if (ids.length === 0) return message.util.send(`${emojis.error} You must provide at least one user id.`);
for (const id of ids) {
- if (!client.constants.regex.snowflake.test(id))
- return message.util.send(`${util.emojis.error} ${id} is not a valid snowflake.`);
+ if (!regex.snowflake.test(id)) return message.util.send(`${emojis.error} ${id} is not a valid snowflake.`);
}
const caseMap = (
@@ -78,15 +89,15 @@ export default class MassEvidenceCommand extends BushCommand {
const lines = ids.map((id, i) => {
const case_ = res[i];
- if (!case_) return `${util.emojis.error} ${id} - no case found.`;
- return `${util.emojis.success} ${id} - ${case_.id}`;
+ if (!case_) return `${emojis.error} ${id} - no case found.`;
+ return `${emojis.success} ${id} - ${case_.id}`;
});
client.emit('massEvidence', message.member!, message.guild, evidence, lines);
- const embeds = util.overflowEmbed(
+ const embeds = overflowEmbed(
{
- color: util.colors.DarkRed,
+ color: colors.DarkRed,
title: 'Mass Evidence'
},
lines
diff --git a/src/commands/moderation/modlog.ts b/src/commands/moderation/modlog.ts
index 71ed975..2c0e33a 100644
--- a/src/commands/moderation/modlog.ts
+++ b/src/commands/moderation/modlog.ts
@@ -1,6 +1,22 @@
-import { BushCommand, ButtonPaginator, ModLog, type ArgType, type CommandMessage, type SlashMessage } from '#lib';
+import {
+ Arg,
+ BushCommand,
+ ButtonPaginator,
+ chunk,
+ clientSendAndPermCheck,
+ colors,
+ emojis,
+ humanizeDuration,
+ ModLog,
+ resolveUserAsync,
+ timestamp,
+ userGuildPermCheck,
+ type ArgType,
+ type CommandMessage,
+ type SlashMessage
+} from '#lib';
import assert from 'assert';
-import { ApplicationCommandOptionType, PermissionFlagsBits, User } from 'discord.js';
+import { ApplicationCommandOptionType, escapeMarkdown, PermissionFlagsBits, User } from 'discord.js';
export default class ModlogCommand extends BushCommand {
public static separator = '\n━━━━━━━━━━━━━━━\n';
@@ -16,7 +32,7 @@ export default class ModlogCommand extends BushCommand {
{
id: 'search',
description: 'The case id or user to search for modlogs by.',
- type: util.arg.union('user', 'string'),
+ type: Arg.union('user', 'string'),
prompt: 'What case id or user would you like to see?',
retry: '{error} Choose a valid case id or user.',
slashType: ApplicationCommandOptionType.String
@@ -34,8 +50,8 @@ export default class ModlogCommand extends BushCommand {
],
slash: true,
channel: 'guild',
- clientPermissions: (m) => util.clientSendAndPermCheck(m),
- userPermissions: (m) => util.userGuildPermCheck(m, [PermissionFlagsBits.ManageMessages])
+ clientPermissions: (m) => clientSendAndPermCheck(m),
+ userPermissions: (m) => userGuildPermCheck(m, [PermissionFlagsBits.ManageMessages])
});
}
@@ -45,7 +61,7 @@ export default class ModlogCommand extends BushCommand {
) {
assert(message.inGuild());
- const foundUser = search instanceof User ? search : await util.resolveUserAsync(search);
+ const foundUser = search instanceof User ? search : await resolveUserAsync(search);
if (foundUser) {
const logs = await M