fix undefined exists func

This commit is contained in:
SowinskiBraeden committed 2022-05-06 13:39:38 -07:00
1 parent c41849eb51
commit cd799a8974
5 files changed
+9 -10

No files matched your search

+1 -1
View File
@@ -66,7 +66,7 @@ module.exports = {
let user = await client.dbo.collection("users").findOne({"user.discord.id":interaction.member.user.id}).then(user => user); 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) 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 (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}\``); return interaction.send(`<@${interaction.member.user.id}>'s status: \`${user.user.dispatchStatus}\` | Set by: \`${user.user.dispatchStatusSetBy}\``);
} else { } else {
let targetUserID = args[0].value.replace('<@!', '').replace('>', ''); let targetUserID = args[0].value.replace('<@!', '').replace('>', '');
+3 -3
View File
@@ -21,10 +21,10 @@ module.exports = {
if (!client.config.Admins.includes(message.author.id)) return; if (!client.config.Admins.includes(message.author.id)) return;
if (args.length==0) return message.channel.send('Debug Error: Provide a debug command'); 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 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(); let command = args[0].toLowerCase();
@@ -91,7 +91,7 @@ module.exports = {
if (!client.config.Admins.includes(interaction.member.user.id)) return; 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 (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; let debugConsole = args[1].value;
+2 -2
View File
@@ -24,7 +24,7 @@ module.exports = {
if (channel.type=="voice") return message.channel.send(`Connot set voice channel to preferred channel.`); 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.`); 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); 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) { 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; if (err) throw err;
return message.channel.send(`Successfully added ${args[0]} to allowed channels.`); 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.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.`); 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); 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) { 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; if (err) throw err;
return interaction.send(`Successfully added <#${args[0].value}> to allowed channels.`); return interaction.send(`Successfully added <#${args[0].value}> to allowed channels.`);
+2 -2
View File
@@ -24,7 +24,7 @@ module.exports = {
return message.channel.send(`Uh Oh! The role ${args[0]} connot be found.`); return message.channel.send(`Uh Oh! The role ${args[0]} connot be found.`);
} else { } else {
let guild = await client.dbo.collection("prefixes").findOne({"server.serverID":message.guild.id}).then(guild => guild); 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) { 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; if (err) throw err;
return message.channel.send(`Successfully added ${args[0]} to allowed roles.`); 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.`); return interaction.send(`Uh Oh! The role <@&${args[0].value}> connot be found.`);
} else { } else {
let guild = await client.dbo.collection("prefixes").findOne({"server.serverID":interaction.guild.id}).then(guild => guild); 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) { 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; if (err) throw err;
return interaction.send(`Successfully added <@&${args[0].value}> to allowed roles.`); return interaction.send(`Successfully added <@&${args[0].value}> to allowed roles.`);
+1 -2
View File
@@ -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() { LoadCommands() {
let CommandsDir = path.join(__dirname, '..', 'commands'); let CommandsDir = path.join(__dirname, '..', 'commands');
@@ -245,7 +245,6 @@ class LinesPoliceCadBot extends Client {
Channel.send(embed); Channel.send(embed);
} }
build() { build() {
this.login(this.config.Token); this.login(this.config.Token);
} }