aboutsummaryrefslogtreecommitdiff
path: root/src/commands/moderation
diff options
context:
space:
mode:
Diffstat (limited to 'src/commands/moderation')
-rw-r--r--src/commands/moderation/_lockdown.ts2
-rw-r--r--src/commands/moderation/ban.ts10
-rw-r--r--src/commands/moderation/kick.ts4
-rw-r--r--src/commands/moderation/modlog.ts3
-rw-r--r--src/commands/moderation/mute.ts10
-rw-r--r--src/commands/moderation/purge.ts5
-rw-r--r--src/commands/moderation/removeReactionEmoji.ts6
-rw-r--r--src/commands/moderation/role.ts12
-rw-r--r--src/commands/moderation/slowmode.ts4
-rw-r--r--src/commands/moderation/unban.ts2
-rw-r--r--src/commands/moderation/unmute.ts6
-rw-r--r--src/commands/moderation/warn.ts8
12 files changed, 37 insertions, 35 deletions
diff --git a/src/commands/moderation/_lockdown.ts b/src/commands/moderation/_lockdown.ts
index 32dbd5b..b7bf4b2 100644
--- a/src/commands/moderation/_lockdown.ts
+++ b/src/commands/moderation/_lockdown.ts
@@ -35,7 +35,7 @@ export default class LockdownCommand extends BushCommand {
public override async exec(message: BushMessage | BushSlashMessage, { all }: { all: boolean }): Promise<unknown> {
return await message.util.reply('no');
if (!all) {
- if (!['GUILD_TEXT', 'GUILD_NEWS'].includes(message.channel.type))
+ if (!['GUILD_TEXT', 'GUILD_NEWS'].includes(message.channel!.type))
return message.util.reply(`${util.emojis.error} You can only lock down text and announcement channels.`);
// eslint-disable-next-line @typescript-eslint/no-unused-vars
diff --git a/src/commands/moderation/ban.ts b/src/commands/moderation/ban.ts
index bda0e2b..e32bf18 100644
--- a/src/commands/moderation/ban.ts
+++ b/src/commands/moderation/ban.ts
@@ -90,15 +90,15 @@ export default class BanCommand extends BushCommand {
force
}: { user: User; reason?: { duration: number; contentWithoutTime: string }; days?: number; force: boolean }
): Promise<unknown> {
- const member = message.guild.members.cache.get(user.id) as BushGuildMember;
+ const member = message.guild!.members.cache.get(user.id) as BushGuildMember;
const useForce = force && message.author.isOwner();
- const canModerateResponse = util.moderationPermissionCheck(message.member, member, 'ban', true, useForce);
+ const canModerateResponse = util.moderationPermissionCheck(message.member!, member, 'ban', true, useForce);
if (canModerateResponse !== true) {
return message.util.reply(canModerateResponse);
}
- if (!Number.isInteger(days) || days < 0 || days > 7) {
+ if (!Number.isInteger(days) || days! < 0 || days! > 7) {
return message.util.reply(`${util.emojis.error} The delete days must be an integer between 0 and 7.`);
}
@@ -109,12 +109,12 @@ export default class BanCommand extends BushCommand {
? await Argument.cast('duration', client.commandHandler.resolver, message as BushMessage, reason)
: reason.duration;
}
- const parsedReason = reason.contentWithoutTime;
+ const parsedReason = reason?.contentWithoutTime ?? '';
const responseCode = await member.bushBan({
reason: parsedReason,
moderator: message.author,
- duration: time,
+ duration: time! ?? 0,
deleteDays: days ?? 0
});
diff --git a/src/commands/moderation/kick.ts b/src/commands/moderation/kick.ts
index 2fc133e..8864320 100644
--- a/src/commands/moderation/kick.ts
+++ b/src/commands/moderation/kick.ts
@@ -59,12 +59,12 @@ export default class KickCommand extends BushCommand {
message: BushMessage | BushSlashMessage,
{ user, reason, force }: { user: BushUser; reason?: string; force: boolean }
): Promise<unknown> {
- const member = message.guild.members.cache.get(user.id) as BushGuildMember;
+ const member = message.guild!.members.cache.get(user.id) as BushGuildMember;
if (!member) return await message.util.reply(`${util.emojis.error} You cannot kick members that are not in the server.`);
const useForce = force && message.author.isOwner();
- const canModerateResponse = util.moderationPermissionCheck(message.member, member, 'kick', true, useForce);
+ const canModerateResponse = util.moderationPermissionCheck(message.member!, member, 'kick', true, useForce);
if (canModerateResponse !== true) {
return message.util.reply(canModerateResponse);
diff --git a/src/commands/moderation/modlog.ts b/src/commands/moderation/modlog.ts
index 84bb5b5..04264b8 100644
--- a/src/commands/moderation/modlog.ts
+++ b/src/commands/moderation/modlog.ts
@@ -42,6 +42,7 @@ export default class ModlogCommand extends BushCommand {
`**Moderator**: <@!${log.moderator}> (${log.moderator})`
];
if (log.duration) modLog.push(`**Duration**: ${util.humanizeDuration(log.duration)}`);
+ // eslint-disable-next-line @typescript-eslint/prefer-nullish-coalescing
modLog.push(`**Reason**: ${log.reason || 'No Reason Specified.'}`);
if (log.evidence) modLog.push(`**Evidence:** ${log.evidence}`);
return modLog.join(`\n`);
@@ -55,7 +56,7 @@ export default class ModlogCommand extends BushCommand {
if (foundUser) {
const logs = await ModLog.findAll({
where: {
- guild: message.guild.id,
+ guild: message.guild!.id,
user: foundUser.id
},
order: [['createdAt', 'ASC']]
diff --git a/src/commands/moderation/mute.ts b/src/commands/moderation/mute.ts
index 9f66558..e6c9065 100644
--- a/src/commands/moderation/mute.ts
+++ b/src/commands/moderation/mute.ts
@@ -61,11 +61,11 @@ export default class MuteCommand extends BushCommand {
message: BushMessage | BushSlashMessage,
{ user, reason, force }: { user: BushUser; reason?: { duration: number; contentWithoutTime: string }; force: boolean }
): Promise<unknown> {
- const member = message.guild.members.cache.get(user.id) as BushGuildMember;
+ const member = message.guild!.members.cache.get(user.id) as BushGuildMember;
if (!member) return await message.util.reply(`${util.emojis.error} You cannot kick members that are not in the server.`);
const useForce = force && message.author.isOwner();
- const canModerateResponse = util.moderationPermissionCheck(message.member, member, 'mute', true, useForce);
+ const canModerateResponse = util.moderationPermissionCheck(message.member!, member, 'mute', true, useForce);
const victimBoldTag = `**${member.user.tag}**`;
if (canModerateResponse !== true) {
@@ -79,16 +79,16 @@ export default class MuteCommand extends BushCommand {
? await Argument.cast('duration', client.commandHandler.resolver, message as BushMessage, reason)
: reason.duration;
}
- const parsedReason = reason.contentWithoutTime;
+ const parsedReason = reason?.contentWithoutTime ?? '';
const responseCode = await member.mute({
reason: parsedReason,
moderator: message.author,
- duration: time
+ duration: time! ?? 0
});
const responseMessage = async () => {
- const prefix = await message.guild.getSetting('prefix');
+ const prefix = await message.guild!.getSetting('prefix');
switch (responseCode) {
case 'missing permissions':
return `${util.emojis.error} Could not mute ${victimBoldTag} because I am missing the \`Manage Roles\` permission.`;
diff --git a/src/commands/moderation/purge.ts b/src/commands/moderation/purge.ts
index 4f1a5a6..b391ff6 100644
--- a/src/commands/moderation/purge.ts
+++ b/src/commands/moderation/purge.ts
@@ -1,3 +1,4 @@
+import { Message } from 'discord.js';
import { BushCommand, BushMessage } from '../../lib';
export default class PurgeCommand extends BushCommand {
@@ -60,10 +61,10 @@ export default class PurgeCommand extends BushCommand {
else {
await message.util
.send(`${util.emojis.success} Successfully purged **${purged.size}** messages.`)
- .then(async (purgeMessage: BushMessage) => {
+ .then(async (purgeMessage) => {
if (!message.util.isSlash) {
await util.sleep(5);
- await purgeMessage.delete().catch(() => {});
+ await (purgeMessage as Message).delete().catch(() => {});
}
});
}
diff --git a/src/commands/moderation/removeReactionEmoji.ts b/src/commands/moderation/removeReactionEmoji.ts
index 075b822..4dfd074 100644
--- a/src/commands/moderation/removeReactionEmoji.ts
+++ b/src/commands/moderation/removeReactionEmoji.ts
@@ -43,9 +43,9 @@ export default class RemoveReactionEmojiCommand extends BushCommand {
const id = !['bigint', 'string'].includes(typeof emoji);
const emojiID = !id ? `${emoji}` : (emoji as Emoji).id;
const success = await messageToRemoveFrom.reactions.cache
- .get(emojiID)
- .remove()
- .catch(() => {});
+ ?.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 \`${
diff --git a/src/commands/moderation/role.ts b/src/commands/moderation/role.ts
index 0118f22..4575a11 100644
--- a/src/commands/moderation/role.ts
+++ b/src/commands/moderation/role.ts
@@ -94,26 +94,26 @@ export default class RoleCommand extends BushCommand {
message: BushMessage | BushSlashMessage,
{ action, user, role, duration }: { action: 'add' | 'remove'; user: BushGuildMember; role: BushRole; duration: number }
): Promise<unknown> {
- if (!message.member.permissions.has('MANAGE_ROLES')) {
+ if (!message.member!.permissions.has('MANAGE_ROLES')) {
const mappings = client.consts.mappings;
let mappedRole: { name: string; id: string };
for (let i = 0; i < mappings.roleMap.length; i++) {
const a = mappings.roleMap[i];
if (a.id == role.id) mappedRole = a;
}
- if (!mappedRole || !mappings.roleWhitelist[mappedRole.name]) {
+ if (!mappedRole! || !mappings.roleWhitelist[mappedRole.name as keyof typeof mappings.roleWhitelist]) {
return await message.util.reply({
content: `${util.emojis.error} <@&${role.id}> is not whitelisted, and you do not have manage roles permission.`,
allowedMentions: AllowedMentions.none()
});
}
- const allowedRoles = mappings.roleWhitelist[mappedRole.name].map((r) => {
+ const allowedRoles = mappings.roleWhitelist[mappedRole.name as keyof typeof mappings.roleWhitelist].map((r) => {
for (let i = 0; i < mappings.roleMap.length; i++) {
if (mappings.roleMap[i].name == r) return mappings.roleMap[i].id;
}
return;
});
- if (!message.member.roles.cache.some((role) => allowedRoles.includes(role.id))) {
+ if (!message.member!.roles.cache.some((role) => allowedRoles.includes(role.id))) {
return await message.util.reply({
content: `${util.emojis.error} <@&${role.id}> is whitelisted, but you do not have any of the roles required to manage it.`,
allowedMentions: AllowedMentions.none()
@@ -125,8 +125,8 @@ export default class RoleCommand extends BushCommand {
const responseCode =
action === 'add'
- ? await user.addRole({ moderator: message.member, addToModlog: shouldLog, role, duration })
- : await user.removeRole({ moderator: message.member, addToModlog: shouldLog, role, duration });
+ ? await user.addRole({ moderator: message.member!, addToModlog: shouldLog, role, duration })
+ : await user.removeRole({ moderator: message.member!, addToModlog: shouldLog, role, duration });
const responseMessage = () => {
switch (responseCode) {
diff --git a/src/commands/moderation/slowmode.ts b/src/commands/moderation/slowmode.ts
index ec9a9de..1d47616 100644
--- a/src/commands/moderation/slowmode.ts
+++ b/src/commands/moderation/slowmode.ts
@@ -58,9 +58,9 @@ export default class SlowModeCommand extends BushCommand {
channel: TextChannel | ThreadChannel | BushTextChannel | BushNewsChannel | BushThreadChannel | NewsChannel;
}
): Promise<unknown> {
- if (message.channel.type === 'DM')
+ if (message.channel!.type === 'DM')
return await message.util.reply(`${util.emojis.error} This command cannot be run in dms.`);
- if (!channel) channel = message.channel;
+ if (!channel) channel = message.channel as any;
if (!(channel instanceof TextChannel) && !(channel instanceof ThreadChannel))
return await message.util.reply(`${util.emojis.error} <#${channel.id}> is not a text or thread channel.`);
if (length) {
diff --git a/src/commands/moderation/unban.ts b/src/commands/moderation/unban.ts
index 545d75c..f13e7f6 100644
--- a/src/commands/moderation/unban.ts
+++ b/src/commands/moderation/unban.ts
@@ -58,7 +58,7 @@ export default class UnbanCommand extends BushCommand {
if (!(user instanceof User)) {
user = util.resolveUser(user, client.users.cache) as BushUser;
}
- const responseCode = await message.guild.unban({
+ const responseCode = await message.guild!.unban({
user,
moderator: message.author,
reason
diff --git a/src/commands/moderation/unmute.ts b/src/commands/moderation/unmute.ts
index 918c27f..7e93d31 100644
--- a/src/commands/moderation/unmute.ts
+++ b/src/commands/moderation/unmute.ts
@@ -56,8 +56,8 @@ export default class UnmuteCommand extends BushCommand {
{ user, reason }: { user: BushUser; reason?: string }
): Promise<unknown> {
const error = util.emojis.error;
- const member = message.guild.members.cache.get(user.id) as BushGuildMember;
- const canModerateResponse = util.moderationPermissionCheck(message.member, member, 'unmute');
+ const member = message.guild!.members.cache.get(user.id) as BushGuildMember;
+ const canModerateResponse = util.moderationPermissionCheck(message.member!, member, 'unmute');
const victimBoldTag = `**${member.user.tag}**`;
if (canModerateResponse !== true) {
@@ -70,7 +70,7 @@ export default class UnmuteCommand extends BushCommand {
});
const responseMessage = async () => {
- const prefix = await message.guild.getSetting('prefix');
+ const prefix = await message.guild!.getSetting('prefix');
switch (responseCode) {
case 'missing permissions':
return `${error} Could not unmute ${victimBoldTag} because I am missing the \`Manage Roles\` permission.`;
diff --git a/src/commands/moderation/warn.ts b/src/commands/moderation/warn.ts
index 1aa14c3..33ac2a3 100644
--- a/src/commands/moderation/warn.ts
+++ b/src/commands/moderation/warn.ts
@@ -59,9 +59,9 @@ export default class WarnCommand extends BushCommand {
message: BushMessage | BushSlashMessage,
{ user, reason, force }: { user: BushUser; reason: string; force: boolean }
): Promise<unknown> {
- const member = message.guild.members.cache.get(user.id) as BushGuildMember;
+ const member = message.guild!.members.cache.get(user.id) as BushGuildMember;
const useForce = force && message.author.isOwner();
- const canModerateResponse = util.moderationPermissionCheck(message.member, member, 'warn', true, useForce);
+ const canModerateResponse = util.moderationPermissionCheck(message.member!, member, 'warn', true, useForce);
const victimBoldTag = `**${member.user.tag}**`;
if (canModerateResponse !== true) {
@@ -81,12 +81,12 @@ export default class WarnCommand extends BushCommand {
case 'failed to dm':
return message.util.reply(
`${util.emojis.warn} **${member.user.tag}** has been warned for the ${util.ordinal(
- caseNum
+ caseNum ?? 0
)} time, however I could not send them a dm.`
);
case 'success':
return message.util.reply(
- `${util.emojis.success} Successfully warned **${member.user.tag}** for the ${util.ordinal(caseNum)} time.`
+ `${util.emojis.success} Successfully warned **${member.user.tag}** for the ${util.ordinal(caseNum ?? 0)} time.`
);
}
}