optimisations!!!!!

pull/5/head
PineappleFan 4 years ago committed by GitHub
parent 19b002b66d
commit 5fe720dc86
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -127,7 +127,7 @@ const check = (interaction: CommandInteraction, defaultCheck: WrappedCheck) => {
// 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 (! interaction.guild.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 banning Nucleus
if (member.id == interaction.guild.me.id) throw "I cannot ban myself"
// Allow the owner to ban anyone

@ -124,7 +124,7 @@ const check = (interaction: CommandInteraction, defaultCheck: WrappedCheck) => {
// 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
if (! interaction.guild.me.permissions.has("KICK_MEMBERS")) throw "I do not have the `kick_members` permission";
if (! me.permissions.has("KICK_MEMBERS")) throw "I do not have the `kick_members` permission";
// Do not allow kicking Nucleus
if (member.id == interaction.guild.me.id) throw "I cannot kick myself"
// Allow the owner to kick anyone

@ -225,11 +225,11 @@ const check = (interaction: CommandInteraction, defaultCheck: WrappedCheck) => {
// 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 (! interaction.guild.me.permissions.has("MODERATE_MEMBERS")) throw "I do not have the `moderate_members` permission";
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 ((interaction.options.getMember("user") as GuildMember).permissions.has("ADMINISTRATOR") || (interaction.options.getMember("user") as GuildMember).id == interaction.guild.ownerId) throw "You cannot mute an admin or 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 == interaction.guild.me.id) throw "I cannot mute myself"
if (member.id == me.id) throw "I cannot mute myself"
// Allow the owner to mute anyone
if (member.id == interaction.guild.ownerId) return true
// Check if the user has moderate_members permission

@ -120,7 +120,7 @@ const check = (interaction: CommandInteraction, defaultCheck: WrappedCheck) => {
// 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
if (! interaction.guild.me.permissions.has("MANAGE_NICKNAMES")) throw "I do not have the `manage_nicknames` permission";
if (! me.permissions.has("MANAGE_NICKNAMES")) throw "I do not have the `manage_nicknames` permission";
// Allow the owner to change anyone's nickname
if (member.id == interaction.guild.ownerId) return true
// Check if the user has manage_nicknames permission

@ -309,12 +309,13 @@ const callback = async (interaction: CommandInteraction) => {
const check = (interaction: CommandInteraction, defaultCheck: WrappedCheck) => {
let member = (interaction.member as GuildMember)
let me = (interaction.guild.me as GuildMember)
// 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 (! interaction.guild.me.permissions.has("MANAGE_MESSAGES")) throw "I do not have the `manage_messages` permission";
if (! me.permissions.has("MANAGE_MESSAGES")) throw "I do not have the `manage_messages` permission";
// Allow warn
return true
}

@ -59,7 +59,7 @@ const check = (interaction: CommandInteraction, defaultCheck: WrappedCheck) => {
let member = (interaction.member as GuildMember)
let me = (interaction.guild.me as GuildMember)
// Check if Nucleus can edit the channel
if (! interaction.guild.me.permission.has("MANAGE_CHANNELS")) throw "I do not have permission to edit this channel"
if (! me.permission.has("MANAGE_CHANNELS")) throw "I do not have permission to edit this channel"
// Allow the owner to set any channel
if (member.id == interaction.guild.ownerId) return true
// Check if the user has manage_channels permission

@ -98,11 +98,11 @@ const check = (interaction: CommandInteraction, defaultCheck: WrappedCheck) => {
// 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 (! interaction.guild.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 == interaction.guild.me.id) throw "I cannot softban myself"
if (member.id == me.id) throw "I cannot softban myself"
// Allow the owner to ban anyone
if (member.id == interaction.guild.ownerId) return true
if (member.id == 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";
// Check if the user is below on the role list

@ -90,7 +90,7 @@ const check = (interaction: CommandInteraction, defaultCheck: WrappedCheck) => {
let member = (interaction.member as GuildMember)
let me = (interaction.guild.me as GuildMember)
// Check if Nucleus can unban members
if (! interaction.guild.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";
// Allow the owner to unban anyone
if (member.id == interaction.guild.ownerId) return true
// Check if the user has ban_members permission

@ -87,9 +87,9 @@ const check = (interaction: CommandInteraction, defaultCheck: WrappedCheck) => {
// 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 (! interaction.guild.me.permissions.has("MODERATE_MEMBERS")) throw "I do not have the `moderate_members` permission";
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 ((interaction.options.getMember("user") as GuildMember).permissions.has("ADMINISTRATOR") || (interaction.options.getMember("user") as GuildMember).id == interaction.guild.ownerId) throw "You cannot unmute an admin or 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

@ -215,11 +215,11 @@ const check = (interaction: CommandInteraction, defaultCheck: WrappedCheck) => {
// Check if Nucleus can UNNAMED the member
if (! (mePos > applyPos)) throw "I do not have a role higher than that member"
// Check if Nucleus has permission to UNNAMED
if (! interaction.guild.me.permissions.has("MANAGE_ROLES")) throw "I do not have the `manage_roles` permission";
if (! me.permissions.has("MANAGE_ROLES")) throw "I do not have the `manage_roles` permission";
// Do not allow the user to have admin or be the owner
if ((interaction.options.getMember("user") as GuildMember).permissions.has("ADMINISTRATOR") || (interaction.options.getMember("user") as GuildMember).id == interaction.guild.ownerId) throw "You cannot mute an admin or the owner"
if (apply.permissions.has("ADMINISTRATOR") || apply.id == interaction.guild.ownerId) throw "You cannot mute an admin or the owner"
// Do not allow muting Nucleus
if (member.id == interaction.guild.me.id) throw "I cannot UNNAMED myself"
if (member.id == me.id) throw "I cannot UNNAMED myself"
// Allow the owner to UNNAMED anyone
if (member.id == interaction.guild.ownerId) return true
// Check if the user has moderate_members permission

Loading…
Cancel
Save