From cd799a8974849cf8125a25005604c3c3dbb27509 Mon Sep 17 00:00:00 2001 From: Braeden Sowinski Date: Fri, 6 May 2022 13:39:38 -0700 Subject: [PATCH] fix undefined exists func --- commands/checkStatus.js | 2 +- commands/debug.js | 6 +++--- commands/setChannel.js | 4 ++-- commands/setRole.js | 4 ++-- structures/LinesPoliceCadBot.js | 3 +-- 5 files changed, 9 insertions(+), 10 deletions(-) diff --git a/commands/checkStatus.js b/commands/checkStatus.js index d4a81e2..4d92812 100644 --- a/commands/checkStatus.js +++ b/commands/checkStatus.js @@ -66,7 +66,7 @@ module.exports = { let user = await client.dbo.collection("users").findOne({"user.discord.id":interaction.member.user.id}).then(user => user); if (!user) return interaction.send(`You are not logged in.`); if (user.user.activeCommunity == null) return interaction.send(`You must join a community to use this command.`); - if (!client.exists(args)) { + if (!client.client.exists(args)) { return interaction.send(`<@${interaction.member.user.id}>'s status: \`${user.user.dispatchStatus}\` | Set by: \`${user.user.dispatchStatusSetBy}\``); } else { let targetUserID = args[0].value.replace('<@!', '').replace('>', ''); diff --git a/commands/debug.js b/commands/debug.js index 52c81da..173cf13 100644 --- a/commands/debug.js +++ b/commands/debug.js @@ -21,10 +21,10 @@ module.exports = { if (!client.config.Admins.includes(message.author.id)) return; if (args.length==0) return message.channel.send('Debug Error: Provide a debug command'); - if (!client.exists(args[0])) return message.channel.send('Debug Error: Provide a valid debug command'); + if (!client.client.exists(args[0])) return message.channel.send('Debug Error: Provide a valid debug command'); let debugConsole = false - if (client.exists(args[1])&&args[1]=='true') debugConsole = true + if (client.client.exists(args[1])&&args[1]=='true') debugConsole = true let command = args[0].toLowerCase(); @@ -91,7 +91,7 @@ module.exports = { if (!client.config.Admins.includes(interaction.member.user.id)) return; if (args.length==0) return message.channel.send('Debug Error: Provide a debug command'); - if (!client.exists(args[0].value)) return interaction.send('Debug Error: Provide a valid debug command'); + if (!client.client.exists(args[0].value)) return interaction.send('Debug Error: Provide a valid debug command'); let debugConsole = args[1].value; diff --git a/commands/setChannel.js b/commands/setChannel.js index 96da365..7a90d89 100644 --- a/commands/setChannel.js +++ b/commands/setChannel.js @@ -24,7 +24,7 @@ module.exports = { if (channel.type=="voice") return message.channel.send(`Connot set voice channel to preferred channel.`); if (channel.deleted) return message.channel.send(`Connot set deleted channel to preferred channel.`); let guild = await client.dbo.collection("prefixes").findOne({"server.serverID":message.guild.id}).then(guild => guild); - if (client.exists(guild.server.allowedChannels)&&guild.server.allowedChannels.includes(channelid)) return message.channel.send(`The channel ${args[0]} has already been added.`); + if (client.client.exists(guild.server.allowedChannels)&&guild.server.allowedChannels.includes(channelid)) return message.channel.send(`The channel ${args[0]} has already been added.`); client.dbo.collection("prefixes").updateOne({"server.serverID":message.guild.id},{$push:{"server.allowedChannels":channelid},$set:{"server.hasCustomChannels":true}},function(err, res) { if (err) throw err; return message.channel.send(`Successfully added ${args[0]} to allowed channels.`); @@ -58,7 +58,7 @@ module.exports = { if (channel.type=="voice") return interaction.send(`Connot set voice channel to preferred channel.`); if (channel.deleted) return interaction.send(`Connot set deleted channel to preferred channel.`); let guild = await client.dbo.collection("prefixes").findOne({"server.serverID":interaction.guild.id}).then(guild => guild); - if (exists(guild.server.allowedChannels)&&guild.server.allowedChannels.includes(channelid)) return interaction.send(`The channel <#${args[0].value}> has already been added.`); + if (client.client.exists(guild.server.allowedChannels)&&guild.server.allowedChannels.includes(channelid)) return interaction.send(`The channel <#${args[0].value}> has already been added.`); client.dbo.collection("prefixes").updateOne({"server.serverID":interaction.guild.id},{$push:{"server.allowedChannels":channelid},$set:{"server.hasCustomChannels":true}},function(err, res) { if (err) throw err; return interaction.send(`Successfully added <#${args[0].value}> to allowed channels.`); diff --git a/commands/setRole.js b/commands/setRole.js index e31fda4..d5b12fe 100644 --- a/commands/setRole.js +++ b/commands/setRole.js @@ -24,7 +24,7 @@ module.exports = { return message.channel.send(`Uh Oh! The role ${args[0]} connot be found.`); } else { let guild = await client.dbo.collection("prefixes").findOne({"server.serverID":message.guild.id}).then(guild => guild); - if (client.exists(guild.server.allowedRoles)&&guild.server.allowedRoles.includes(roleid)) return message.channel.send(`The role ${args[0]} has already been added.`); + if (client.client.exists(guild.server.allowedRoles)&&guild.server.allowedRoles.includes(roleid)) return message.channel.send(`The role ${args[0]} has already been added.`); client.dbo.collection("prefixes").updateOne({"server.serverID":message.guild.id},{$push:{"server.allowedRoles":roleid},$set:{"server.hasCustomRoles":true}},function(err, res) { if (err) throw err; return message.channel.send(`Successfully added ${args[0]} to allowed roles.`); @@ -59,7 +59,7 @@ module.exports = { return interaction.send(`Uh Oh! The role <@&${args[0].value}> connot be found.`); } else { let guild = await client.dbo.collection("prefixes").findOne({"server.serverID":interaction.guild.id}).then(guild => guild); - if (exists(guild.server.allowedRoles)&&guild.server.allowedRoles.includes(roleid)) return interaction.send(`The role <@&${args[0].value}> has already been added.`); + if (client.exists(guild.server.allowedRoles)&&guild.server.allowedRoles.includes(roleid)) return interaction.send(`The role <@&${args[0].value}> has already been added.`); client.dbo.collection("prefixes").updateOne({"server.serverID":interaction.guild.id},{$push:{"server.allowedRoles":roleid},$set:{"server.hasCustomRoles":true}},function(err, res) { if (err) throw err; return interaction.send(`Successfully added <@&${args[0].value}> to allowed roles.`); diff --git a/structures/LinesPoliceCadBot.js b/structures/LinesPoliceCadBot.js index 42a1307..8a3ea55 100644 --- a/structures/LinesPoliceCadBot.js +++ b/structures/LinesPoliceCadBot.js @@ -103,7 +103,7 @@ class LinesPoliceCadBot extends Client { }); } - exists(n){return null!=n&&null!=n&&""!=n} + exists(n) {return null != n && undefined != n && "" != n} LoadCommands() { let CommandsDir = path.join(__dirname, '..', 'commands'); @@ -245,7 +245,6 @@ class LinesPoliceCadBot extends Client { Channel.send(embed); } - build() { this.login(this.config.Token); }