aboutsummaryrefslogtreecommitdiff
path: root/src/commands/moderation
diff options
context:
space:
mode:
authorIRONM00N <64110067+IRONM00N@users.noreply.github.com>2021-07-14 13:12:32 -0400
committerIRONM00N <64110067+IRONM00N@users.noreply.github.com>2021-07-14 13:12:32 -0400
commit070b5f326d0647e7b105f99811e4bdc915c8652e (patch)
tree15c5e3366acb9f6056de83924db6dd9db961061a /src/commands/moderation
parentcdb8b0297f806cb3147b3759b0fd234bffbcc3f9 (diff)
downloadtanzanite-070b5f326d0647e7b105f99811e4bdc915c8652e.tar.gz
tanzanite-070b5f326d0647e7b105f99811e4bdc915c8652e.tar.bz2
tanzanite-070b5f326d0647e7b105f99811e4bdc915c8652e.zip
revamped role command and some other stuff
Diffstat (limited to 'src/commands/moderation')
-rw-r--r--src/commands/moderation/ban.ts45
-rw-r--r--src/commands/moderation/kick.ts40
-rw-r--r--src/commands/moderation/modlog.ts3
-rw-r--r--src/commands/moderation/mute.ts68
-rw-r--r--src/commands/moderation/role.ts176
-rw-r--r--src/commands/moderation/unban.ts41
-rw-r--r--src/commands/moderation/unmute.ts68
7 files changed, 199 insertions, 242 deletions
diff --git a/src/commands/moderation/ban.ts b/src/commands/moderation/ban.ts
index d713a15..c5833fc 100644
--- a/src/commands/moderation/ban.ts
+++ b/src/commands/moderation/ban.ts
@@ -1,4 +1,4 @@
-import { BushCommand, BushGuildMember, BushMessage, BushSlashMessage } from '@lib';
+import { AllowedMentions, BushCommand, BushGuildMember, BushMessage, BushSlashMessage } from '@lib';
import { Argument } from 'discord-akairo';
import { User } from 'discord.js';
@@ -99,36 +99,29 @@ export default class BanCommand extends BushCommand {
}
const parsedReason = reason.contentWithoutTime;
- const response = await member.bushBan({
+ const responseCode = await member.bushBan({
reason: parsedReason,
moderator: message.author,
duration: time,
deleteDays: days ?? 0
});
- switch (response) {
- case 'missing permissions':
- return message.util.reply(
- `${this.client.util.emojis.error} Could not ban **${member.user.tag}** because I do not have permissions`
- );
- case 'error banning':
- return message.util.reply(
- `${this.client.util.emojis.error} An error occurred while trying to ban **${member.user.tag}**.`
- );
- case 'error creating ban entry':
- return message.util.reply(
- `${this.client.util.emojis.error} While banning **${member.user.tag}**, there was an error creating a ban entry, please report this to my developers.`
- );
- case 'error creating modlog entry':
- return message.util.reply(
- `${this.client.util.emojis.error} While banning **${member.user.tag}**, there was an error creating a modlog entry, please report this to my developers.`
- );
- case 'failed to dm':
- return message.util.reply(
- `${this.client.util.emojis.warn} Banned **${member.user.tag}** however I could not send them a dm.`
- );
- case 'success':
- return message.util.reply(`${this.client.util.emojis.success} Successfully banned **${member.user.tag}**.`);
- }
+ const responseMessage = () => {
+ switch (responseCode) {
+ case 'missing permissions':
+ return `${this.client.util.emojis.error} Could not ban **${member.user.tag}** because I do not have permissions`;
+ case 'error banning':
+ return `${this.client.util.emojis.error} An error occurred while trying to ban **${member.user.tag}**.`;
+ case 'error creating ban entry':
+ return `${this.client.util.emojis.error} While banning **${member.user.tag}**, there was an error creating a ban entry, please report this to my developers.`;
+ case 'error creating modlog entry':
+ return `${this.client.util.emojis.error} While banning **${member.user.tag}**, there was an error creating a modlog entry, please report this to my developers.`;
+ case 'failed to dm':
+ return `${this.client.util.emojis.warn} Banned **${member.user.tag}** however I could not send them a dm.`;
+ case 'success':
+ return `${this.client.util.emojis.success} Successfully banned **${member.user.tag}**.`;
+ }
+ };
+ return await message.util.reply({ content: responseMessage(), allowedMentions: AllowedMentions.none() });
}
}
diff --git a/src/commands/moderation/kick.ts b/src/commands/moderation/kick.ts
index d70bbfb..ccf35a9 100644
--- a/src/commands/moderation/kick.ts
+++ b/src/commands/moderation/kick.ts
@@ -1,4 +1,4 @@
-import { BushCommand, BushGuildMember, BushMessage, BushSlashMessage, BushUser } from '@lib';
+import { AllowedMentions, BushCommand, BushGuildMember, BushMessage, BushSlashMessage, BushUser } from '@lib';
export default class KickCommand extends BushCommand {
public constructor() {
@@ -53,36 +53,30 @@ export default class KickCommand extends BushCommand {
async exec(message: BushMessage | BushSlashMessage, { user, reason }: { user: BushUser; reason?: string }): Promise<unknown> {
const member = message.guild.members.cache.get(user.id) as BushGuildMember;
const canModerateResponse = this.client.util.moderationPermissionCheck(message.member, member, 'kick');
- // const victimBoldTag = `**${member.user.tag}**`;
if (canModerateResponse !== true) {
return message.util.reply(canModerateResponse);
}
- const response = await member.bushKick({
+ const responseCode = await member.bushKick({
reason,
moderator: message.author
});
- switch (response) {
- case 'missing permissions':
- return message.util.reply(
- `${this.client.util.emojis.error} Could not kick **${member.user.tag}** because I am missing the \`Kick Members\` permission.`
- );
- case 'error kicking':
- return message.util.reply(
- `${this.client.util.emojis.error} An error occurred while trying to kick **${member.user.tag}**.`
- );
- case 'error creating modlog entry':
- return message.util.reply(
- `${this.client.util.emojis.error} While muting **${member.user.tag}**, there was an error creating a modlog entry, please report this to my developers.`
- );
- case 'failed to dm':
- return message.util.reply(
- `${this.client.util.emojis.warn} Kicked **${member.user.tag}** however I could not send them a dm.`
- );
- case 'success':
- return message.util.reply(`${this.client.util.emojis.success} Successfully kicked **${member.user.tag}**.`);
- }
+ const responseMessage = () => {
+ switch (responseCode) {
+ case 'missing permissions':
+ return `${this.client.util.emojis.error} Could not kick **${member.user.tag}** because I am missing the \`Kick Members\` permission.`;
+ case 'error kicking':
+ return `${this.client.util.emojis.error} An error occurred while trying to kick **${member.user.tag}**.`;
+ case 'error creating modlog entry':
+ return `${this.client.util.emojis.error} While muting **${member.user.tag}**, there was an error creating a modlog entry, please report this to my developers.`;
+ case 'failed to dm':
+ return `${this.client.util.emojis.warn} Kicked **${member.user.tag}** however I could not send them a dm.`;
+ case 'success':
+ return `${this.client.util.emojis.success} Successfully kicked **${member.user.tag}**.`;
+ }
+ };
+ return await message.util.reply({ content: responseMessage(), allowedMentions: AllowedMentions.none() });
}
}
diff --git a/src/commands/moderation/modlog.ts b/src/commands/moderation/modlog.ts
index c71f962..af5f563 100644
--- a/src/commands/moderation/modlog.ts
+++ b/src/commands/moderation/modlog.ts
@@ -1,7 +1,6 @@
import { BushCommand, BushMessage, BushSlashMessage, ModLog } from '@lib';
import { Argument } from 'discord-akairo';
import { MessageEmbed } from 'discord.js';
-import moment from 'moment';
export default class ModlogCommand extends BushCommand {
public constructor() {
@@ -43,7 +42,7 @@ export default class ModlogCommand extends BushCommand {
`**User**: <@!${log.user}> (${log.user})`,
`**Moderator**: <@!${log.moderator}> (${log.moderator})`
];
- if (log.duration) modLog.push(`**Duration**: ${moment.duration(log.duration, 'milliseconds').humanize()}`);
+ if (log.duration) modLog.push(`**Duration**: ${this.client.util.humanizeDuration(log.duration)}`);
modLog.push(`**Reason**: ${log.reason || 'No Reason Specified.'}`);
return modLog.join(`\n`);
}
diff --git a/src/commands/moderation/mute.ts b/src/commands/moderation/mute.ts
index 0eae547..7443c55 100644
--- a/src/commands/moderation/mute.ts
+++ b/src/commands/moderation/mute.ts
@@ -1,4 +1,4 @@
-import { BushCommand, BushGuildMember, BushMessage, BushSlashMessage, BushUser } from '@lib';
+import { AllowedMentions, BushCommand, BushGuildMember, BushMessage, BushSlashMessage, BushUser } from '@lib';
import { Argument } from 'discord-akairo';
export default class MuteCommand extends BushCommand {
@@ -73,51 +73,35 @@ export default class MuteCommand extends BushCommand {
}
const parsedReason = reason.contentWithoutTime;
- const response = await member.mute({
+ const responseCode = await member.mute({
reason: parsedReason,
moderator: message.author,
duration: time
});
- switch (response) {
- case 'missing permissions':
- return message.util.reply(
- `${error} Could not mute ${victimBoldTag} because I am missing the \`Manage Roles\` permission.`
- );
- case 'no mute role':
- return message.util.reply(
- `${error} Could not mute ${victimBoldTag}, you must set a mute role with \`${message.guild.getSetting(
- 'prefix'
- )}muterole\`.`
- );
- case 'invalid mute role':
- return message.util.reply(
- `${error} Could not mute ${victimBoldTag} because the current mute role no longer exists. Please set a new mute role with \`${message.guild.getSetting(
- 'prefix'
- )}muterole\`.`
- );
- case 'mute role not manageable':
- return message.util.reply(
- `${error} Could not mute ${victimBoldTag} because I cannot assign the current mute role, either change the role's position or set a new mute role with \`${message.guild.getSetting(
- 'prefix'
- )}muterole\`.`
- );
- case 'error giving mute role':
- return message.util.reply(`${error} Could not mute ${victimBoldTag}, there was an error assigning them the mute role.`);
- case 'error creating modlog entry':
- return message.util.reply(
- `${error} While muting ${victimBoldTag}, there was an error creating a modlog entry, please report this to my developers.`
- );
- case 'error creating mute entry':
- return message.util.reply(
- `${error} While muting ${victimBoldTag}, there was an error creating a mute entry, please report this to my developers.`
- );
- case 'failed to dm':
- return message.util.reply(
- `${this.client.util.emojis.warn} Muted **${member.user.tag}** however I could not send them a dm.`
- );
- case 'success':
- return message.util.reply(`${this.client.util.emojis.success} Successfully muted **${member.user.tag}**.`);
- }
+ const responseMessage = () => {
+ const prefix = message.guild.getSetting('prefix');
+ switch (responseCode) {
+ case 'missing permissions':
+ return `${error} Could not mute ${victimBoldTag} because I am missing the \`Manage Roles\` permission.`;
+ case 'no mute role':
+ return `${error} Could not mute ${victimBoldTag}, you must set a mute role with \`${prefix}muterole\`.`;
+ case 'invalid mute role':
+ return `${error} Could not mute ${victimBoldTag} because the current mute role no longer exists. Please set a new mute role with \`${prefix}muterole\`.`;
+ case 'mute role not manageable':
+ return `${error} Could not mute ${victimBoldTag} because I cannot assign the current mute role, either change the role's position or set a new mute role with \`${prefix}muterole\`.`;
+ case 'error giving mute role':
+ return `${error} Could not mute ${victimBoldTag}, there was an error assigning them the mute role.`;
+ case 'error creating modlog entry':
+ return `${error} There was an error creating a modlog entry, please report this to my developers.`;
+ case 'error creating mute entry':
+ return `${error} There was an error creating a punishment entry, please report this to my developers.`;
+ case 'failed to dm':
+ return `${this.client.util.emojis.warn} Muted **${member.user.tag}** however I could not send them a dm.`;
+ case 'success':
+ return `${this.client.util.emojis.success} Successfully muted **${member.user.tag}**.`;
+ }
+ };
+ return await message.util.reply({ content: responseMessage(), allowedMentions: AllowedMentions.none() });
}
}
diff --git a/src/commands/moderation/role.ts b/src/commands/moderation/role.ts
index 29913d5..3470ab9 100644
--- a/src/commands/moderation/role.ts
+++ b/src/commands/moderation/role.ts
@@ -8,9 +8,44 @@ export default class RoleCommand extends BushCommand {
category: 'moderation',
description: {
content: "Manages users' roles.",
- usage: 'role <add|remove> <user> <role>',
- examples: ['role add tyman adminperms']
+ usage: 'role <add|remove> <user> <role> [duration]',
+ examples: ['role add spammer nogiveaways 7days']
},
+ args: [
+ {
+ id: 'action',
+ type: [['add'], ['remove']],
+ prompt: {
+ start: 'Would you like to `add` or `remove` a role?',
+ retry: '{error} Choose whether you would you like to `add` or `remove` a role.'
+ }
+ },
+ {
+ id: 'user',
+ type: 'member',
+ prompt: {
+ start: `What user do you want to add/remove the role to/from?`,
+ retry: `{error} Choose a valid user to add/remove the role to/from.`
+ }
+ },
+ {
+ id: 'role',
+ type: 'role',
+ prompt: {
+ start: `What role do you want to add/remove to/from the user.?`,
+ retry: `{error} Choose a valid role to add/remove.`
+ }
+ },
+ {
+ id: 'duration',
+ type: 'duration',
+ prompt: {
+ start: 'How long would you like to role to last?',
+ retry: '{error} Choose a valid duration.',
+ optional: true
+ }
+ }
+ ],
slash: true,
slashOptions: [
{
@@ -31,15 +66,21 @@ export default class RoleCommand extends BushCommand {
},
{
name: 'user',
- description: 'The user you would like to add/remove the role from.',
+ description: 'What user do you want to add/remove the role to/from?',
type: 'USER',
required: true
},
{
name: 'role',
- description: 'The role you would like to add/remove from the user.',
+ description: 'The role you would like to add/remove from the to/from.',
type: 'ROLE',
required: true
+ },
+ {
+ name: 'duration',
+ description: 'How long would you like to role to last?',
+ type: 'STRING',
+ required: false
}
],
channel: 'guild',
@@ -49,44 +90,11 @@ export default class RoleCommand extends BushCommand {
});
}
- *args(): unknown {
- const action: 'add' | 'remove' = yield {
- id: 'action',
- type: [['add'], ['remove']],
- prompt: {
- start: 'Would you like to `add` or `remove` a role?',
- retry: '{error} Choose whether you would you like to `add` or `remove` a role.'
- }
- };
- let action2: 'to' | 'from';
- if (action === 'add') action2 = 'to';
- else if (action === 'remove') action2 = 'from';
- else return;
- const user = yield {
- id: 'user',
- type: 'member',
- prompt: {
- start: `What user do you want to ${action} the role ${action2}?`,
- retry: `{error} Choose a valid user to ${action} the role ${action2}.`
- }
- };
- const role = yield {
- id: 'role',
- type: 'role',
- match: 'restContent',
- prompt: {
- start: `What role do you want to ${action}?`,
- retry: `{error} Choose a valid role to ${action}.`
- }
- };
- return { action, user, role };
- }
-
public async exec(
message: BushMessage | BushSlashMessage,
- { action, user, role }: { action: 'add' | 'remove'; user: BushGuildMember; role: BushRole }
+ { action, user, role, duration }: { action: 'add' | 'remove'; user: BushGuildMember; role: BushRole; duration: number }
): Promise<unknown> {
- if (!message.member.permissions.has('MANAGE_ROLES') && !message.author.isOwner()) {
+ if (!message.member.permissions.has('MANAGE_ROLES')) {
const mappings = this.client.consts.mappings;
let mappedRole: { name: string; id: string };
for (let i = 0; i < mappings.roleMap.length; i++) {
@@ -111,53 +119,51 @@ export default class RoleCommand extends BushCommand {
allowedMentions: AllowedMentions.none()
});
}
- } else if (!message.author.isOwner()) {
- if (role.comparePositionTo(message.member.roles.highest) >= 0) {
- return await message.util.reply({
- content: `${this.client.util.emojis.error} <@&${role.id}> is higher or equal to your highest role.`,
- allowedMentions: AllowedMentions.none()
- });
- }
- if (role.comparePositionTo(message.guild.me.roles.highest) >= 0) {
- return await message.util.reply({
- content: `${this.client.util.emojis.error} <@&${role.id}> is higher or equal to my highest role.`,
- allowedMentions: AllowedMentions.none()
- });
- }
- if (role.managed) {
- return await message.util.reply({
- content: `${this.client.util.emojis.error} <@&${role.id}> is managed by an integration and cannot be managed.`,
- allowedMentions: AllowedMentions.none()
- });
- }
}
- // no checks if the user has MANAGE_ROLES
- if (action == 'remove') {
- const success = await user.roles.remove(role.id).catch(() => {});
- if (success) {
- return await message.util.reply({
- content: `${this.client.util.emojis.success} Successfully removed <@&${role.id}> from <@${user.id}>!`,
- allowedMentions: AllowedMentions.none()
- });
- } else {
- return await message.util.reply({
- content: `${this.client.util.emojis.error} Could not remove <@&${role.id}> from <@${user.id}>.`,
- allowedMentions: AllowedMentions.none()
- });
- }
- } else if (action == 'add') {
- const success = await user.roles.add(role.id).catch(() => {});
- if (success) {
- return await message.util.reply({
- content: `${this.client.util.emojis.success} Successfully added <@&${role.id}> to <@${user.id}>!`,
- allowedMentions: AllowedMentions.none()
- });
- } else {
- return await message.util.reply({
- content: `${this.client.util.emojis.error} Could not add <@&${role.id}> to <@${user.id}>.`,
- allowedMentions: AllowedMentions.none()
- });
+
+ const shouldLog = this.punishmentRoleNames.includes(role.name);
+
+ const responseCode =
+ action === 'add'
+ ? await user.addRole({ moderator: message.member, addToModlog: shouldLog, role, duration })
+ : await user.removeRole({ moderator: message.member, addToModlog: shouldLog, role, duration });
+
+ const responseMessage = () => {
+ switch (responseCode) {
+ case 'user hierarchy':
+ return `${this.client.util.emojis.error} <@&${role.id}> is higher or equal to your highest role.`;
+ case 'role managed':
+ return `${this.client.util.emojis.error} <@&${role.id}> is managed by an integration and cannot be managed.`;
+ case 'client hierarchy':
+ return `${this.client.util.emojis.error} <@&${role.id}> is higher or equal to my highest role.`;
+ case 'error creating modlog entry':
+ return `${this.client.util.emojis.error} There was an error creating a modlog entry, please report this to my developers.`;
+ case 'error creating role entry' || 'error removing role entry':
+ return `${this.client.util.emojis.error} There was an error ${
+ action === 'add' ? 'creating' : 'removing'
+ } a punishment entry, please report this to my developers.`;
+ case 'error adding role' || 'error removing role':
+ return `${this.client.util.emojis.error} An error occurred while trying to ${action} <@&${role.id}> ${
+ action === 'add' ? 'to' : 'from'
+ } **${user.user.tag}**.`;
+ case 'success':
+ return `${this.client.util.emojis.success} Successfully ${action === 'add' ? 'added' : 'removed'} <@&${role.id}> ${
+ action === 'add' ? 'to' : 'from'
+ } **${user.user.tag}**${duration ? ` for ${this.client.util.humanizeDuration(duration)}` : ''}.`;
}
- }
+ };
+
+ await message.util.reply({ content: responseMessage(), allowedMentions: AllowedMentions.none() });
}
+
+ punishmentRoleNames = [
+ 'No Files',
+ 'No Links',
+ 'No Reactions',
+ 'No Suggestions',
+ 'No Bots',
+ 'No VC',
+ 'No Giveaways',
+ 'No Support'
+ ];
}
diff --git a/src/commands/moderation/unban.ts b/src/commands/moderation/unban.ts
index 4f52666..0de2489 100644
--- a/src/commands/moderation/unban.ts
+++ b/src/commands/moderation/unban.ts
@@ -1,4 +1,4 @@
-import { BushCommand, BushMessage, BushSlashMessage } from '@lib';
+import { AllowedMentions, BushCommand, BushMessage, BushSlashMessage } from '@lib';
import { User } from 'discord.js';
export default class UnbanCommand extends BushCommand {
@@ -55,31 +55,28 @@ export default class UnbanCommand extends BushCommand {
if (!(user instanceof User)) {
user = this.client.util.resolveUser(user, this.client.users.cache);
}
- const response = await message.guild.unban({
+ const responseCode = await message.guild.unban({
user,
moderator: message.author,
reason
});
- switch (response) {
- case 'missing permissions':
- return message.util.reply(
- `${this.client.util.emojis.error} Could not unban **${user.tag}** because I do not have permissions`
- );
- case 'error unbanning':
- return message.util.reply(`${this.client.util.emojis.error} An error occurred while trying to unban **${user.tag}**.`);
- case 'error removing ban entry':
- return message.util.reply(
- `${this.client.util.emojis.error} While unbanning **${user.tag}**, there was an error removing their ban entry, please report this to my developers.`
- );
- case 'error creating modlog entry':
- return message.util.reply(
- `${this.client.util.emojis.error} While unbanning **${user.tag}**, there was an error creating a modlog entry, please report this to my developers.`
- );
- case 'user not banned':
- return message.util.reply(`${this.client.util.emojis.warn} **${user.tag}** but I tried to unban them anyways.`);
- case 'success':
- return message.util.reply(`${this.client.util.emojis.success} Successfully unbanned **${user.tag}**.`);
- }
+ const responseMessage = () => {
+ switch (responseCode) {
+ case 'missing permissions':
+ return `${this.client.util.emojis.error} Could not unban **${user.tag}** because I do not have permissions`;
+ case 'error unbanning':
+ return `${this.client.util.emojis.error} An error occurred while trying to unban **${user.tag}**.`;
+ case 'error removing ban entry':
+ return `${this.client.util.emojis.error} While unbanning **${user.tag}**, there was an error removing their ban entry, please report this to my developers.`;
+ case 'error creating modlog entry':
+ return `${this.client.util.emojis.error} While unbanning **${user.tag}**, there was an error creating a modlog entry, please report this to my developers.`;
+ case 'user not banned':
+ return `${this.client.util.emojis.warn} **${user.tag}** but I tried to unban them anyways.`;
+ case 'success':
+ return `${this.client.util.emojis.success} Successfully unbanned **${user.tag}**.`;
+ }
+ };
+ return await message.util.reply({ content: responseMessage(), allowedMentions: AllowedMentions.none() });
}
}
diff --git a/src/commands/moderation/unmute.ts b/src/commands/moderation/unmute.ts
index 4030fb7..277ca91 100644
--- a/src/commands/moderation/unmute.ts
+++ b/src/commands/moderation/unmute.ts
@@ -1,4 +1,4 @@
-import { BushCommand, BushGuildMember, BushMessage, BushSlashMessage, BushUser } from '@lib';
+import { AllowedMentions, BushCommand, BushGuildMember, BushMessage, BushSlashMessage, BushUser } from '@lib';
export default class UnmuteCommand extends BushCommand {
public constructor() {
@@ -60,50 +60,34 @@ export default class UnmuteCommand extends BushCommand {
return message.util.reply(canModerateResponse);
}
- const response = await member.unmute({
+ const responseCode = await member.unmute({
reason,
moderator: message.author
});
- switch (response) {
- case 'missing permissions':
- return message.util.reply(
- `${error} Could not unmute ${victimBoldTag} because I am missing the \`Manage Roles\` permission.`
- );
- case 'no mute role':
- return message.util.reply(
- `${error} Could not unmute ${victimBoldTag}, you must set a mute role with \`${message.guild.getSetting(
- 'prefix'
- )}muterole\`.`
- );
- case 'invalid mute role':
- return message.util.reply(
- `${error} Could not unmute ${victimBoldTag} because the current mute role no longer exists. Please set a new mute role with \`${message.guild.getSetting(
- 'prefix'
- )}muterole\`.`
- );
- case 'mute role not manageable':
- return message.util.reply(
- `${error} Could not unmute ${victimBoldTag} because I cannot assign the current mute role, either change the role's position or set a new mute role with \`${message.guild.getSetting(
- 'prefix'
- )}muterole\`.`
- );
- case 'error removing mute role':
- return message.util.reply(`${error} Could not unmute ${victimBoldTag}, there was an error removing their mute role.`);
- case 'error creating modlog entry':
- return message.util.reply(
- `${error} While muting ${victimBoldTag}, there was an error creating a modlog entry, please report this to my developers.`
- );
- case 'error removing mute entry':
- return message.util.reply(
- `${error} While muting ${victimBoldTag}, there was an error removing their mute entry, please report this to my developers.`
- );
- case 'failed to dm':
- return message.util.reply(
- `${this.client.util.emojis.warn} unmuted **${member.user.tag}** however I could not send them a dm.`
- );
- case 'success':
- return message.util.reply(`${this.client.util.emojis.success} Successfully unmuted **${member.user.tag}**.`);
- }
+ const responseMessage = () => {
+ const prefix = message.guild.getSetting('prefix');
+ switch (responseCode) {
+ case 'missing permissions':
+ return `${error} Could not unmute ${victimBoldTag} because I am missing the \`Manage Roles\` permission.`;
+ case 'no mute role':
+ return `${error} Could not unmute ${victimBoldTag}, you must set a mute role with \`${prefix}muterole\`.`;
+ case 'invalid mute role':
+ return `${error} Could not unmute ${victimBoldTag} because the current mute role no longer exists. Please set a new mute role with \`${prefix}muterole\`.`;
+ case 'mute role not manageable':
+ return `${error} Could not unmute ${victimBoldTag} because I cannot assign the current mute role, either change the role's position or set a new mute role with \`${prefix}muterole\`.`;
+ case 'error removing mute role':
+ return `${error} Could not unmute ${victimBoldTag}, there was an error removing their mute role.`;
+ case 'error creating modlog entry':
+ return `${error} While muting ${victimBoldTag}, there was an error creating a modlog entry, please report this to my developers.`;
+ case 'error removing mute entry':
+ return `${error} While muting ${victimBoldTag}, there was an error removing their mute entry, please report this to my developers.`;
+ case 'failed to dm':
+ return `${this.client.util.emojis.warn} unmuted **${member.user.tag}** however I could not send them a dm.`;
+ case 'success':
+ return `${this.client.util.emojis.success} Successfully unmuted **${member.user.tag}**.`;
+ }
+ };
+ return await message.util.reply({ content: responseMessage(), allowedMentions: AllowedMentions.none() });
}
}