purge work and general fixes
diff --git a/src/commands/mod/softban.ts b/src/commands/mod/softban.ts
index 6da3a68..bcebbd5 100644
--- a/src/commands/mod/softban.ts
+++ b/src/commands/mod/softban.ts
@@ -38,8 +38,8 @@
await (interaction.options.getMember("user") as GuildMember).send({
embeds: [new EmojiEmbed()
.setEmoji("PUNISH.BAN.RED")
- .setTitle("Kick")
- .setDescription(`You have been kicked from ${interaction.guild.name}` +
+ .setTitle("Softbanned")
+ .setDescription(`You have been softbanned from ${interaction.guild.name}` +
(interaction.options.getString("reason") ? ` for:\n> ${interaction.options.getString("reason")}` : " with no reason provided."))
.setStatus("Danger")
]
@@ -48,17 +48,11 @@
}
} catch {}
try {
- (interaction.options.getMember("user") as GuildMember).ban({
+ await (interaction.options.getMember("user") as GuildMember).ban({
days: Number(interaction.options.getInteger("delete") ?? 0),
reason: interaction.options.getString("reason")
- }) // TODO: unban here
- let failed = (dmd == false && interaction.options.getString("notify") != "no")
- 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 interaction.guild.members.unban(interaction.options.getMember("user") as GuildMember, "Softban");
} catch {
await interaction.editReply({embeds: [new EmojiEmbed()
.setEmoji("PUNISH.BAN.RED")
@@ -67,6 +61,13 @@
.setStatus("Danger")
], components: []})
}
+ let failed = (dmd == false && interaction.options.getString("notify") != "no")
+ 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")
@@ -78,8 +79,15 @@
}
const check = (interaction: CommandInteraction, defaultCheck: WrappedCheck) => {
+ let member = (interaction.member as GuildMember)
+ let me = (interaction.guild.me as GuildMember)
+ let apply = (interaction.options.getMember("user") as GuildMember)
+ if (member == null || me == null || apply == null) throw "That member is not in the server"
+ let memberPos = member.roles ? member.roles.highest.position : 0
+ let mePos = me.roles ? me.roles.highest.position : 0
+ let applyPos = apply.roles ? apply.roles.highest.position : 0
// Check if Nucleus can ban the member
- if (! (interaction.guild.me.roles.highest.position > (interaction.member as GuildMember).roles.highest.position)) 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 (! interaction.guild.me.permissions.has("BAN_MEMBERS")) throw "I do not have the `ban_members` permission";
// Do not allow softbanning Nucleus
@@ -89,7 +97,7 @@
// Check if the user has ban_members permission
if (! (interaction.member as GuildMember).permissions.has("BAN_MEMBERS")) throw "You do not have the `ban_members` permission";
// Check if the user is below on the role list
- if (! ((interaction.member as GuildMember).roles.highest.position > (interaction.options.getMember("user") as GuildMember).roles.highest.position)) 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
}