From ef72b589215dcec7a6b41644061ff42e1d88cdc7 Mon Sep 17 00:00:00 2001 From: Braeden Sowinski Date: Wed, 5 Oct 2022 20:21:37 -0700 Subject: [PATCH] add missing data check --- commands/channels.js | 2 +- commands/removeRole.js | 2 +- commands/roles.js | 4 ++-- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/commands/channels.js b/commands/channels.js index 6db6951..da39d90 100644 --- a/commands/channels.js +++ b/commands/channels.js @@ -23,7 +23,7 @@ module.exports = { } let guild = await client.dbo.collection("prefixes").findOne({"server.serverID":interaction.guild.id}).then(guild => guild); - if (guild.server.hasCustomChannels==false) { + if (client.exists(guild.server.hasCustomChannels) || !guild.server.hasCustomChannels) { return interaction.send({ content: 'There are no channels set for the bot.' }); } diff --git a/commands/removeRole.js b/commands/removeRole.js index 9342be8..c4717a1 100644 --- a/commands/removeRole.js +++ b/commands/removeRole.js @@ -36,7 +36,7 @@ module.exports = { return interaction.send({ content: `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 (guild.server.hasCustomRoles==false) return interaction.send({ content: `There are no roles to be removed.` }); + if (!client.exists(guild.server.hasCustomRoles) || !guild.server.hasCustomRoles) return interaction.send({ content: `There are no roles to be removed.` }); if (!guild.server.allowedRoles.includes(roleid)) return interaction.send({ content: `The role <@&${args[0].value}> is not added to your roles.` }); for (let i = 0; i < guild.server.allowedRoles.length; i++) { if (guild.server.allowedRoles[i]==roleid) { diff --git a/commands/roles.js b/commands/roles.js index 389b2a5..790a67c 100644 --- a/commands/roles.js +++ b/commands/roles.js @@ -21,9 +21,9 @@ module.exports = { if (GuildDB.customChannelStatus==true&&!GuildDB.allowedChannels.includes(interaction.channel_id)) { return interaction.send({ content: `You are not allowed to use the bot in this channel.` }); } - + let guild = await client.dbo.collection("prefixes").findOne({"server.serverID":interaction.guild.id}).then(guild => guild); - if (guild.server.hasCustomRoles==false) { + if (!client.exists(guild.server.hasCustomRoles) || !guild.server.hasCustomRoles) { return interaction.send({ content: 'There are no roles set for the bot.' }); }