Skip to content

Commit

Permalink
[New] Added a new perms command to check users roles and your own!
Browse files Browse the repository at this point in the history
  • Loading branch information
naseif committed Aug 30, 2021
1 parent 23aa73f commit 33cc673
Showing 1 changed file with 59 additions and 0 deletions.
59 changes: 59 additions & 0 deletions commands/misc/perms.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
const { SlashCommandBuilder } = require("@discordjs/builders");
const { embedMessage } = require("../../modules/embedSimple");

module.exports = {
data: new SlashCommandBuilder()
.setName("perms")
.setDescription("Shows the permission for another member or your own")
.addUserOption((option) =>
option.setName("user").setDescription("Select a user")
),
async execute(interaction, client) {
const user = interaction.options.getMember("user");
await interaction.deferReply();

let userRoles;

if (user) {
userRoles = await user.roles.cache.map((role) => {
if (role.name !== "@everyone") return `<@&${role.id}>`;
});
} else {
userRoles = await interaction.member.roles.cache.map((role) => {
if (role.name !== "@everyone") return `<@&${role.id}>`;
});
}

const permsEmbed = {
color: "#9dcc37",
title: `Roles list for ${
user ? user.user.username : interaction.user.username
}`,
author: {
name: `${interaction.user.username}`,
icon_url: `${interaction.user.avatarURL()}`,
},
description: `${userRoles.join("\n")}`,

timestamp: new Date(),
footer: {
text: "Created by naseif",
icon_url: "https://i.imgur.com/KrAvM8U.jpg",
},
};
try {
await interaction.followUp({
embeds: [permsEmbed],
});
} catch (err) {
await interaction.followUp({
embeds: [
embedMessage(
"#9dcc37",
`❌ | Ups! Looks like I do not have permission to list the roles or something else went wrong!`
),
],
});
}
},
};

0 comments on commit 33cc673

Please sign in to comment.