huge changes once again
diff --git a/src/commands/mod/softban.ts b/src/commands/mod/softban.ts
index 5a01287..ea4a447 100644
--- a/src/commands/mod/softban.ts
+++ b/src/commands/mod/softban.ts
@@ -2,7 +2,7 @@
import { SlashCommandSubcommandBuilder } from "@discordjs/builders";
import { WrappedCheck } from "jshaiku";
import confirmationMessage from "../../utils/confirmationMessage.js";
-import generateEmojiEmbed from "../../utils/generateEmojiEmbed.js";
+import EmojiEmbed from "../../utils/generateEmojiEmbed.js";
import keyValueList from "../../utils/generateKeyValueList.js";
import client from "../../utils/client.js";
import addPlural from "../../utils/plurals.js";
@@ -18,13 +18,14 @@
)
.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) => {
+const callback = async (interaction: CommandInteraction): Promise<any> => {
+ const { renderUser } = client.logger
// TODO:[Modals] Replace this with a modal
let confirmation = await new confirmationMessage(interaction)
.setEmoji("PUNISH.BAN.RED")
.setTitle("Softban")
.setDescription(keyValueList({
- "user": `<@!${(interaction.options.getMember("user") as GuildMember).id}> (${(interaction.options.getMember("user") as GuildMember).user.username})`,
+ "user": renderUser(interaction.options.getUser("user")),
"reason": `\n> ${interaction.options.getString("reason") ? interaction.options.getString("reason") : "*No reason provided*"}`
})
+ `The user **will${interaction.options.getString("notify") === "no" ? ' not' : ''}** be notified\n`
@@ -34,11 +35,11 @@
.send()
if (confirmation.success) {
let dmd = false;
- let config = await client.database.read(interaction.guild.id);
+ let config = await client.database.guilds.read(interaction.guild.id);
try {
if (interaction.options.getString("notify") != "no") {
await (interaction.options.getMember("user") as GuildMember).send({
- embeds: [new generateEmojiEmbed()
+ embeds: [new EmojiEmbed()
.setEmoji("PUNISH.BAN.RED")
.setTitle("Softbanned")
.setDescription(`You have been softbanned from ${interaction.guild.name}` +
@@ -54,29 +55,31 @@
dmd = true
}
} catch {}
+ let member = (interaction.options.getMember("user") as GuildMember)
try {
- await (interaction.options.getMember("user") as GuildMember).ban({
+ await member.ban({
days: Number(interaction.options.getInteger("delete") ?? 0),
reason: interaction.options.getString("reason")
});
- await interaction.guild.members.unban(interaction.options.getMember("user") as GuildMember, "Softban");
+ await interaction.guild.members.unban(member, "Softban");
} catch {
- await interaction.editReply({embeds: [new generateEmojiEmbed()
+ 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: []})
}
+ try { await client.database.history.create("softban", interaction.guild.id, member.user, interaction.options.getString("reason")) } catch {}
let failed = (dmd == false && interaction.options.getString("notify") != "no")
- await interaction.editReply({embeds: [new generateEmojiEmbed()
+ 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 generateEmojiEmbed()
+ await interaction.editReply({embeds: [new EmojiEmbed()
.setEmoji("PUNISH.BAN.GREEN")
.setTitle(`Softban`)
.setDescription("No changes were made")
@@ -96,13 +99,13 @@
// Check if Nucleus can ban the 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 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 "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"
// Allow softban