Tickets! and a lot of bug fixes
diff --git a/src/commands/mod/unmute.ts b/src/commands/mod/unmute.ts
index c93f8cc..e2585e1 100644
--- a/src/commands/mod/unmute.ts
+++ b/src/commands/mod/unmute.ts
@@ -43,6 +43,7 @@
notify
)
.addReasonButton(reason ?? "")
+ .setFailedMessage("No changes were made", "Success", "PUNISH.MUTE.GREEN")
.send(reason !== null);
if (confirmation.cancelled) timedOut = true;
else if (confirmation.success !== undefined) success = true;
@@ -51,96 +52,83 @@
notify = confirmation.components!["notify"]!.active;
}
} while (!timedOut && !success);
- if (confirmation.cancelled) return;
- if (confirmation.success) {
- let dmSent = false;
- let dmMessage;
- try {
- if (notify) {
- dmMessage = await (interaction.options.getMember("user") as GuildMember).send({
- embeds: [
- new EmojiEmbed()
- .setEmoji("PUNISH.MUTE.GREEN")
- .setTitle("Unmuted")
- .setDescription(
- `You have been unmuted in ${interaction.guild.name}` +
- (reason ? ` for:\n> ${reason}` : " with no reason provided.")
- )
- .setStatus("Success")
- ]
- });
- dmSent = true;
- }
- } catch {
- dmSent = false;
- }
- const member = interaction.options.getMember("user") as GuildMember;
- try {
- member.timeout(0, reason ?? "*No reason provided*");
- } catch {
- await interaction.editReply({
+ if (confirmation.cancelled || !confirmation.success) return;
+ let dmSent = false;
+ let dmMessage;
+ try {
+ if (notify) {
+ dmMessage = await (interaction.options.getMember("user") as GuildMember).send({
embeds: [
new EmojiEmbed()
- .setEmoji("PUNISH.MUTE.RED")
- .setTitle("Unmute")
- .setDescription("Something went wrong and the user was not unmuted")
- .setStatus("Danger")
- ],
- components: []
+ .setEmoji("PUNISH.MUTE.GREEN")
+ .setTitle("Unmuted")
+ .setDescription(
+ `You have been unmuted in ${interaction.guild.name}` +
+ (reason ? ` for:\n> ${reason}` : " with no reason provided.")
+ )
+ .setStatus("Success")
+ ]
});
- if (dmSent && dmMessage) await dmMessage.delete();
- return;
+ dmSent = true;
}
- await client.database.history.create(
- "unmute",
- interaction.guild.id,
- (interaction.options.getMember("user") as GuildMember).user,
- interaction.user,
- reason
- );
- const data = {
- meta: {
- type: "memberUnmute",
- displayName: "Unmuted",
- calculateType: "guildMemberPunish",
- color: NucleusColors.green,
- emoji: "PUNISH.MUTE.GREEN",
- timestamp: new Date().getTime()
- },
- list: {
- memberId: entry(member.user.id, `\`${member.user.id}\``),
- name: entry(member.user.id, renderUser(member.user)),
- unmuted: entry(new Date().getTime().toString(), renderDelta(new Date().getTime())),
- unmutedBy: entry(interaction.user.id, renderUser(interaction.user))
- },
- hidden: {
- guild: interaction.guild.id
- }
- };
- log(data);
- const failed = !dmSent && notify;
- await interaction.editReply({
- embeds: [
- new EmojiEmbed()
- .setEmoji(`PUNISH.MUTE.${failed ? "YELLOW" : "GREEN"}`)
- .setTitle("Unmute")
- .setDescription("The member was unmuted" + (failed ? ", but could not be notified" : ""))
- .setStatus(failed ? "Warning" : "Success")
- ],
- components: []
- });
- } else {
- await interaction.editReply({
- embeds: [
- new EmojiEmbed()
- .setEmoji("PUNISH.MUTE.GREEN")
- .setTitle("Unmute")
- .setDescription("No changes were made")
- .setStatus("Success")
- ],
- components: []
- });
+ } catch {
+ dmSent = false;
}
+ const member = interaction.options.getMember("user") as GuildMember;
+ try {
+ member.timeout(0, reason ?? "*No reason provided*");
+ } catch {
+ await interaction.editReply({
+ embeds: [
+ new EmojiEmbed()
+ .setEmoji("PUNISH.MUTE.RED")
+ .setTitle("Unmute")
+ .setDescription("Something went wrong and the user was not unmuted")
+ .setStatus("Danger")
+ ],
+ components: []
+ });
+ if (dmSent && dmMessage) await dmMessage.delete();
+ return;
+ }
+ await client.database.history.create(
+ "unmute",
+ interaction.guild.id,
+ (interaction.options.getMember("user") as GuildMember).user,
+ interaction.user,
+ reason
+ );
+ const data = {
+ meta: {
+ type: "memberUnmute",
+ displayName: "Unmuted",
+ calculateType: "guildMemberPunish",
+ color: NucleusColors.green,
+ emoji: "PUNISH.MUTE.GREEN",
+ timestamp: new Date().getTime()
+ },
+ list: {
+ memberId: entry(member.user.id, `\`${member.user.id}\``),
+ name: entry(member.user.id, renderUser(member.user)),
+ unmuted: entry(new Date().getTime().toString(), renderDelta(new Date().getTime())),
+ unmutedBy: entry(interaction.user.id, renderUser(interaction.user))
+ },
+ hidden: {
+ guild: interaction.guild.id
+ }
+ };
+ log(data);
+ const failed = !dmSent && notify;
+ await interaction.editReply({
+ embeds: [
+ new EmojiEmbed()
+ .setEmoji(`PUNISH.MUTE.${failed ? "YELLOW" : "GREEN"}`)
+ .setTitle("Unmute")
+ .setDescription("The member was unmuted" + (failed ? ", but could not be notified" : ""))
+ .setStatus(failed ? "Warning" : "Success")
+ ],
+ components: []
+ });
};
const check = (interaction: CommandInteraction) => {
@@ -152,18 +140,18 @@
const mePos = me.roles.cache.size > 1 ? me.roles.highest.position : 0;
const applyPos = apply.roles.cache.size > 1 ? apply.roles.highest.position : 0;
// Do not allow unmuting the owner
- if (member.id === interaction.guild.ownerId) throw new Error("You cannot unmute the owner of the server");
+ if (member.id === interaction.guild.ownerId) return "You cannot unmute the owner of the server";
// Check if Nucleus can unmute the member
- if (!(mePos > applyPos)) throw new Error("I do not have a role higher than that member");
+ if (!(mePos > applyPos)) return "I do not have a role higher than that member";
// Check if Nucleus has permission to unmute
- if (!me.permissions.has("ModerateMembers")) throw new Error("I do not have the *Moderate Members* permission");
+ if (!me.permissions.has("ModerateMembers")) return "I do not have the *Moderate Members* permission";
// Allow the owner to unmute anyone
if (member.id === interaction.guild.ownerId) return true;
// Check if the user has moderate_members permission
if (!member.permissions.has("ModerateMembers"))
- throw new Error("You do not have the *Moderate Members* permission");
+ return "You do not have the *Moderate Members* permission";
// Check if the user is below on the role list
- if (!(memberPos > applyPos)) throw new Error("You do not have a role higher than that member");
+ if (!(memberPos > applyPos)) return "You do not have a role higher than that member";
// Allow unmute
return true;
};