update/add nameSearch and debug control

This commit is contained in:
SowinskiBraeden committed 2022-03-08 19:58:56 -08:00
1 parent 6cbd981a00
commit 68120d1e60
6 files changed
+156 -15

No files matched your search

+8 -3
View File
@@ -75,6 +75,8 @@ class LinesPoliceCadBot extends Client {
this.log('Successfully connected to mongoDB');
}
exists(n){return null!=n&&null!=n&&""!=n}
LoadCommands() {
let CommandsDir = path.join(__dirname, '..', 'commands');
fs.readdir(CommandsDir, (err, files) => {
@@ -121,12 +123,15 @@ class LinesPoliceCadBot extends Client {
});
}
async checkRoleStatus(message) {
async checkRoleStatus(roles, serverID) {
let hasRole = false;
let guild = await this.dbo.collection("prefixes").findOne({"server.serverID":message.guild.id}).then(guild => guild);
let guild = await this.dbo.collection("prefixes").findOne({"server.serverID":serverID}).then(guild => guild);
// If user has one of any in the list of allowed roles, hasRole is true
for (let i = 0; i < guild.server.allowedRoles.length; i++) {
if (message.member.roles.cache.some(role => role.id == guild.server.allowedRoles[i])) hasRole = true;
if (roles.includes(guild.server.allowedRoles[i])) {
hasRole = true
break
}
}
return hasRole;
}