Advertisement
cheesyy

Untitled

Nov 11th, 2020
95
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.36 KB | None | 0 0
  1. const BaseCommand = require('../../utils/structures/BaseCommand');
  2. const Discord = require('discord.js');
  3.  
  4. module.exports = {
  5. name: 'unlock',
  6. description: 'Unlocks channel mentioned',
  7. async execute(message, args) {
  8. if (!message.member.hasPermission('MANAGE_CHANNELS')) return message.channel.send('You can not use this command.');
  9. if (!args[0]) return message.channel.send('You did not mention any channels.');
  10. if (!message.mentions.channels.first()) return message.channel.send('You did not mention any valid channels.');
  11.  
  12. const role = message.guild.roles.get('768814563067297823')
  13. if (!role) return message.channel.send('Role is not able to be found!');
  14.  
  15. await message.mentions.channels.forEach(async channel => {
  16. if (!channel.name.startsWith('🔐')) return message.channel.send(`<#${channel.id}> is already unlocked!`);
  17. await channel.setName(channel.name.substring(1));
  18. try {
  19. await channel.overwritePermissions(role, {
  20. SEND_MESSAGES: true
  21. })
  22. message.channel.send(`<#${channel.id}> has been unlocked!`);
  23.  
  24. } catch (err) {
  25. console.log(err);
  26. message.channel.send('Something has went wrong unlocking the channels.')
  27. }
  28. });
  29. }
  30. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement