Fixed a lot of commands, 0 typing errors on those changed
diff --git a/src/commands/mod/warn.ts b/src/commands/mod/warn.ts
index 2fc5a06..5125587 100644
--- a/src/commands/mod/warn.ts
+++ b/src/commands/mod/warn.ts
@@ -1,10 +1,11 @@
import Discord, { CommandInteraction, GuildMember, ActionRowBuilder, ButtonBuilder, ButtonStyle } from "discord.js";
-import { SlashCommandSubcommandBuilder } from "@discordjs/builders";
+import type { 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 client from "../../utils/client.js";
+import { LinkWarningFooter } from "../../utils/defaultEmbeds.js";
const command = (builder: SlashCommandSubcommandBuilder) =>
builder
@@ -15,7 +16,7 @@
const callback = async (interaction: CommandInteraction): Promise<unknown> => {
const { log, NucleusColors, renderUser, entry } = client.logger;
// TODO:[Modals] Replace this with a modal
- let reason = null;
+ let reason: string | null = null;
let notify = true;
let createAppealTicket = false;
let confirmation;
@@ -27,20 +28,18 @@
.setTitle("Warn")
.setDescription(
keyValueList({
- user: renderUser(interaction.options.getUser("user")),
+ 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",
+ !(await areTicketsEnabled(interaction.guild!.id)),
+ async () => await create(interaction.guild!, interaction.options.getUser("user")!, interaction.user, reason),
+ "An appeal ticket will be created",
"CONTROL.TICKET",
createAppealTicket
)
@@ -49,7 +48,7 @@
"Notify user",
false,
null,
- null,
+ "The user will be sent a DM",
"ICONS.NOTIFY." + (notify ? "ON" : "OFF"),
notify
)
@@ -60,53 +59,51 @@
else if (confirmation.success !== undefined) success = true;
else if (confirmation.newReason) reason = confirmation.newReason;
else if (confirmation.components) {
- notify = confirmation.components.notify.active;
- createAppealTicket = confirmation.components.appeal.active;
+ notify = confirmation.components["notify"]!.active;
+ createAppealTicket = confirmation.components["appeal"]!.active;
}
} while (!timedOut && !success)
if (timedOut) return;
if (confirmation.success) {
- let dmd = false;
+ let dmSent = false;
+ const config = await client.database.guilds.read(interaction.guild!.id);
try {
if (notify) {
- const config = await client.database.guilds.read(interaction.guild.id);
- await (interaction.options.getMember("user") as GuildMember).send({
+ const messageData: {
+ embeds: EmojiEmbed[];
+ components: ActionRowBuilder<ButtonBuilder>[];
+ } = {
embeds: [
new EmojiEmbed()
.setEmoji("PUNISH.WARN.RED")
.setTitle("Warned")
.setDescription(
- `You have been warned in ${interaction.guild.name}` +
- (reason ? ` for:\n> ${reason}` : ".") +
+ `You have been warned in ${interaction.guild!.name}` +
+ (reason ? ` for:\n> ${reason}` : ".\n*No reason was provided*") +
"\n\n" +
- (confirmation.components.appeal.response
- ? `You can appeal this here ticket: <#${confirmation.components.appeal.response}>`
+ (createAppealTicket
+ ? `You can appeal this in the ticket created in <#${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 ActionRowBuilder().addComponents([
- new ButtonBuilder()
- .setStyle(ButtonStyle.Link)
- .setLabel(config.moderation.warn.text)
- .setURL(config.moderation.warn.link)
- ])
- ]
- : []
- });
- dmd = true;
+ components: []
+ };
+ if (config.moderation.warn.text && config.moderation.warn.link) {
+ messageData.embeds[0]!.setFooter(LinkWarningFooter)
+ messageData.components.push(new ActionRowBuilder<Discord.ButtonBuilder>()
+ .addComponents(new ButtonBuilder()
+ .setStyle(ButtonStyle.Link)
+ .setLabel(config.moderation.warn.text)
+ .setURL(config.moderation.warn.link)
+ )
+ )
+ }
+ await (interaction.options.getMember("user") as GuildMember).send(messageData);
+ dmSent = true;
}
- } catch {
- dmd = false;
+ } catch (e) {
+ dmSent = false;
}
const data = {
meta: {
@@ -122,22 +119,22 @@
(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"
+ warnedBy: entry(interaction.member!.user.id, renderUser(interaction.member!.user as Discord.User)),
+ reason: reason ? `\n> ${reason}` : "*No reason provided*"
},
hidden: {
- guild: interaction.guild.id
+ guild: interaction.guild!.id
}
};
await client.database.history.create(
"warn",
- interaction.guild.id,
+ interaction.guild!.id,
(interaction.options.getMember("user") as GuildMember).user,
interaction.user,
reason
);
log(data);
- const failed = !dmd && notify;
+ const failed = !dmSent && notify;
if (!failed) {
await interaction.editReply({
embeds: [
@@ -146,8 +143,8 @@
.setTitle("Warn")
.setDescription(
"The user was warned" +
- (confirmation.components.appeal.response
- ? ` and an appeal ticket was opened in <#${confirmation.components.appeal.response}>`
+ (createAppealTicket
+ ? ` and an appeal ticket was opened in <#${confirmation.components!["appeal"]!.response}>`
: "")
)
.setStatus("Success")
@@ -157,7 +154,7 @@
} else {
const canSeeChannel = (interaction.options.getMember("user") as GuildMember)
.permissionsIn(interaction.channel as Discord.TextChannel)
- .has("VIEW_CHANNEL");
+ .has("ViewChannel");
const m = (await interaction.editReply({
embeds: [
new EmojiEmbed()
@@ -167,7 +164,7 @@
.setStatus("Danger")
],
components: [
- new ActionRowBuilder().addComponents([
+ new ActionRowBuilder<Discord.ButtonBuilder>().addComponents(
new Discord.ButtonBuilder().setCustomId("log").setLabel("Ignore and log").setStyle(ButtonStyle.Secondary),
new Discord.ButtonBuilder()
.setCustomId("here")
@@ -178,7 +175,8 @@
.setCustomId("ticket")
.setLabel("Create ticket")
.setStyle(canSeeChannel ? ButtonStyle.Primary : ButtonStyle.Secondary)
- ])
+ .setDisabled(createAppealTicket)
+ )
]
})) as Discord.Message;
let component;
@@ -200,7 +198,7 @@
});
}
if (component.customId === "here") {
- await interaction.channel.send({
+ await interaction.channel!.send({
embeds: [
new EmojiEmbed()
.setEmoji("PUNISH.WARN.RED")
@@ -220,8 +218,8 @@
.setTitle("Warn")
.setDescription(
"The user was warned" +
- (confirmation.response
- ? ` and an appeal ticket was opened in <#${confirmation.response}>`
+ (createAppealTicket
+ ? ` and an appeal ticket was opened in <#${confirmation.components!["appeal"]!.response}>`
: "")
)
.setStatus("Success")
@@ -241,8 +239,8 @@
});
} else if (component.customId === "ticket") {
const ticketChannel = await create(
- interaction.guild,
- interaction.options.getUser("user"),
+ interaction.guild!,
+ interaction.options.getUser("user")!,
interaction.user,
reason,
"Warn Notification"
@@ -296,7 +294,7 @@
// 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"))
+ if (!member.permissions.has("ModerateMembers"))
throw new Error("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");