Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- const BaseCommand = require('../../utils/structures/BaseCommand');
- const Discord = require('discord.js');
- module.exports = {
- name: 'unlock',
- description: 'Unlocks channel mentioned',
- async execute(message, args) {
- if (!message.member.hasPermission('MANAGE_CHANNELS')) return message.channel.send('You can not use this command.');
- if (!args[0]) return message.channel.send('You did not mention any channels.');
- if (!message.mentions.channels.first()) return message.channel.send('You did not mention any valid channels.');
- const role = message.guild.roles.get('768814563067297823')
- if (!role) return message.channel.send('Role is not able to be found!');
- await message.mentions.channels.forEach(async channel => {
- if (!channel.name.startsWith('🔐')) return message.channel.send(`<#${channel.id}> is already unlocked!`);
- await channel.setName(channel.name.substring(1));
- try {
- await channel.overwritePermissions(role, {
- SEND_MESSAGES: true
- })
- message.channel.send(`<#${channel.id}> has been unlocked!`);
- } catch (err) {
- console.log(err);
- message.channel.send('Something has went wrong unlocking the channels.')
- }
- });
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement