Fix a bunch of linter errors
diff --git a/src/commands/mod/softban.ts b/src/commands/mod/softban.ts
index d0dc9bb..f3c475e 100644
--- a/src/commands/mod/softban.ts
+++ b/src/commands/mod/softban.ts
@@ -1,4 +1,9 @@
-import { CommandInteraction, GuildMember, MessageActionRow, MessageButton } from "discord.js";
+import {
+ CommandInteraction,
+ GuildMember,
+ MessageActionRow,
+ MessageButton
+} from "discord.js";
import { SlashCommandSubcommandBuilder } from "@discordjs/builders";
import confirmationMessage from "../../utils/confirmationMessage.js";
import EmojiEmbed from "../../utils/generateEmojiEmbed.js";
@@ -10,10 +15,24 @@
builder
.setName("softban")
.setDescription("Kicks a user and deletes their messages")
- .addUserOption(option => option.setName("user").setDescription("The user to softban").setRequired(true))
- .addIntegerOption(option => option.setName("delete").setDescription("The days of messages to delete | Default: 0").setMinValue(0).setMaxValue(7).setRequired(false));
+ .addUserOption((option) =>
+ option
+ .setName("user")
+ .setDescription("The user to softban")
+ .setRequired(true)
+ )
+ .addIntegerOption((option) =>
+ option
+ .setName("delete")
+ .setDescription("The days of messages to delete | Default: 0")
+ .setMinValue(0)
+ .setMaxValue(7)
+ .setRequired(false)
+ );
-const callback = async (interaction: CommandInteraction): Promise<void | unknown> => {
+const callback = async (
+ interaction: CommandInteraction
+): Promise<void | unknown> => {
const { renderUser } = client.logger;
// TODO:[Modals] Replace this with a modal
let reason = null;
@@ -23,15 +42,35 @@
const confirmation = await new confirmationMessage(interaction)
.setEmoji("PUNISH.BAN.RED")
.setTitle("Softban")
- .setDescription(keyValueList({
- "user": renderUser(interaction.options.getUser("user")),
- "reason": reason ? ("\n> " + ((reason ?? "").replaceAll("\n", "\n> "))) : "*No reason provided*"
- })
- + `The user **will${notify ? "" : " not"}** be notified\n`
- + `${addPlural(interaction.options.getInteger("delete") ? interaction.options.getInteger("delete") : 0, "day")} of messages will be deleted\n\n`
- + `Are you sure you want to softban <@!${(interaction.options.getMember("user") as GuildMember).id}>?`)
+ .setDescription(
+ keyValueList({
+ user: renderUser(interaction.options.getUser("user")),
+ reason: reason
+ ? "\n> " + (reason ?? "").replaceAll("\n", "\n> ")
+ : "*No reason provided*"
+ }) +
+ `The user **will${notify ? "" : " not"}** be notified\n` +
+ `${addPlural(
+ interaction.options.getInteger("delete")
+ ? interaction.options.getInteger("delete")
+ : 0,
+ "day"
+ )} of messages will be deleted\n\n` +
+ `Are you sure you want to softban <@!${
+ (interaction.options.getMember("user") as GuildMember)
+ .id
+ }>?`
+ )
.setColor("Danger")
- .addCustomBoolean("notify", "Notify user", false, null, null, "ICONS.NOTIFY." + (notify ? "ON" : "OFF" ), notify)
+ .addCustomBoolean(
+ "notify",
+ "Notify user",
+ false,
+ null,
+ null,
+ "ICONS.NOTIFY." + (notify ? "ON" : "OFF"),
+ notify
+ )
.addReasonButton(reason ?? "")
.send(reason !== null);
reason = reason ?? "";
@@ -47,24 +86,38 @@
const config = await client.database.guilds.read(interaction.guild.id);
try {
if (notify) {
- await (interaction.options.getMember("user") as GuildMember).send({
- embeds: [new EmojiEmbed()
- .setEmoji("PUNISH.BAN.RED")
- .setTitle("Softbanned")
- .setDescription(`You have been softbanned from ${interaction.guild.name}` +
- (reason ? ` for:\n> ${reason}` : "."))
- .setStatus("Danger")
+ await (
+ interaction.options.getMember("user") as GuildMember
+ ).send({
+ embeds: [
+ new EmojiEmbed()
+ .setEmoji("PUNISH.BAN.RED")
+ .setTitle("Softbanned")
+ .setDescription(
+ `You have been softbanned from ${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)
- ] : [])]
+ 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;}
- const member = (interaction.options.getMember("user") as GuildMember);
+ } catch {
+ dmd = false;
+ }
+ const member = interaction.options.getMember("user") as GuildMember;
try {
await member.ban({
days: Number(interaction.options.getInteger("delete") ?? 0),
@@ -72,55 +125,83 @@
});
await interaction.guild.members.unban(member, "Softban");
} catch {
- await interaction.editReply({embeds: [new EmojiEmbed()
- .setEmoji("PUNISH.BAN.RED")
- .setTitle("Softban")
- .setDescription("Something went wrong and the user was not softbanned")
- .setStatus("Danger")
- ], components: []});
+ await interaction.editReply({
+ embeds: [
+ new EmojiEmbed()
+ .setEmoji("PUNISH.BAN.RED")
+ .setTitle("Softban")
+ .setDescription(
+ "Something went wrong and the user was not softbanned"
+ )
+ .setStatus("Danger")
+ ],
+ components: []
+ });
}
- await client.database.history.create("softban", interaction.guild.id, member.user, reason);
- const failed = (dmd === false && notify);
- await interaction.editReply({embeds: [new EmojiEmbed()
- .setEmoji(`PUNISH.BAN.${failed ? "YELLOW" : "GREEN"}`)
- .setTitle("Softban")
- .setDescription("The member was softbanned" + (failed ? ", but could not be notified" : ""))
- .setStatus(failed ? "Warning" : "Success")
- ], components: []});
+ await client.database.history.create(
+ "softban",
+ interaction.guild.id,
+ member.user,
+ reason
+ );
+ const failed = !dmd && notify;
+ await interaction.editReply({
+ embeds: [
+ new EmojiEmbed()
+ .setEmoji(`PUNISH.BAN.${failed ? "YELLOW" : "GREEN"}`)
+ .setTitle("Softban")
+ .setDescription(
+ "The member was softbanned" +
+ (failed ? ", but could not be notified" : "")
+ )
+ .setStatus(failed ? "Warning" : "Success")
+ ],
+ components: []
+ });
} else {
- await interaction.editReply({embeds: [new EmojiEmbed()
- .setEmoji("PUNISH.BAN.GREEN")
- .setTitle("Softban")
- .setDescription("No changes were made")
- .setStatus("Success")
- ], components: []});
+ await interaction.editReply({
+ embeds: [
+ new EmojiEmbed()
+ .setEmoji("PUNISH.BAN.GREEN")
+ .setTitle("Softban")
+ .setDescription("No changes were made")
+ .setStatus("Success")
+ ],
+ components: []
+ });
}
};
const check = (interaction: CommandInteraction) => {
- const member = (interaction.member as GuildMember);
- const me = (interaction.guild.me as GuildMember);
- const apply = (interaction.options.getMember("user") as GuildMember);
- if (member === null || me === null || apply === null) throw "That member is not in the server";
+ const member = interaction.member as GuildMember;
+ const me = interaction.guild.me!;
+ const apply = interaction.options.getMember("user") as GuildMember;
+ if (member === null || me === null || apply === null)
+ throw "That member is not in the server";
const memberPos = member.roles ? member.roles.highest.position : 0;
const mePos = me.roles ? me.roles.highest.position : 0;
const applyPos = apply.roles ? apply.roles.highest.position : 0;
// Do not allow softbanning the owner
- if (member.id === interaction.guild.ownerId) throw "You cannot softban the owner of the server";
+ if (member.id === interaction.guild.ownerId)
+ throw "You cannot softban the owner of the server";
// Check if Nucleus can ban the member
- if (! (mePos > applyPos)) throw "I do not have a role higher than that member";
+ if (!(mePos > applyPos))
+ throw "I do not have a role higher than that member";
// Check if Nucleus has permission to ban
- if (!me.permissions.has("BAN_MEMBERS")) throw "I do not have the *Ban Members* permission";
+ if (!me.permissions.has("BAN_MEMBERS"))
+ throw "I do not have the *Ban Members* permission";
// Do not allow softbanning Nucleus
if (member.id === me.id) throw "I cannot softban myself";
// Allow the owner to softban anyone
if (member.id === interaction.guild.ownerId) return true;
// Check if the user has ban_members permission
- if (! member.permissions.has("BAN_MEMBERS")) throw "You do not have the *Ban Members* permission";
+ if (!member.permissions.has("BAN_MEMBERS"))
+ throw "You do not have the *Ban Members* permission";
// Check if the user is below on the role list
- if (! (memberPos > applyPos)) throw "You do not have a role higher than that member";
+ if (!(memberPos > applyPos))
+ throw "You do not have a role higher than that member";
// Allow softban
return true;
};
-export { command, callback, check };
\ No newline at end of file
+export { command, callback, check };