@@ -4,10 +4,13 @@ const {
44 ActionRowBuilder,
55 ButtonBuilder,
66 ButtonStyle,
7+ MessageFlags,
78} = require ( "discord.js" ) ;
89const si = require ( "systeminformation" ) ;
910
1011const ALLOWED_USER_ID = "123456789012345678" ; // REPLACE WITH YOUR USER ID
12+ const ALLOWED_ROLE_ID = "1392088061424439348" ; // REPLACE WITH YOUR ROLE ID
13+
1114
1215function getUniqueProcessesByName ( processList ) {
1316 const map = new Map ( ) ;
@@ -62,10 +65,15 @@ module.exports = {
6265 . setDescription ( "📊 Displays a list of unique processes like `htop`." ) ,
6366
6467 async execute ( interaction ) {
65- if ( interaction . user . id !== ALLOWED_USER_ID ) {
68+ const isAllowedUser = interaction . user . id === ALLOWED_USER_ID ;
69+ const hasAllowedRole =
70+ interaction . inGuild ( ) &&
71+ Boolean ( interaction . member ?. roles ?. cache ?. has ( ALLOWED_ROLE_ID ) ) ;
72+
73+ if ( ! isAllowedUser && ! hasAllowedRole ) {
6674 return interaction . reply ( {
6775 content : "❌ You do not have permission to use this command." ,
68- ephemeral : true ,
76+ flags : MessageFlags . Ephemeral ,
6977 } ) ;
7078 }
7179
@@ -117,9 +125,9 @@ module.exports = {
117125 await message . edit ( { components : [ disabledRow ] } ) ;
118126 } ) ;
119127 } catch ( err ) {
120- console . error ( "Błąd komendy /htop:" , err ) ;
128+ console . error ( "Error in /htop command :" , err ) ;
121129 await interaction . editReply (
122- "❌ Wystąpił błąd podczas pobierania procesów ."
130+ "❌ An error occurred while fetching processes ."
123131 ) ;
124132 }
125133 } ,
0 commit comments