-
Notifications
You must be signed in to change notification settings - Fork 10
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[New] Added a new perms command to check users roles and your own!
- Loading branch information
Showing
1 changed file
with
59 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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!` | ||
), | ||
], | ||
}); | ||
} | ||
}, | ||
}; |