diff --git a/bot.js b/bot.js index 4cafffa..6a87424 100644 --- a/bot.js +++ b/bot.js @@ -87,6 +87,8 @@ client.on("message", async message => { userInfo(message); } else if (message.content.toLowerCase().startsWith(`${prefix}aboutbot`)) { aboutBot(message); + } else if (message.content.toLowerCase().startsWith(`${prefix}roleinfo`)) { + roleInfo(message); } }); @@ -333,6 +335,47 @@ async function userInfo(message) { message.channel.send(userInfoEmbed).catch(console.error); } +async function roleInfo(message) { + if (!message.content.split(" ")[1]) { + message.reply("role query must contain at least 3 characters!") + return; + } + + if (message.content.split(" ")[1].length < 3) { + 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])); + let roleChannel; + + if (!message.content.split(" ")[2]) { + message.reply("user query must contain at least 3 characters!") + return; + } + + if (message.content.split(" ")[2].length < 3) { + message.reply("user query must contain at least 3 characters!") + return; + } + + if (roles.array().length < 1) { + message.reply("no roles found with that name!"); + return; + } + + const role = roles.array()[0]; + + const roleCreateEmbed = new Discord.MessageEmbed() + .setTitle(`Role \`${role.name}\` Info`) + .setAuthor(message.author.tag, message.author.avatarURL()) + .addField("Permissions", role.permissions.toArray().map(p => `\`${p}\``.toLowerCase()).join(' • ')) + .addField("Mentionable", role.mentionable) + .setFooter("Role ID: " + role.id) + .setTimestamp() + .setColor('00aaff'); +} + async function addRole(message) { if (!message.member.hasPermission('ADMINISTRATOR')) { message.reply("you do not have adequate permissions!")