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 // Check if Nucleus can ban the member
if (! (mePos > applyPos)) 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 // 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 // Do not allow banning Nucleus
if (member.id == interaction.guild.me.id) throw "I cannot ban myself" if (member.id == interaction.guild.me.id) throw "I cannot ban myself"
// Allow the owner to ban anyone // Allow the owner to ban anyone

@ -124,7 +124,7 @@ const check = (interaction: CommandInteraction, defaultCheck: WrappedCheck) => {
// Check if Nucleus can kick the member // Check if Nucleus can kick the member
if (! (mePos > applyPos)) 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 kick // 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 // Do not allow kicking Nucleus
if (member.id == interaction.guild.me.id) throw "I cannot kick myself" if (member.id == interaction.guild.me.id) throw "I cannot kick myself"
// Allow the owner to kick anyone // Allow the owner to kick anyone

@ -225,11 +225,11 @@ const check = (interaction: CommandInteraction, defaultCheck: WrappedCheck) => {
// Check if Nucleus can mute the member // Check if Nucleus can mute the member
if (! (mePos > applyPos)) 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 mute // 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 // 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 // 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 // Allow the owner to mute anyone
if (member.id == interaction.guild.ownerId) return true if (member.id == interaction.guild.ownerId) return true
// Check if the user has moderate_members permission // 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 // Check if Nucleus can change the nickname
if (! (mePos > applyPos)) 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 change the nickname // 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 // Allow the owner to change anyone's nickname
if (member.id == interaction.guild.ownerId) return true if (member.id == interaction.guild.ownerId) return true
// Check if the user has manage_nicknames permission // Check if the user has manage_nicknames permission

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

@ -59,7 +59,7 @@ const check = (interaction: CommandInteraction, defaultCheck: WrappedCheck) => {
let member = (interaction.member as GuildMember) let member = (interaction.member as GuildMember)
let me = (interaction.guild.me as GuildMember) let me = (interaction.guild.me as GuildMember)
// Check if Nucleus can edit the channel // 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 // Allow the owner to set any channel
if (member.id == interaction.guild.ownerId) return true if (member.id == interaction.guild.ownerId) return true
// Check if the user has manage_channels permission // 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 // Check if Nucleus can ban the member
if (! (mePos > applyPos)) 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 // 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 // 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 // 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 // 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 // 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 member = (interaction.member as GuildMember)
let me = (interaction.guild.me as GuildMember) let me = (interaction.guild.me as GuildMember)
// Check if Nucleus can unban members // 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 // Allow the owner to unban anyone
if (member.id == interaction.guild.ownerId) return true if (member.id == interaction.guild.ownerId) return true
// Check if the user has ban_members permission // 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 // Check if Nucleus can unmute the member
if (! (mePos > applyPos)) 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 unmute // 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 // 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 // Allow the owner to unmute anyone
if (member.id == interaction.guild.ownerId) return true if (member.id == interaction.guild.ownerId) return true
// Check if the user has moderate_members permission // 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 // Check if Nucleus can UNNAMED the member
if (! (mePos > applyPos)) 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 UNNAMED // 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 // 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 // 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 // Allow the owner to UNNAMED anyone
if (member.id == interaction.guild.ownerId) return true if (member.id == interaction.guild.ownerId) return true
// Check if the user has moderate_members permission // Check if the user has moderate_members permission

Loading…
Cancel
Save