Browse Source

Improve role querys

master
Abheek Dhawan 4 years ago
parent
commit
f6170d1154
  1. 15
      bot.js

15
bot.js

@ -376,8 +376,9 @@ async function roleInfo(message) {
message.reply("role query must contain at least 3 characters!") message.reply("role query must contain at least 3 characters!")
return; return;
} }
const queriedRole = message.content.split(" ");
const roles = message.guild.roles.cache.filter(role => role.name.toLowerCase().includes(message.content.split(" ")[1])); queriedRole.shift();
const roles = message.guild.roles.cache.filter(role => role.name.toLowerCase().includes(queriedRole.join(" ").toLowerCase()));
let roleChannel; let roleChannel;
if (roles.array().length < 1) { if (roles.array().length < 1) {
@ -414,7 +415,11 @@ async function addRole(message) {
return; 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; let roleChannel;
if (!message.content.split(" ")[2]) { if (!message.content.split(" ")[2]) {
@ -753,7 +758,9 @@ async function roleRequest(message) {
return; 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; let roleChannel;
if (roles.array().length < 1) { if (roles.array().length < 1) {

Loading…
Cancel
Save