Browse Source

Add roleInfo command

master
Abheek Dhawan 4 years ago
parent
commit
55f5e0bf3b
  1. 43
      bot.js

43
bot.js

@ -87,6 +87,8 @@ client.on("message", async message => {
userInfo(message); userInfo(message);
} else if (message.content.toLowerCase().startsWith(`${prefix}aboutbot`)) { } else if (message.content.toLowerCase().startsWith(`${prefix}aboutbot`)) {
aboutBot(message); 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); 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) { async function addRole(message) {
if (!message.member.hasPermission('ADMINISTRATOR')) { if (!message.member.hasPermission('ADMINISTRATOR')) {
message.reply("you do not have adequate permissions!") message.reply("you do not have adequate permissions!")

Loading…
Cancel
Save