Fix a bunch of linter errors
diff --git a/src/commands/mod/warn.ts b/src/commands/mod/warn.ts
index 34ad3c3..91c876e 100644
--- a/src/commands/mod/warn.ts
+++ b/src/commands/mod/warn.ts
@@ -1,18 +1,33 @@
-import Discord, { CommandInteraction, GuildMember, MessageActionRow, MessageButton } from "discord.js";
+import Discord, {
+ CommandInteraction,
+ GuildMember,
+ MessageActionRow,
+ MessageButton
+} from "discord.js";
import { SlashCommandSubcommandBuilder } from "@discordjs/builders";
import confirmationMessage from "../../utils/confirmationMessage.js";
import EmojiEmbed from "../../utils/generateEmojiEmbed.js";
import keyValueList from "../../utils/generateKeyValueList.js";
-import { create, areTicketsEnabled } from "../../actions/createModActionTicket.js";
+import {
+ create,
+ areTicketsEnabled
+} from "../../actions/createModActionTicket.js";
import client from "../../utils/client.js";
const command = (builder: SlashCommandSubcommandBuilder) =>
builder
.setName("warn")
.setDescription("Warns a user")
- .addUserOption(option => option.setName("user").setDescription("The user to warn").setRequired(true));
+ .addUserOption((option) =>
+ option
+ .setName("user")
+ .setDescription("The user to warn")
+ .setRequired(true)
+ );
-const callback = async (interaction: CommandInteraction): Promise<void | unknown> => {
+const callback = async (
+ interaction: CommandInteraction
+): Promise<void | unknown> => {
const { log, NucleusColors, renderUser, entry } = client.logger;
// TODO:[Modals] Replace this with a modal
let reason = null;
@@ -23,18 +38,44 @@
confirmation = await new confirmationMessage(interaction)
.setEmoji("PUNISH.WARN.RED")
.setTitle("Warn")
- .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\n`
- + `Are you sure you want to warn <@!${(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\n` +
+ `Are you sure you want to warn <@!${
+ (interaction.options.getMember("user") as GuildMember)
+ .id
+ }>?`
+ )
.setColor("Danger")
.addCustomBoolean(
- "appeal", "Create appeal ticket", !(await areTicketsEnabled(interaction.guild.id)),
- async () => await create(interaction.guild, interaction.options.getUser("user"), interaction.user, reason),
- "An appeal ticket will be created when Confirm is clicked", "CONTROL.TICKET", createAppealTicket)
- .addCustomBoolean("notify", "Notify user", false, null, null, "ICONS.NOTIFY." + (notify ? "ON" : "OFF" ), notify)
+ "appeal",
+ "Create appeal ticket",
+ !(await areTicketsEnabled(interaction.guild.id)),
+ async () =>
+ await create(
+ interaction.guild,
+ interaction.options.getUser("user"),
+ interaction.user,
+ reason
+ ),
+ "An appeal ticket will be created when Confirm is clicked",
+ "CONTROL.TICKET",
+ createAppealTicket
+ )
+ .addCustomBoolean(
+ "notify",
+ "Notify user",
+ false,
+ null,
+ null,
+ "ICONS.NOTIFY." + (notify ? "ON" : "OFF"),
+ notify
+ )
.addReasonButton(reason ?? "")
.send(reason !== null);
reason = reason ?? "";
@@ -50,31 +91,51 @@
let dmd = false;
try {
if (notify) {
- const config = await client.database.guilds.read(interaction.guild.id);
- await (interaction.options.getMember("user") as GuildMember).send({
- embeds: [new EmojiEmbed()
- .setEmoji("PUNISH.WARN.RED")
- .setTitle("Warned")
- .setDescription(`You have been warned in ${interaction.guild.name}` +
- (reason ? ` for:\n> ${reason}` : ".") + "\n\n" +
- (confirmation.components.appeal.response ? `You can appeal this here ticket: <#${confirmation.components.appeal.response}>` : ""))
- .setStatus("Danger")
- .setFooter({
- text: config.moderation.warn.text ? "The button below is set by the server admins. Do not enter any passwords or other account details on the linked site." : "",
- iconURL: "https://cdn.discordapp.com/emojis/952295894370369587.webp?size=128&quality=lossless"
- })
+ const config = await client.database.guilds.read(
+ interaction.guild.id
+ );
+ await (
+ interaction.options.getMember("user") as GuildMember
+ ).send({
+ embeds: [
+ new EmojiEmbed()
+ .setEmoji("PUNISH.WARN.RED")
+ .setTitle("Warned")
+ .setDescription(
+ `You have been warned in ${interaction.guild.name}` +
+ (reason ? ` for:\n> ${reason}` : ".") +
+ "\n\n" +
+ (confirmation.components.appeal.response
+ ? `You can appeal this here ticket: <#${confirmation.components.appeal.response}>`
+ : "")
+ )
+ .setStatus("Danger")
+ .setFooter({
+ text: config.moderation.warn.text
+ ? "The button below is set by the server admins. Do not enter any passwords or other account details on the linked site."
+ : "",
+ iconURL:
+ "https://cdn.discordapp.com/emojis/952295894370369587.webp?size=128&quality=lossless"
+ })
],
- components: config.moderation.warn.text ? [new MessageActionRow().addComponents([new MessageButton()
- .setStyle("LINK")
- .setLabel(config.moderation.warn.text)
- .setURL(config.moderation.warn.link)
- ])] : []
+ components: config.moderation.warn.text
+ ? [
+ new MessageActionRow().addComponents([
+ new MessageButton()
+ .setStyle("LINK")
+ .setLabel(config.moderation.warn.text)
+ .setURL(config.moderation.warn.link)
+ ])
+ ]
+ : []
});
dmd = true;
}
- } catch { dmd = false; }
+ } catch {
+ dmd = false;
+ }
const data = {
- meta:{
+ meta: {
type: "memberWarn",
displayName: "Member warned",
calculateType: "guildMemberPunish",
@@ -83,8 +144,18 @@
timestamp: new Date().getTime()
},
list: {
- user: entry((interaction.options.getMember("user") as GuildMember).user.id, renderUser((interaction.options.getMember("user") as GuildMember).user)),
- warnedBy: entry(interaction.member.user.id, renderUser(interaction.member.user)),
+ user: entry(
+ (interaction.options.getMember("user") as GuildMember).user
+ .id,
+ renderUser(
+ (interaction.options.getMember("user") as GuildMember)
+ .user
+ )
+ ),
+ warnedBy: entry(
+ interaction.member.user.id,
+ renderUser(interaction.member.user)
+ ),
reason: reason ? `\n> ${reason}` : "No reason provided"
},
hidden: {
@@ -92,28 +163,47 @@
}
};
await client.database.history.create(
- "warn", interaction.guild.id,
+ "warn",
+ interaction.guild.id,
(interaction.options.getMember("user") as GuildMember).user,
- interaction.user, reason
+ interaction.user,
+ reason
);
log(data);
- const failed = (dmd === false && notify);
+ const failed = !dmd && notify;
if (!failed) {
- await interaction.editReply({embeds: [new EmojiEmbed()
- .setEmoji("PUNISH.WARN.GREEN")
- .setTitle("Warn")
- .setDescription("The user was warned" + (confirmation.components.appeal.response ? ` and an appeal ticket was opened in <#${confirmation.components.appeal.response}>` : ""))
- .setStatus("Success")
- ], components: []});
+ await interaction.editReply({
+ embeds: [
+ new EmojiEmbed()
+ .setEmoji("PUNISH.WARN.GREEN")
+ .setTitle("Warn")
+ .setDescription(
+ "The user was warned" +
+ (confirmation.components.appeal.response
+ ? ` and an appeal ticket was opened in <#${confirmation.components.appeal.response}>`
+ : "")
+ )
+ .setStatus("Success")
+ ],
+ components: []
+ });
} else {
- const canSeeChannel = (interaction.options.getMember("user") as GuildMember).permissionsIn(interaction.channel as Discord.TextChannel).has("VIEW_CHANNEL");
- const m = await interaction.editReply({
- embeds: [new EmojiEmbed()
- .setEmoji("PUNISH.WARN.RED")
- .setTitle("Warn")
- .setDescription("The user's DMs are not open\n\nWhat would you like to do?")
- .setStatus("Danger")
- ], components: [
+ const canSeeChannel = (
+ interaction.options.getMember("user") as GuildMember
+ )
+ .permissionsIn(interaction.channel as Discord.TextChannel)
+ .has("VIEW_CHANNEL");
+ const m = (await interaction.editReply({
+ embeds: [
+ new EmojiEmbed()
+ .setEmoji("PUNISH.WARN.RED")
+ .setTitle("Warn")
+ .setDescription(
+ "The user's DMs are not open\n\nWhat would you like to do?"
+ )
+ .setStatus("Danger")
+ ],
+ components: [
new MessageActionRow().addComponents([
new Discord.MessageButton()
.setCustomId("log")
@@ -130,76 +220,131 @@
.setStyle(canSeeChannel ? "SECONDARY" : "PRIMARY")
])
]
- }) as Discord.Message;
+ })) as Discord.Message;
let component;
try {
- component = await m.awaitMessageComponent({filter: (m) => m.user.id === interaction.user.id, time: 300000});
+ component = await m.awaitMessageComponent({
+ filter: (m) => m.user.id === interaction.user.id,
+ time: 300000
+ });
} catch (e) {
- return await interaction.editReply({embeds: [new EmojiEmbed()
+ return await interaction.editReply({
+ embeds: [
+ new EmojiEmbed()
+ .setEmoji("PUNISH.WARN.GREEN")
+ .setTitle("Warn")
+ .setDescription("No changes were made")
+ .setStatus("Success")
+ ],
+ components: []
+ });
+ }
+ if (component.customId === "here") {
+ await interaction.channel.send({
+ embeds: [
+ new EmojiEmbed()
+ .setEmoji("PUNISH.WARN.RED")
+ .setTitle("Warn")
+ .setDescription(
+ "You have been warned" +
+ (reason ? ` for:\n> ${reason}` : ".")
+ )
+ .setStatus("Danger")
+ ],
+ content: `<@!${
+ (interaction.options.getMember("user") as GuildMember)
+ .id
+ }>`,
+ allowedMentions: {
+ users: [
+ (
+ interaction.options.getMember(
+ "user"
+ ) as GuildMember
+ ).id
+ ]
+ }
+ });
+ return await interaction.editReply({
+ embeds: [
+ new EmojiEmbed()
+ .setEmoji("PUNISH.WARN.GREEN")
+ .setTitle("Warn")
+ .setDescription(
+ "The user was warned" +
+ (confirmation.response
+ ? ` and an appeal ticket was opened in <#${confirmation.response}>`
+ : "")
+ )
+ .setStatus("Success")
+ ],
+ components: []
+ });
+ } else if (component.customId === "log") {
+ await interaction.editReply({
+ embeds: [
+ new EmojiEmbed()
+ .setEmoji("PUNISH.WARN.GREEN")
+ .setTitle("Warn")
+ .setDescription("The warn was logged")
+ .setStatus("Success")
+ ],
+ components: []
+ });
+ } else if (component.customId === "ticket") {
+ const ticketChannel = await create(
+ interaction.guild,
+ interaction.options.getUser("user"),
+ interaction.user,
+ reason,
+ "Warn Notification"
+ );
+ if (ticketChannel === null) {
+ return await interaction.editReply({
+ embeds: [
+ new EmojiEmbed()
+ .setEmoji("PUNISH.WARN.RED")
+ .setTitle("Warn")
+ .setDescription("A ticket could not be created")
+ .setStatus("Danger")
+ ],
+ components: []
+ });
+ }
+ await interaction.editReply({
+ embeds: [
+ new EmojiEmbed()
+ .setEmoji("PUNISH.WARN.GREEN")
+ .setTitle("Warn")
+ .setDescription(
+ `A ticket was created in <#${ticketChannel}>`
+ )
+ .setStatus("Success")
+ ],
+ components: []
+ });
+ }
+ }
+ } else {
+ await interaction.editReply({
+ embeds: [
+ new EmojiEmbed()
.setEmoji("PUNISH.WARN.GREEN")
.setTitle("Warn")
.setDescription("No changes were made")
.setStatus("Success")
- ], components: []});
- }
- if ( component.customId === "here" ) {
- await interaction.channel.send({
- embeds: [new EmojiEmbed()
- .setEmoji("PUNISH.WARN.RED")
- .setTitle("Warn")
- .setDescription("You have been warned" +
- (reason ? ` for:\n> ${reason}` : "."))
- .setStatus("Danger")
- ],
- content: `<@!${(interaction.options.getMember("user") as GuildMember).id}>`,
- allowedMentions: {users: [(interaction.options.getMember("user") as GuildMember).id]}
- });
- return await interaction.editReply({embeds: [new EmojiEmbed()
- .setEmoji("PUNISH.WARN.GREEN")
- .setTitle("Warn")
- .setDescription("The user was warned" + (confirmation.response ? ` and an appeal ticket was opened in <#${confirmation.response}>` : ""))
- .setStatus("Success")
- ], components: []});
- } else if (component.customId === "log") {
- await interaction.editReply({embeds: [new EmojiEmbed()
- .setEmoji("PUNISH.WARN.GREEN")
- .setTitle("Warn")
- .setDescription("The warn was logged")
- .setStatus("Success")
- ], components: []});
- } else if (component.customId === "ticket") {
- const ticketChannel = await create(interaction.guild, interaction.options.getUser("user"), interaction.user, reason, "Warn Notification");
- if (ticketChannel === null) {
- return await interaction.editReply({embeds: [new EmojiEmbed()
- .setEmoji("PUNISH.WARN.RED")
- .setTitle("Warn")
- .setDescription("A ticket could not be created")
- .setStatus("Danger")
- ], components: []});
- }
- await interaction.editReply({embeds: [new EmojiEmbed()
- .setEmoji("PUNISH.WARN.GREEN")
- .setTitle("Warn")
- .setDescription(`A ticket was created in <#${ticketChannel}>`)
- .setStatus("Success")
- ], components: []});
- }
- }
- } else {
- await interaction.editReply({embeds: [new EmojiEmbed()
- .setEmoji("PUNISH.WARN.GREEN")
- .setTitle("Warn")
- .setDescription("No changes were made")
- .setStatus("Success")
- ], components: []});
+ ],
+ 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 applyPos = apply.roles ? apply.roles.highest.position : 0;
// Do not allow warning bots
@@ -207,11 +352,13 @@
// Allow the owner to warn anyone
if (member.id === interaction.guild.ownerId) return true;
// Check if the user has moderate_members permission
- if (! member.permissions.has("MODERATE_MEMBERS")) throw "You do not have the *Moderate Members* permission";
+ if (!member.permissions.has("MODERATE_MEMBERS"))
+ throw "You do not have the *Moderate 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 warn
return true;
};
-export { command, callback, check };
\ No newline at end of file
+export { command, callback, check };