Browse Source

Add primitive userInfo command

master
Abheek Dhawan 4 years ago
parent
commit
bb55b55504
  1. 37
      index.js

37
index.js

@ -108,9 +108,46 @@ client.on("message", async message => {
kick(message); kick(message);
} else if (message.content.toLowerCase().startsWith(`${prefix}addrole`)) { } else if (message.content.toLowerCase().startsWith(`${prefix}addrole`)) {
addRole(message); addRole(message);
} else if (message.content.toLowerCase().startsWith(`${prefix}userinfo`)) {
userInfo(message);
} }
}); });
async function userInfo(message) {
if (!message.content.split(" ")[1]) {
message.reply("query must contain at least 3 characters!")
return;
}
if (message.content.split(" ")[1].length < 3) {
message.reply("query must contain at least 3 characters!")
return;
}
const members = message.guild.members.cache.filter(member => {
if (member.nickname) {
return member.user.username.toLowerCase().includes(message.content.split(" ")[1].toLowerCase()) || member.nickname.toLowerCase().includes(message.content.split(" ")[1].toLowerCase());
} else {
return member.user.username.toLowerCase().includes(message.content.split(" ")[1].toLowerCase())
}
});
if (members.array().length < 1) {
message.reply("no members found with that name!");
return;
}
const member = members.array()[0];
const userInfoEmbed = new Discord.MessageEmbed()
.setAuthor(member.user.tag, member.user.avatarURL())
.addField("Roles", member.roles.map(r => `${r}`).join(' • '))
.setColor("00c5ff")
.setFooter("User ID: ", member.user.id)
.setTimestamp();
message.channel.send(userInfoEmbed);
}
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