Fixed a lot of commands, 0 typing errors on those changed
diff --git a/src/commands/mod/ban.ts b/src/commands/mod/ban.ts
index 5f4f41c..6deb4ad 100644
--- a/src/commands/mod/ban.ts
+++ b/src/commands/mod/ban.ts
@@ -1,10 +1,11 @@
-import { CommandInteraction, GuildMember, ActionRowBuilder, ButtonBuilder, User, ButtonStyle } from "discord.js";
+import Discord, { CommandInteraction, GuildMember, ActionRowBuilder, ButtonBuilder, User, ButtonStyle } from "discord.js";
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 addPlurals from "../../utils/plurals.js";
import client from "../../utils/client.js";
+import { LinkWarningFooter } from "../../utils/defaultEmbeds.js";
const command = (builder: SlashCommandSubcommandBuilder) =>
@@ -12,11 +13,10 @@
.setName("ban")
.setDescription("Bans a user from the server")
.addUserOption((option) => option.setName("user").setDescription("The user to ban").setRequired(true))
- .addStringOption((option) => option.setName("reason").setDescription("The reason for the ban").setRequired(false))
.addNumberOption((option) =>
option
.setName("delete")
- .setDescription("The days of messages to delete | Default: 0")
+ .setDescription("Delete this number of days of messages from the user | Default: 0")
.setMinValue(0)
.setMaxValue(7)
.setRequired(false)
@@ -42,9 +42,8 @@
}) +
`The user **will${notify ? "" : " not"}** be notified\n` +
`${addPlurals(
- (interaction.options.get("delete")?.value as number | null) ?? 0,
- "day"
- )} of messages will be deleted\n\n` +
+ (interaction.options.get("delete")?.value as number | null) ?? 0, "day")
+ } of messages will be deleted\n\n` +
`Are you sure you want to ban <@!${(interaction.options.getMember("user") as GuildMember).id}>?`
)
.addCustomBoolean(
@@ -52,7 +51,7 @@
"Notify user",
false,
undefined,
- null,
+ "The user will be sent a DM",
"ICONS.NOTIFY." + (notify ? "ON" : "OFF"),
notify
)
@@ -68,12 +67,15 @@
if (timedOut) return;
if (confirmation.success) {
reason = reason.length ? reason : null
- let dmd = false;
- let dm;
+ let dmSent = false;
+ let dmMessage;
const config = await client.database.guilds.read(interaction.guild!.id);
try {
if (notify) {
- dm = await (interaction.options.getMember("user") as GuildMember).send({
+ const messageData: {
+ embeds: EmojiEmbed[];
+ components: ActionRowBuilder<ButtonBuilder>[];
+ } = {
embeds: [
new EmojiEmbed()
.setEmoji("PUNISH.BAN.RED")
@@ -83,25 +85,30 @@
)
.setStatus("Danger")
],
- components: config.moderation.ban.text ? [
- new ActionRowBuilder().addComponents([
- new ButtonBuilder()
+ components: []
+ };
+ if (config.moderation.ban.text && config.moderation.ban.link) {
+ messageData.embeds[0]!.setFooter(LinkWarningFooter)
+ messageData.components.push(new ActionRowBuilder<Discord.ButtonBuilder>()
+ .addComponents(new ButtonBuilder()
.setStyle(ButtonStyle.Link)
.setLabel(config.moderation.ban.text)
- .setURL(config.moderation.ban.link!)
- ])
- ] : []
- });
- dmd = true;
+ .setURL(config.moderation.ban.link)
+ )
+ )
+ }
+ dmMessage = await (interaction.options.getMember("user") as GuildMember).send(messageData);
+ dmSent = true;
}
} catch {
- dmd = false;
+ dmSent = false;
}
try {
const member = interaction.options.getMember("user") as GuildMember;
+ const days: number = interaction.options.get("delete")?.value as number | null ?? 0;
member.ban({
- days: Number(interaction.options.getNumber("delete") ?? 0),
- reason: reason ?? "No reason provided"
+ deleteMessageSeconds: days * 24 * 60 * 60,
+ 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;
@@ -117,10 +124,10 @@
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())),
+ banned: entry(new Date().getTime().toString(), 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)),
+ accountCreated: entry(member.user.createdAt.toString(), renderDelta(member.user.createdAt.getTime())),
serverMemberCount: interaction.guild!.memberCount
},
hidden: {
@@ -139,10 +146,10 @@
],
components: []
});
- if (dmd && dm) await dm.delete();
+ if (dmSent && dmMessage) await dmMessage.delete();
return;
}
- const failed = !dmd && notify;
+ const failed = !dmSent && notify;
await interaction.editReply({
embeds: [
new EmojiEmbed()
@@ -169,7 +176,7 @@
const check = async (interaction: CommandInteraction) => {
const member = interaction.member as GuildMember;
- const me = interaction.guild!.me!;
+ const me = interaction.guild!.members.me!;
let apply = interaction.options.getUser("user") as User | GuildMember;
const memberPos = member.roles.cache.size > 1 ? member.roles.highest.position : 0;
const mePos = me.roles.cache.size > 1 ? me.roles.highest.position : 0;
@@ -185,13 +192,13 @@
// Check if Nucleus can ban the member
if (!(mePos > applyPos)) throw new Error("I do not have a role higher than that member");
// Check if Nucleus has permission to ban
- if (!me.permissions.has("BAN_MEMBERS")) throw new Error("I do not have the *Ban Members* permission");
+ if (!me.permissions.has("BanMembers")) throw new Error("I do not have the *Ban Members* permission");
// Do not allow banning Nucleus
- if (member.id === interaction.guild!.me!.id) throw new Error("I cannot ban myself");
+ if (member.id === me.id) throw new Error("I cannot ban myself");
// Allow the owner to ban anyone
if (member.id === interaction.guild!.ownerId) return true;
// Check if the user has ban_members permission
- if (!member.permissions.has("BAN_MEMBERS")) throw new Error("You do not have the *Ban Members* permission");
+ if (!member.permissions.has("BanMembers")) throw new Error("You do not have the *Ban 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");
// Allow ban