From f6170d1154c51b241bfa46b4bff4ba9a985bf943 Mon Sep 17 00:00:00 2001 From: Abheek Dhawan Date: Mon, 26 Apr 2021 15:16:16 -0500 Subject: [PATCH] Improve role querys --- bot.js | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/bot.js b/bot.js index e58e03b..b324678 100644 --- a/bot.js +++ b/bot.js @@ -376,8 +376,9 @@ async function roleInfo(message) { message.reply("role query must contain at least 3 characters!") return; } - - const roles = message.guild.roles.cache.filter(role => role.name.toLowerCase().includes(message.content.split(" ")[1])); + const queriedRole = message.content.split(" "); + queriedRole.shift(); + const roles = message.guild.roles.cache.filter(role => role.name.toLowerCase().includes(queriedRole.join(" ").toLowerCase())); let roleChannel; if (roles.array().length < 1) { @@ -414,7 +415,11 @@ async function addRole(message) { return; } - const roles = message.guild.roles.cache.filter(role => role.name.toLowerCase().includes(message.content.split(" ")[1])); + const queriedRole = message.content.split(" "); + console.log(queriedRole); + queriedRole.shift(); + const roles = message.guild.roles.cache.filter(role => role.name.toLowerCase().includes(queriedRole[0].toLowerCase())); + console.log(roles); let roleChannel; if (!message.content.split(" ")[2]) { @@ -753,7 +758,9 @@ async function roleRequest(message) { return; } - const roles = message.guild.roles.cache.filter(role => role.name.toLowerCase().includes(message.content.split(" ")[1].toLowerCase())); + const queriedRole = message.content.split(" "); + queriedRole.shift(); + const roles = message.guild.roles.cache.filter(role => role.name.toLowerCase().includes(queriedRole.join(" ").toLowerCase())); let roleChannel; if (roles.array().length < 1) {