aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorIRONM00N <64110067+IRONM00N@users.noreply.github.com>2022-01-06 17:02:57 -0500
committerIRONM00N <64110067+IRONM00N@users.noreply.github.com>2022-01-06 17:02:57 -0500
commit1a48fd647fc84952439da5484d38f4d16c89198c (patch)
treed2033f7f614ee95013b3abb92b8ad890653d1fee /src
parente8a55bd9edf535d30171c2f1c7c3cc11b4f7595c (diff)
downloadtanzanite-1a48fd647fc84952439da5484d38f4d16c89198c.tar.gz
tanzanite-1a48fd647fc84952439da5484d38f4d16c89198c.tar.bz2
tanzanite-1a48fd647fc84952439da5484d38f4d16c89198c.zip
fixed some errors, made moderation methods use manual enum thing
Diffstat (limited to 'src')
-rw-r--r--src/commands/moderation/ban.ts13
-rw-r--r--src/commands/moderation/block.ts15
-rw-r--r--src/commands/moderation/evidence.ts4
-rw-r--r--src/commands/moderation/hideCase.ts4
-rw-r--r--src/commands/moderation/kick.ts22
-rw-r--r--src/commands/moderation/mute.ts19
-rw-r--r--src/commands/moderation/role.ts30
-rw-r--r--src/commands/moderation/timeout.ts22
-rw-r--r--src/commands/moderation/unban.ts23
-rw-r--r--src/commands/moderation/unblock.ts15
-rw-r--r--src/commands/moderation/unmute.ts19
-rw-r--r--src/commands/moderation/untimeout.ts19
-rw-r--r--src/commands/moderation/warn.ts8
-rw-r--r--src/lib/common/util/Moderation.ts62
-rw-r--r--src/lib/extensions/discord-akairo/BushClientUtil.ts4
-rw-r--r--src/lib/extensions/discord.js/BushButtonInteraction.ts2
-rw-r--r--src/lib/extensions/discord.js/BushClientEvents.d.ts2
-rw-r--r--src/lib/extensions/discord.js/BushCommandInteraction.ts2
-rw-r--r--src/lib/extensions/discord.js/BushGuild.ts149
-rw-r--r--src/lib/extensions/discord.js/BushGuildMember.ts379
-rw-r--r--src/lib/extensions/discord.js/BushSelectMenuInteraction.ts2
21 files changed, 515 insertions, 300 deletions
diff --git a/src/commands/moderation/ban.ts b/src/commands/moderation/ban.ts
index f21ccdc..7f0b91f 100644
--- a/src/commands/moderation/ban.ts
+++ b/src/commands/moderation/ban.ts
@@ -1,5 +1,6 @@
import {
AllowedMentions,
+ banResponse,
BushCommand,
Moderation,
type ArgType,
@@ -126,17 +127,17 @@ export default class BanCommand extends BushCommand {
const responseMessage = (): string => {
const victim = util.format.input(user.tag);
switch (responseCode) {
- case 'missing permissions':
+ case banResponse.MISSING_PERMISSIONS:
return `${util.emojis.error} Could not ban ${victim} because I am missing the **Ban Members** permission.`;
- case 'error banning':
+ case banResponse.ACTION_ERROR:
return `${util.emojis.error} An error occurred while trying to ban ${victim}.`;
- case 'error creating ban entry':
+ 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.`;
- case 'error creating modlog entry':
+ 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.`;
- case 'failed to dm':
+ case banResponse.DM_ERROR:
return `${util.emojis.warn} Banned ${victim} however I could not send them a dm.`;
- case 'success':
+ case banResponse.SUCCESS:
return `${util.emojis.success} Successfully banned ${victim}.`;
}
};
diff --git a/src/commands/moderation/block.ts b/src/commands/moderation/block.ts
index d53ffd5..57f909a 100644
--- a/src/commands/moderation/block.ts
+++ b/src/commands/moderation/block.ts
@@ -1,5 +1,6 @@
import {
AllowedMentions,
+ blockResponse,
BushCommand,
BushTextChannel,
BushThreadChannel,
@@ -105,19 +106,19 @@ export default class BlockCommand extends BushCommand {
const responseMessage = (): string => {
const victim = util.format.input(member.user.tag);
switch (responseCode) {
- case 'missing permissions':
+ case blockResponse.MISSING_PERMISSIONS:
return `${util.emojis.error} Could not block ${victim} because I am missing the **Manage Channel** permission.`;
- case 'invalid channel':
+ case blockResponse.INVALID_CHANNEL:
return `${util.emojis.error} Could not block ${victim}, you can only block users in text or thread channels.`;
- case 'error blocking':
+ case blockResponse.ACTION_ERROR:
return `${util.emojis.error} An unknown error occurred while trying to block ${victim}.`;
- case 'error creating modlog entry':
+ case blockResponse.MODLOG_ERROR:
return `${util.emojis.error} There was an error creating a modlog entry, please report this to my developers.`;
- case 'error creating block entry':
+ case blockResponse.PUNISHMENT_ENTRY_ADD_ERROR:
return `${util.emojis.error} There was an error creating a punishment entry, please report this to my developers.`;
- case 'failed to dm':
+ case blockResponse.DM_ERROR:
return `${util.emojis.warn} Blocked ${victim} however I could not send them a dm.`;
- case 'success':
+ case blockResponse.SUCCESS:
return `${util.emojis.success} Successfully blocked ${victim}.`;
}
};
diff --git a/src/commands/moderation/evidence.ts b/src/commands/moderation/evidence.ts
index 714a2e5..cff63ed 100644
--- a/src/commands/moderation/evidence.ts
+++ b/src/commands/moderation/evidence.ts
@@ -7,8 +7,8 @@ export default class EvidenceCommand extends BushCommand {
aliases: ['evidence'],
category: 'moderation',
description: 'Add evidence to a modlog case.',
- usage: ['evidence <case_id> <evidence>'],
- examples: ['evidence 9210b1ea-91f5-4ea2-801b-02b394469c77 was spamming in #general'],
+ usage: ['evidence <caseId> <evidence>'],
+ examples: ['evidence IgQvFpzgIKJ77mZ62TEuG was spamming in #general'],
args: [
{
id: 'case_id',
diff --git a/src/commands/moderation/hideCase.ts b/src/commands/moderation/hideCase.ts
index 04160fd..e12d8c8 100644
--- a/src/commands/moderation/hideCase.ts
+++ b/src/commands/moderation/hideCase.ts
@@ -6,8 +6,8 @@ export default class HideCaseCommand extends BushCommand {
aliases: ['hide-case', 'hide_case', 'show-case', 'show_case', 'cover-up-mod-abuse', 'cover_up_mod_abuse'],
category: 'moderation',
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'],
+ usage: ['hide-case <caseId>'],
+ examples: ['hide-case Xurm---HdRyHlrKLsOcIO'],
args: [
{
id: 'case_id',
diff --git a/src/commands/moderation/kick.ts b/src/commands/moderation/kick.ts
index 6d96ae9..af486ac 100644
--- a/src/commands/moderation/kick.ts
+++ b/src/commands/moderation/kick.ts
@@ -1,4 +1,12 @@
-import { AllowedMentions, BushCommand, Moderation, type ArgType, type BushMessage, type BushSlashMessage } from '#lib';
+import {
+ AllowedMentions,
+ BushCommand,
+ kickResponse,
+ Moderation,
+ type ArgType,
+ type BushMessage,
+ type BushSlashMessage
+} from '#lib';
export default class KickCommand extends BushCommand {
public constructor() {
@@ -68,15 +76,15 @@ export default class KickCommand extends BushCommand {
const responseMessage = (): string => {
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.`;
- case 'error kicking':
+ case kickResponse.MISSING_PERMISSIONS:
+ return `${util.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}.`;
- case 'error creating modlog entry':
+ 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.`;
- case 'failed to dm':
+ case kickResponse.DM_ERROR:
return `${util.emojis.warn} Kicked ${victim} however I could not send them a dm.`;
- case 'success':
+ case kickResponse.SUCCESS:
return `${util.emojis.success} Successfully kicked ${victim}.`;
}
};
diff --git a/src/commands/moderation/mute.ts b/src/commands/moderation/mute.ts
index e731e30..40e13e7 100644
--- a/src/commands/moderation/mute.ts
+++ b/src/commands/moderation/mute.ts
@@ -2,6 +2,7 @@ import {
AllowedMentions,
BushCommand,
Moderation,
+ muteResponse,
type ArgType,
type BushMessage,
type BushSlashMessage,
@@ -99,23 +100,23 @@ export default class MuteCommand extends BushCommand {
const prefix = util.prefix(message);
const victim = util.format.input(member.user.tag);
switch (responseCode) {
- case 'missing permissions':
+ case muteResponse.MISSING_PERMISSIONS:
return `${util.emojis.error} Could not mute ${victim} because I am missing the **Manage Roles** permission.`;
- case 'no mute role':
+ case muteResponse.NO_MUTE_ROLE:
return `${util.emojis.error} Could not mute ${victim}, you must set a mute role with \`${prefix}config muteRole\`.`;
- case 'invalid mute role':
+ case muteResponse.MUTE_ROLE_INVALID:
return `${util.emojis.error} Could not mute ${victim} because the current mute role no longer exists. Please set a new mute role with \`${prefix}config muteRole\`.`;
- case 'mute role not manageable':
+ case muteResponse.MUTE_ROLE_NOT_MANAGEABLE:
return `${util.emojis.error} Could not mute ${victim} because I cannot assign the current mute role, either change the role's position or set a new mute role with \`${prefix}config muteRole\`.`;
- case 'error giving mute role':
+ case muteResponse.ACTION_ERROR:
return `${util.emojis.error} Could not mute ${victim}, there was an error assigning them the mute role.`;
- case 'error creating modlog entry':
+ case muteResponse.MODLOG_ERROR:
return `${util.emojis.error} There was an error creating a modlog entry, please report this to my developers.`;
- case 'error creating mute entry':
+ case muteResponse.PUNISHMENT_ENTRY_ADD_ERROR:
return `${util.emojis.error} There was an error creating a punishment entry, please report this to my developers.`;
- case 'failed to dm':
+ case muteResponse.DM_ERROR:
return `${util.emojis.warn} Muted ${victim} however I could not send them a dm.`;
- case 'success':
+ case muteResponse.SUCCESS:
return `${util.emojis.success} Successfully muted ${victim}.`;
}
};
diff --git a/src/commands/moderation/role.ts b/src/commands/moderation/role.ts
index 6cb8d2f..f0d0448 100644
--- a/src/commands/moderation/role.ts
+++ b/src/commands/moderation/role.ts
@@ -1,4 +1,13 @@
-import { AllowedMentions, BushCommand, type ArgType, type BushMessage, type BushSlashMessage, type OptionalArgType } from '#lib';
+import {
+ addRoleResponse,
+ AllowedMentions,
+ BushCommand,
+ removeRoleResponse,
+ type ArgType,
+ type BushMessage,
+ type BushSlashMessage,
+ type OptionalArgType
+} from '#lib';
import { type ArgumentOptions, type Flag } from 'discord-akairo';
import { type Snowflake } from 'discord.js';
@@ -170,25 +179,26 @@ export default class RoleCommand extends BushCommand {
const responseMessage = (): string => {
const victim = util.format.input(args.member.user.tag);
switch (responseCode) {
- case 'user hierarchy':
+ case addRoleResponse.MISSING_PERMISSIONS:
+ return `${util.emojis.error} I don't have the **Manage Roles** permission.`;
+ case addRoleResponse.USER_HIERARCHY:
return `${util.emojis.error} <@&${args.role.id}> is higher or equal to your highest role.`;
- case 'role managed':
+ case addRoleResponse.ROLE_MANAGED:
return `${util.emojis.error} <@&${args.role.id}> is managed by an integration and cannot be managed.`;
- case 'client hierarchy':
+ case addRoleResponse.CLIENT_HIERARCHY:
return `${util.emojis.error} <@&${args.role.id}> is higher or equal to my highest role.`;
- case 'error creating modlog entry':
+ case addRoleResponse.MODLOG_ERROR:
return `${util.emojis.error} There was an error creating a modlog entry, please report this to my developers.`;
- case 'error creating role entry':
- case 'error removing role entry':
+ case addRoleResponse.PUNISHMENT_ENTRY_ADD_ERROR:
+ case removeRoleResponse.PUNISHMENT_ENTRY_REMOVE_ERROR:
return `${util.emojis.error} There was an error ${
args.action === 'add' ? 'creating' : 'removing'
} a punishment entry, please report this to my developers.`;
- case 'error adding role':
- case 'error removing role':
+ case addRoleResponse.ACTION_ERROR:
return `${util.emojis.error} An error occurred while trying to ${args.action} <@&${args.role.id}> ${
args.action === 'add' ? 'to' : 'from'
} ${victim}.`;
- case 'success':
+ case addRoleResponse.SUCCESS:
return `${util.emojis.success} Successfully ${args.action === 'add' ? 'added' : 'removed'} <@&${args.role.id}> ${
args.action === 'add' ? 'to' : 'from'
} ${victim}${args.duration ? ` for ${util.humanizeDuration(args.duration)}` : ''}.`;
diff --git a/src/commands/moderation/timeout.ts b/src/commands/moderation/timeout.ts
index 3968bde..ec79271 100644
--- a/src/commands/moderation/timeout.ts
+++ b/src/commands/moderation/timeout.ts
@@ -1,4 +1,12 @@
-import { AllowedMentions, BushCommand, Moderation, type ArgType, type BushMessage, type BushSlashMessage } from '#lib';
+import {
+ AllowedMentions,
+ BushCommand,
+ Moderation,
+ timeoutResponse,
+ type ArgType,
+ type BushMessage,
+ type BushSlashMessage
+} from '#lib';
import assert from 'assert';
export default class TimeoutCommand extends BushCommand {
@@ -81,17 +89,17 @@ export default class TimeoutCommand extends BushCommand {
const responseMessage = (): string => {
const victim = util.format.input(member.user.tag);
switch (responseCode) {
- case 'missing permissions':
+ case timeoutResponse.MISSING_PERMISSIONS:
return `${util.emojis.error} Could not timeout ${victim} because I am missing the **Timeout Members** permission.`;
- case 'duration too long':
+ case timeoutResponse.INVALID_DURATION:
return `${util.emojis.error} The duration you specified is too long, the longest you can timeout someone for is 28 days.`;
- case 'error timing out':
+ case timeoutResponse.ACTION_ERROR:
return `${util.emojis.error} An unknown error occurred while trying to timeout ${victim}.`;
- case 'error creating modlog entry':
+ case timeoutResponse.MODLOG_ERROR:
return `${util.emojis.error} There was an error creating a modlog entry, please report this to my developers.`;
- case 'failed to dm':
+ case timeoutResponse.DM_ERROR:
return `${util.emojis.warn} Timed out ${victim} however I could not send them a dm.`;
- case 'success':
+ case timeoutResponse.SUCCESS:
return `${util.emojis.success} Successfully timed out ${victim}.`;
}
};
diff --git a/src/commands/moderation/unban.ts b/src/commands/moderation/unban.ts
index bbce4e0..c939792 100644
--- a/src/commands/moderation/unban.ts
+++ b/src/commands/moderation/unban.ts
@@ -1,4 +1,12 @@
-import { AllowedMentions, BushCommand, type ArgType, type BushMessage, type BushSlashMessage, type OptionalArgType } from '#lib';
+import {
+ AllowedMentions,
+ BushCommand,
+ unbanResponse,
+ type ArgType,
+ type BushMessage,
+ type BushSlashMessage,
+ type OptionalArgType
+} from '#lib';
export default class UnbanCommand extends BushCommand {
public constructor() {
@@ -47,17 +55,18 @@ export default class UnbanCommand extends BushCommand {
const responseMessage = (): string => {
const victim = util.format.input(user.tag);
switch (responseCode) {
- case 'missing permissions':
+ case unbanResponse.MISSING_PERMISSIONS:
return `${util.emojis.error} Could not unban ${victim} because I am missing the **Ban Members** permission.`;
- case 'error unbanning':
+ case unbanResponse.ACTION_ERROR:
return `${util.emojis.error} An error occurred while trying to unban ${victim}.`;
- case 'error removing ban entry':
+ case unbanResponse.PUNISHMENT_ENTRY_REMOVE_ERROR:
return `${util.emojis.error} While unbanning ${victim}, there was an error removing their ban entry, please report this to my developers.`;
- case 'error creating modlog entry':
+ case unbanResponse.MODLOG_ERROR:
return `${util.emojis.error} While unbanning ${victim}, there was an error creating a modlog entry, please report this to my developers.`;
- case 'user not banned':
+ case unbanResponse.NOT_BANNED:
return `${util.emojis.warn} ${victim} is not banned but I tried to unban them anyways.`;
- case 'success':
+ case unbanResponse.DM_ERROR:
+ case unbanResponse.SUCCESS:
return `${util.emojis.success} Successfully unbanned ${victim}.`;
}
};
diff --git a/src/commands/moderation/unblock.ts b/src/commands/moderation/unblock.ts
index 4cc8b49..454de8b 100644
--- a/src/commands/moderation/unblock.ts
+++ b/src/commands/moderation/unblock.ts
@@ -4,6 +4,7 @@ import {
BushTextChannel,
BushThreadChannel,
Moderation,
+ unblockResponse,
type ArgType,
type BushMessage,
type BushSlashMessage,
@@ -87,19 +88,19 @@ export default class UnblockCommand extends BushCommand {
const responseMessage = (): string => {
const victim = util.format.input(member.user.tag);
switch (responseCode) {
- case 'missing permissions':
+ case unblockResponse.MISSING_PERMISSIONS:
return `${util.emojis.error} Could not unblock ${victim} because I am missing the **Manage Channel** permission.`;
- case 'invalid channel':
+ case unblockResponse.INVALID_CHANNEL:
return `${util.emojis.error} Could not unblock ${victim}, you can only unblock users in text or thread channels.`;
- case 'error unblocking':
+ case unblockResponse.ACTION_ERROR:
return `${util.emojis.error} An unknown error occurred while trying to unblock ${victim}.`;
- case 'error creating modlog entry':
+ case unblockResponse.MODLOG_ERROR:
return `${util.emojis.error} There was an error creating a modlog entry, please report this to my developers.`;
- case 'error removing block entry':
+ case unblockResponse.PUNISHMENT_ENTRY_REMOVE_ERROR:
return `${util.emojis.error} There was an error creating a punishment entry, please report this to my developers.`;
- case 'failed to dm':
+ case unblockResponse.DM_ERROR:
return `${util.emojis.warn} Unblocked ${victim} however I could not send them a dm.`;
- case 'success':
+ case unblockResponse.SUCCESS:
return `${util.emojis.success} Successfully unblocked ${victim}.`;
}
};
diff --git a/src/commands/moderation/unmute.ts b/src/commands/moderation/unmute.ts
index 631f213..3bd399f 100644
--- a/src/commands/moderation/unmute.ts
+++ b/src/commands/moderation/unmute.ts
@@ -2,6 +2,7 @@ import {
AllowedMentions,
BushCommand,
Moderation,
+ unmuteResponse,
type ArgType,
type BushGuildMember,
type BushMessage,
@@ -79,23 +80,23 @@ export default class UnmuteCommand extends BushCommand {
const prefix = util.prefix(message);
const victim = util.format.input(member.user.tag);
switch (responseCode) {
- case 'missing permissions':
+ case unmuteResponse.MISSING_PERMISSIONS:
return `${error} Could not unmute ${victim} because I am missing the **Manage Roles** permission.`;
- case 'no mute role':
+ case unmuteResponse.NO_MUTE_ROLE:
return `${error} Could not unmute ${victim}, you must set a mute role with \`${prefix}config muteRole\`.`;
- case 'invalid mute role':
+ case unmuteResponse.MUTE_ROLE_INVALID:
return `${error} Could not unmute ${victim} because the current mute role no longer exists. Please set a new mute role with \`${prefix}config muteRole\`.`;
- case 'mute role not manageable':
+ case unmuteResponse.MUTE_ROLE_NOT_MANAGEABLE:
return `${error} Could not unmute ${victim} because I cannot assign the current mute role, either change the role's position or set a new mute role with \`${prefix}config muteRole\`.`;
- case 'error removing mute role':
+ case unmuteResponse.ACTION_ERROR:
return `${error} Could not unmute ${victim}, there was an error removing their mute role.`;
- case 'error creating modlog entry':
+ case unmuteResponse.MODLOG_ERROR:
return `${error} While muting ${victim}, there was an error creating a modlog entry, please report this to my developers.`;
- case 'error removing mute entry':
+ case unmuteResponse.PUNISHMENT_ENTRY_REMOVE_ERROR:
return `${error} While muting ${victim}, there was an error removing their mute entry, please report this to my developers.`;
- case 'failed to dm':
+ case unmuteResponse.DM_ERROR:
return `${util.emojis.warn} unmuted ${victim} however I could not send them a dm.`;
- case 'success':
+ case unmuteResponse.SUCCESS:
return `${util.emojis.success} Successfully unmuted ${victim}.`;
}
};
diff --git a/src/commands/moderation/untimeout.ts b/src/commands/moderation/untimeout.ts
index b5ea5be..c5518b4 100644
--- a/src/commands/moderation/untimeout.ts
+++ b/src/commands/moderation/untimeout.ts
@@ -2,6 +2,7 @@ import {
AllowedMentions,
BushCommand,
Moderation,
+ removeTimeoutResponse,
type ArgType,
type BushMessage,
type BushSlashMessage,
@@ -81,18 +82,16 @@ export default class UntimeoutCommand extends BushCommand {
const responseMessage = (): string => {
const victim = util.format.input(member.user.tag);
switch (responseCode) {
- case 'missing permissions':
- return `${util.emojis.error} Could not timeout ${victim} because I am missing the **Timeout Members** permission.`;
- case 'duration too long':
- return `${util.emojis.error} The duration you specified is too long, the longest you can timeout someone for is 28 days.`;
- case 'error removing timeout':
+ case removeTimeoutResponse.MISSING_PERMISSIONS:
+ return `${util.emojis.error} Could not untimeout ${victim} because I am missing the **Timeout Members** permission.`;
+ case removeTimeoutResponse.ACTION_ERROR:
return `${util.emojis.error} An unknown error occurred while trying to timeout ${victim}.`;
- case 'error creating modlog entry':
+ case removeTimeoutResponse.MODLOG_ERROR:
return `${util.emojis.error} There was an error creating a modlog entry, please report this to my developers.`;
- case 'failed to dm':
- return `${util.emojis.warn} Timed out ${victim} however I could not send them a dm.`;
- case 'success':
- return `${util.emojis.success} Successfully timed out ${victim}.`;
+ case removeTimeoutResponse.DM_ERROR:
+ return `${util.emojis.warn} Removed ${victim}'s timeout however I could not send them a dm.`;
+ case removeTimeoutResponse.SUCCESS:
+ return `${util.emojis.success} Successfully removed ${victim}'s timeout.`;
}
};
return await message.util.reply({ content: responseMessage(), allowedMentions: AllowedMentions.none() });
diff --git a/src/commands/moderation/warn.ts b/src/commands/moderation/warn.ts
index 05b1e36..aebf300 100644
--- a/src/commands/moderation/warn.ts
+++ b/src/commands/moderation/warn.ts
@@ -2,6 +2,7 @@ import {
AllowedMentions,
BushCommand,
Moderation,
+ warnResponse,
type ArgType,
type BushGuildMember,
type BushMessage,
@@ -75,13 +76,14 @@ export default class WarnCommand extends BushCommand {
const responseMessage = (): string => {
const victim = util.format.input(member.user.tag);
switch (response) {
- case 'error creating modlog entry':
+ case warnResponse.MODLOG_ERROR:
return `${util.emojis.error} While warning ${victim}, there was an error creating a modlog entry, please report this to my developers.`;
- case 'failed to dm':
+ case warnResponse.ACTION_ERROR:
+ case warnResponse.DM_ERROR:
return `${util.emojis.warn} ${victim} has been warned for the ${util.ordinal(
caseNum ?? 0
)} time, however I could not send them a dm.`;
- case 'success':
+ case warnResponse.SUCCESS:
return `${util.emojis.success} Successfully warned ${victim} for the ${util.ordinal(caseNum ?? 0)} time.`;
}
};
diff --git a/src/lib/common/util/Moderation.ts b/src/lib/common/util/Moderation.ts
index a09930b..9757f25 100644
--- a/src/lib/common/util/Moderation.ts
+++ b/src/lib/common/util/Moderation.ts
@@ -3,12 +3,14 @@ import {
ActivePunishmentType,
Guild,
ModLog,
+ type BushGuild,
type BushGuildMember,
type BushGuildMemberResolvable,
type BushGuildResolvable,
+ type BushUserResolvable,
type ModLogType
} from '#lib';
-import { type Snowflake } from 'discord.js';
+import { MessageEmbed, type Snowflake } from 'discord.js';
/**
* A utility class with moderation-related methods.
@@ -197,6 +199,28 @@ export class Moderation {
};
return typeMap[type];
}
+
+ public static async punishDM(options: PunishDMOptions): Promise<boolean> {
+ const ending = await options.guild.getSetting('punishmentEnding');
+ const dmEmbed =
+ ending && ending.length && options.sendFooter
+ ? new MessageEmbed().setDescription(ending).setColor(util.colors.newBlurple)
+ : undefined;
+
+ const dmSuccess = await client.users
+ .send(options.user, {
+ content: `You have been ${options.punishment} in **${options.guild.name}** ${
+ options.duration !== null && options.duration !== undefined
+ ? options.duration
+ ? `for ${util.humanizeDuration(options.duration)} `
+ : 'permanently '
+ : ''
+ }for **${options.reason?.trim() ? options.reason?.trim() : 'No reason provided'}**.`,
+ embeds: dmEmbed ? [dmEmbed] : undefined
+ })
+ .catch(() => false);
+ return !!dmSuccess;
+ }
}
/**
@@ -303,3 +327,39 @@ export interface RemovePunishmentEntryOptions {
*/
extraInfo?: Snowflake;
}
+
+/**
+ * Options for sending a user a punishment dm.
+ */
+export interface PunishDMOptions {
+ /**
+ * The guild that the punishment is taking place in.
+ */
+ guild: BushGuild;
+
+ /**
+ * The user that is being punished.
+ */
+ user: BushUserResolvable;
+
+ /**
+ * The punishment that the user has received.
+ */
+ punishment: string;
+
+ /**
+ * The reason the user's punishment.
+ */
+ reason?: string;
+
+ /**
+ * The duration of the punishment.
+ */
+ duration?: number;
+
+ /**
+ * Whether or not to send the guild's punishment footer with the dm.
+ * @default true
+ */
+ sendFooter: boolean;
+}
diff --git a/src/lib/extensions/discord-akairo/BushClientUtil.ts b/src/lib/extensions/discord-akairo/BushClientUtil.ts
index 47a3717..d7416bb 100644
--- a/src/lib/extensions/discord-akairo/BushClientUtil.ts
+++ b/src/lib/extensions/discord-akairo/BushClientUtil.ts
@@ -2,7 +2,6 @@ import {
Arg,
BushConstants,
Global,
- GlobalCache,
type BushClient,
type BushInspectOptions,
type BushMessage,
@@ -11,14 +10,15 @@ import {
type BushSlashSendMessageType,
type BushUser,
type CodeBlockLang,
+ type GlobalCache,
type Pronoun,
type PronounCode
} from '#lib';
+import type { APIMessage } from '@discordjs/builders/node_modules/discord-api-types';
import { humanizeDuration } from '@notenoughupdates/humanize-duration';
import { exec } from 'child_process';
import deepLock from 'deep-lock';
import { ClientUtil, Util as AkairoUtil } from 'discord-akairo';
-import { APIMessage } from 'discord-api-types';
import {
Constants as DiscordConstants,
GuildMember,
diff --git a/src/lib/extensions/discord.js/BushButtonInteraction.ts b/src/lib/extensions/discord.js/BushButtonInteraction.ts
index 2bc1c25..191ad5c 100644
--- a/src/lib/extensions/discord.js/BushButtonInteraction.ts
+++ b/src/lib/extensions/discord.js/BushButtonInteraction.ts
@@ -1,5 +1,5 @@
import type { BushClient, BushGuild, BushGuildMember, BushGuildTextBasedChannel, BushTextBasedChannel, BushUser } from '#lib';
-import type { APIInteractionGuildMember } from 'discord-api-types/v9';
+import type { APIInteractionGuildMember } from '@discordjs/builders/node_modules/discord-api-types/payloads/v9/_interactions/base';
import { ButtonInteraction, type CacheType, type CacheTypeReducer } from 'discord.js';
import type { RawMessageButtonInteractionData } from 'discord.js/typings/rawDataTypes';
diff --git a/src/lib/extensions/discord.js/BushClientEvents.d.ts b/src/lib/extensions/discord.js/BushClientEvents.d.ts
index 16eccd4..b5ad749 100644
--- a/src/lib/extensions/discord.js/BushClientEvents.d.ts
+++ b/src/lib/extensions/discord.js/BushClientEvents.d.ts
@@ -173,7 +173,7 @@ export interface BushClientEvents extends AkairoClientEvents {
evidence?: string
];
bushBlock: [
- victim: BushGuildMember | BushUser,
+ victim: BushGuildMember,
moderator: BushUser,
guild: BushGuild,
reason: string | undefined,
diff --git a/src/lib/extensions/discord.js/BushCommandInteraction.ts b/src/lib/extensions/discord.js/BushCommandInteraction.ts
index 5f32829..f4be5ed 100644
--- a/src/lib/extensions/discord.js/BushCommandInteraction.ts
+++ b/src/lib/extensions/discord.js/BushCommandInteraction.ts
@@ -10,7 +10,7 @@ import type {
BushTextBasedChannel,
BushUser
} from '#lib';
-import type { APIInteractionGuildMember } from 'discord-api-types/v9';
+import type { APIInteractionGuildMember } from '@discordjs/builders/node_modules/discord-api-types';
import { CommandInteraction, type CacheType, type CacheTypeReducer, type Invite, type Snowflake } from 'discord.js';
import type { RawCommandInteractionData } from 'discord.js/typings/rawDataTypes';
diff --git a/src/lib/extensions/discord.js/BushGuild.ts b/src/lib/extensions/discord.js/BushGuild.ts
index ea8b67e..0011ce6 100644
--- a/src/lib/extensions/discord.js/BushGuild.ts
+++ b/src/lib/extensions/discord.js/BushGuild.ts
@@ -1,26 +1,23 @@
-import type {
- BushClient,
- BushGuildMember,
- BushGuildMemberManager,
- BushGuildMemberResolvable,
- BushNewsChannel,
- BushTextChannel,
- BushThreadChannel,
- BushUser,
- BushUserResolvable,
- GuildFeatures,
- GuildLogType,
- GuildModel
-} from '#lib';
import {
- Collection,
- Guild,
- GuildChannelManager,
- Snowflake,
- type MessageOptions,
- type MessagePayload,
- type UserResolvable
-} from 'discord.js';
+ banResponse,
+ dmResponse,
+ permissionsResponse,
+ punishmentEntryRemove,
+ type BanResponse,
+ type BushClient,
+ type BushGuildMember,
+ type BushGuildMemberManager,
+ type BushGuildMemberResolvable,
+ type BushNewsChannel,
+ type BushTextChannel,
+ type BushThreadChannel,
+ type BushUser,
+ type BushUserResolvable,
+ type GuildFeatures,
+ type GuildLogType,
+ type Guild