2022-07-12 20:10:35 +03:00
const { checkRole } = require ( './verify.js' ) ;
2022-09-27 16:45:50 -04:00
const { Constants } = require ( 'discord.js' ) ;
2022-07-12 20:10:35 +03:00
module . exports = {
name : 'lock' ,
description : 'Lock a channel' ,
2022-09-27 16:45:50 -04:00
execute ( interaction , Discord , Client , bot ) {
const arg = interaction . options . data [ 0 ] ;
const guild = bot . guilds . cache . get ( interaction . guildId ) ;
2022-07-12 20:10:35 +03:00
2022-10-23 18:23:11 -04:00
checkRole ( bot , guild , interaction . user . id ) . then ( ( isAllowed ) => {
if ( isAllowed ) { return interaction . reply ( 'Insufficient Permissions!' ) ; }
2022-07-12 20:10:35 +03:00
2022-10-23 18:23:11 -04:00
var channel ;
if ( arg ) {
channel = arg . channel ;
} else {
channel = interaction . channel ;
}
2022-07-12 20:10:35 +03:00
2022-10-23 18:23:11 -04:00
let role = interaction . guild . roles . cache . find ( r => r . name === "@everyone" ) ;
channel . permissionOverwrites . edit ( role . id , {
VIEW _CHANNEL : true ,
SEND _MESSAGES : false ,
READ _MESSAGE _HISTORY : true ,
ATTACH _FILES : false
} ) ;
2022-09-27 16:45:50 -04:00
2022-10-23 18:23:11 -04:00
interaction . reply ( ` ${ channel } has been locked! ` ) ;
} ) ;
2022-09-27 16:45:50 -04:00
} ,
options : [ { name : 'channel' , description : 'The channel to lock (defaults to current channel)' , type : Constants . ApplicationCommandOptionTypes . CHANNEL , required : false } ]
2022-07-12 20:10:35 +03:00
}