Fix the last of the eslint errors (for real this time)
diff --git a/src/commands/mod/ban.ts b/src/commands/mod/ban.ts
index 4f2d4d7..9a82970 100644
--- a/src/commands/mod/ban.ts
+++ b/src/commands/mod/ban.ts
@@ -26,7 +26,9 @@
let reason = null;
let notify = true;
let confirmation;
- while (true) {
+ let cancelled = false;
+ let timedOut = false;
+ while (!timedOut && !cancelled) {
confirmation = await new confirmationMessage(interaction)
.setEmoji("PUNISH.BAN.RED")
.setTitle("Ban")
@@ -46,114 +48,101 @@
.addReasonButton(reason ?? "")
.send(reason !== null);
reason = reason ?? "";
- if (confirmation.cancelled) return;
- if (confirmation.success) break;
- if (confirmation.newReason) reason = confirmation.newReason;
- if (confirmation.components) notify = confirmation.components.notify.active;
+ if (confirmation.cancelled) timedOut = true;
+ else if (confirmation.success) cancelled = true;
+ else if (confirmation.newReason) reason = confirmation.newReason;
+ else if (confirmation.components) notify = confirmation.components.notify.active;
}
- if (confirmation.success) {
- let dmd = false;
- let dm;
- const config = await client.database.guilds.read(interaction.guild.id);
- try {
- if (notify) {
- dm = await (interaction.options.getMember("user") as GuildMember).send({
- embeds: [
- new EmojiEmbed()
- .setEmoji("PUNISH.BAN.RED")
- .setTitle("Banned")
- .setDescription(
- `You have been banned in ${interaction.guild.name}` +
- (reason ? ` for:\n> ${reason}` : ".")
- )
- .setStatus("Danger")
- ],
- components: [
- new MessageActionRow().addComponents(
- config.moderation.ban.text
- ? [
- new MessageButton()
- .setStyle("LINK")
- .setLabel(config.moderation.ban.text)
- .setURL(config.moderation.ban.link)
- ]
- : []
- )
- ]
- });
- dmd = true;
- }
- } catch {
- dmd = false;
- }
- try {
- const member = interaction.options.getMember("user") as GuildMember;
- member.ban({
- days: Number(interaction.options.getNumber("delete") ?? 0),
- reason: reason ?? "No reason provided"
- });
- await client.database.history.create("ban", interaction.guild.id, member.user, interaction.user, reason);
- const { log, NucleusColors, entry, renderUser, renderDelta } = client.logger;
- const data = {
- meta: {
- type: "memberBan",
- displayName: "Member Banned",
- calculateType: "guildMemberPunish",
- color: NucleusColors.red,
- emoji: "PUNISH.BAN.RED",
- timestamp: new Date().getTime()
- },
- list: {
- memberId: entry(member.user.id, `\`${member.user.id}\``),
- name: entry(member.user.id, renderUser(member.user)),
- banned: entry(new Date().getTime(), renderDelta(new Date().getTime())),
- bannedBy: entry(interaction.user.id, renderUser(interaction.user)),
- reason: entry(reason, reason ? `\n> ${reason}` : "*No reason provided.*"),
- accountCreated: entry(member.user.createdAt, renderDelta(member.user.createdAt)),
- serverMemberCount: interaction.guild.memberCount
- },
- hidden: {
- guild: interaction.guild.id
- }
- };
- log(data);
- } catch {
- await interaction.editReply({
+ if (timedOut) return;
+ let dmd = false;
+ let dm;
+ const config = await client.database.guilds.read(interaction.guild.id);
+ try {
+ if (notify) {
+ dm = await (interaction.options.getMember("user") as GuildMember).send({
embeds: [
new EmojiEmbed()
.setEmoji("PUNISH.BAN.RED")
- .setTitle("Ban")
- .setDescription("Something went wrong and the user was not banned")
+ .setTitle("Banned")
+ .setDescription(
+ `You have been banned in ${interaction.guild.name}` + (reason ? ` for:\n> ${reason}` : ".")
+ )
.setStatus("Danger")
],
- components: []
+ components: [
+ new MessageActionRow().addComponents(
+ config.moderation.ban.text
+ ? [
+ new MessageButton()
+ .setStyle("LINK")
+ .setLabel(config.moderation.ban.text)
+ .setURL(config.moderation.ban.link)
+ ]
+ : []
+ )
+ ]
});
- if (dmd) await dm.delete();
- return;
+ dmd = true;
}
- const failed = !dmd && notify;
- await interaction.editReply({
- embeds: [
- new EmojiEmbed()
- .setEmoji(`PUNISH.BAN.${failed ? "YELLOW" : "GREEN"}`)
- .setTitle("Ban")
- .setDescription("The member was banned" + (failed ? ", but could not be notified" : ""))
- .setStatus(failed ? "Warning" : "Success")
- ],
- components: []
- });
- } else {
- await interaction.editReply({
- embeds: [
- new EmojiEmbed()
- .setEmoji("PUNISH.BAN.GREEN")
- .setTitle("Ban")
- .setDescription("No changes were made")
- .setStatus("Success")
- ],
- components: []
- });
+ } catch {
+ dmd = false;
}
+ try {
+ const member = interaction.options.getMember("user") as GuildMember;
+ member.ban({
+ days: Number(interaction.options.getNumber("delete") ?? 0),
+ reason: reason ?? "No reason provided"
+ });
+ await client.database.history.create("ban", interaction.guild.id, member.user, interaction.user, reason);
+ const { log, NucleusColors, entry, renderUser, renderDelta } = client.logger;
+ const data = {
+ meta: {
+ type: "memberBan",
+ displayName: "Member Banned",
+ calculateType: "guildMemberPunish",
+ color: NucleusColors.red,
+ emoji: "PUNISH.BAN.RED",
+ timestamp: new Date().getTime()
+ },
+ list: {
+ memberId: entry(member.user.id, `\`${member.user.id}\``),
+ name: entry(member.user.id, renderUser(member.user)),
+ banned: entry(new Date().getTime(), renderDelta(new Date().getTime())),
+ bannedBy: entry(interaction.user.id, renderUser(interaction.user)),
+ reason: entry(reason, reason ? `\n> ${reason}` : "*No reason provided.*"),
+ accountCreated: entry(member.user.createdAt, renderDelta(member.user.createdAt)),
+ serverMemberCount: interaction.guild.memberCount
+ },
+ hidden: {
+ guild: interaction.guild.id
+ }
+ };
+ log(data);
+ } catch {
+ await interaction.editReply({
+ embeds: [
+ new EmojiEmbed()
+ .setEmoji("PUNISH.BAN.RED")
+ .setTitle("Ban")
+ .setDescription("Something went wrong and the user was not banned")
+ .setStatus("Danger")
+ ],
+ components: []
+ });
+ if (dmd) await dm.delete();
+ return;
+ }
+ const failed = !dmd && notify;
+ await interaction.editReply({
+ embeds: [
+ new EmojiEmbed()
+ .setEmoji(`PUNISH.BAN.${failed ? "YELLOW" : "GREEN"}`)
+ .setTitle("Ban")
+ .setDescription("The member was banned" + (failed ? ", but could not be notified" : ""))
+ .setStatus(failed ? "Warning" : "Success")
+ ],
+ components: []
+ });
};
const check = (interaction: CommandInteraction) => {