Changed a bunch of perms, shouldn't have any issues now
diff --git a/src/commands/mod/ban.ts b/src/commands/mod/ban.ts
index 5da8693..8fc98d2 100644
--- a/src/commands/mod/ban.ts
+++ b/src/commands/mod/ban.ts
@@ -129,6 +129,8 @@
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
+ // Do not allow banning the owner
+ if (member.id === interaction.guild.ownerId) throw "You cannot ban the owner of the server"
// 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
diff --git a/src/commands/mod/kick.ts b/src/commands/mod/kick.ts
index a0b9a97..ef748e8 100644
--- a/src/commands/mod/kick.ts
+++ b/src/commands/mod/kick.ts
@@ -128,6 +128,8 @@
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
+ // Do not allow kicking the owner
+ if (member.id === interaction.guild.ownerId) throw "You cannot kick the owner of the server"
// Check if Nucleus can kick the member
if (! (mePos > applyPos)) throw "I do not have a role higher than that member"
// Check if Nucleus has permission to kick
diff --git a/src/commands/mod/mute.ts b/src/commands/mod/mute.ts
index 8bb6854..808d22d 100644
--- a/src/commands/mod/mute.ts
+++ b/src/commands/mod/mute.ts
@@ -252,12 +252,12 @@
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
+ // Do not allow muting the owner
+ if (member.id === interaction.guild.ownerId) throw "You cannot mute the owner of the server"
// Check if Nucleus can mute the member
if (! (mePos > applyPos)) throw "I do not have a role higher than that member"
// Check if Nucleus has permission to mute
if (! me.permissions.has("MODERATE_MEMBERS")) throw "I do not have the *Moderate Members* permission";
- // Do not allow the user to have admin or be the owner
- if (apply.permissions.has("ADMINISTRATOR") || (interaction.options.getMember("user") as GuildMember).id === interaction.guild.ownerId) throw "You cannot mute an admin or the owner"
// Do not allow muting Nucleus
if (member.id === me.id) throw "I cannot mute myself"
// Allow the owner to mute anyone
diff --git a/src/commands/mod/nick.ts b/src/commands/mod/nick.ts
index cf33109..d50becd 100644
--- a/src/commands/mod/nick.ts
+++ b/src/commands/mod/nick.ts
@@ -121,6 +121,8 @@
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
+ // Do not allow any changing of the owner
+ if (member.id === interaction.guild.ownerId) throw "You cannot change the owner's nickname"
// Check if Nucleus can change the nickname
if (! (mePos > applyPos)) throw "I do not have a role higher than that member"
// Check if Nucleus has permission to change the nickname
diff --git a/src/commands/mod/purge.ts b/src/commands/mod/purge.ts
index e1e4de9..521d8a7 100644
--- a/src/commands/mod/purge.ts
+++ b/src/commands/mod/purge.ts
@@ -313,13 +313,13 @@
const check = (interaction: CommandInteraction, defaultCheck: WrappedCheck) => {
let member = (interaction.member as GuildMember)
let me = (interaction.guild.me as GuildMember)
+ // Check if nucleus has the manage_messages permission
+ if (! me.permissions.has("MANAGE_MESSAGES")) throw "I do not have the *Manage Messages* permission";
// Allow the owner to purge
if (member.id === interaction.guild.ownerId) return true
// Check if the user has manage_messages permission
if (! member.permissions.has("MANAGE_MESSAGES")) throw "You do not have the *Manage Messages* permission";
- // Check if nucleus has the manage_messages permission
- if (! me.permissions.has("MANAGE_MESSAGES")) throw "I do not have the *Manage Messages* permission";
- // Allow warn
+ // Allow purge
return true
}
diff --git a/src/commands/mod/softban.ts b/src/commands/mod/softban.ts
index 5c7e8c4..43d03fd 100644
--- a/src/commands/mod/softban.ts
+++ b/src/commands/mod/softban.ts
@@ -106,13 +106,15 @@
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
+ // Do not allow softbanning the owner
+ if (member.id === interaction.guild.ownerId) throw "You cannot softban the owner of the server"
// 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";
// Do not allow softbanning Nucleus
if (member.id === me.id) throw "I cannot softban myself"
- // Allow the owner to ban anyone
+ // Allow the owner to softban 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";
diff --git a/src/commands/mod/unmute.ts b/src/commands/mod/unmute.ts
index 25aacfa..6451837 100644
--- a/src/commands/mod/unmute.ts
+++ b/src/commands/mod/unmute.ts
@@ -114,12 +114,12 @@
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
+ // Do not allow unmuting the owner
+ if (member.id === interaction.guild.ownerId) throw "You cannot unmute the owner of the server"
// Check if Nucleus can unmute the member
if (! (mePos > applyPos)) throw "I do not have a role higher than that member"
// Check if Nucleus has permission to unmute
if (! me.permissions.has("MODERATE_MEMBERS")) throw "I do not have the *Moderate Members* permission";
- // Do not allow the user to have admin or be the owner
- if (apply.permissions.has("ADMINISTRATOR") || apply.id === interaction.guild.ownerId) throw "You cannot unmute an admin or the owner"
// Allow the owner to unmute anyone
if (member.id === interaction.guild.ownerId) return true
// Check if the user has moderate_members permission
diff --git a/src/commands/mod/warn.ts b/src/commands/mod/warn.ts
index 5a42911..b007b29 100644
--- a/src/commands/mod/warn.ts
+++ b/src/commands/mod/warn.ts
@@ -107,6 +107,7 @@
.setStatus("Success")
], components: []})
} else {
+ let canSeeChannel = (interaction.options.getMember("user") as GuildMember).permissionsIn(interaction.channel as Discord.TextChannel).has("VIEW_CHANNEL")
let m = await interaction.editReply({
embeds: [new EmojiEmbed()
.setEmoji(`PUNISH.WARN.RED`)
@@ -122,8 +123,12 @@
new Discord.MessageButton()
.setCustomId("here")
.setLabel("Warn here")
- .setStyle("SECONDARY")
- .setDisabled((interaction.options.getMember("user") as GuildMember).permissionsIn(interaction.channel as Discord.TextChannel).has("VIEW_CHANNEL") === false),
+ .setStyle(canSeeChannel ? "PRIMARY" : "SECONDARY")
+ .setDisabled(!canSeeChannel),
+ new Discord.MessageButton()
+ .setCustomId("ticket")
+ .setLabel("Create ticket")
+ .setStyle(canSeeChannel ? "SECONDARY" : "PRIMARY")
])
]
})
@@ -156,13 +161,29 @@
.setDescription("The user was warned" + (confirmation.response ? ` and an appeal ticket was opened in <#${confirmation.response}>` : ``))
.setStatus("Success")
], components: []})
- } else {
+ } 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") {
+ let 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 {