Tarna256

lock/unlock command

Oct 15th, 2020 (edited)
116
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. // lockdown command
  2. if (message.member.roles.cache.some(role => role.name === 'staff')) {
  3.     const textChannels = message.guild.channels.cache.filter(c => c.type == 'text');
  4.     const voiceChannels = message.guild.channels.cache.filter(c => c.type == 'voice');
  5.     const verified = message.guild.roles.cache.find(role => role.name === 'Verified');
  6.     textChannels.forEach(channel => {
  7.         channel.overwritePermissions([
  8.             {
  9.                 id: verified,
  10.                 deny: ['SEND_MESSAGES'],
  11.             }
  12.         ]);
  13.     })
  14.     voiceChannels.forEach(channel => {
  15.         channel.overwritePermissions([
  16.             {
  17.                 id: verified,
  18.                 deny: ['SPEAK']
  19.             }
  20.         ])
  21.     })
  22.     message.channel.send('Discord is now on lockdown!');
  23. }
  24.  
  25. //unlock command
  26. if (message.member.roles.cache.some(role => role.name === 'staff')) {
  27.     const textChannels = message.guild.channels.cache.filter(c => c.type == 'text');
  28.     const voiceChannels = message.guild.channels.cache.filter(c => c.type == 'voice');
  29.     const verified = message.guild.roles.cache.find(role => role.name === 'Verified');
  30.     textChannels.forEach(channel => {
  31.         channel.overwritePermissions([
  32.             {
  33.                 id: verified,
  34.                 allow: ['SEND_MESSAGES'],
  35.             }
  36.         ]);
  37.     })
  38.     voiceChannels.forEach(channel => {
  39.         channel.overwritePermissions([
  40.             {
  41.                 id: verified,
  42.                 allow: ['SPEAK']
  43.             }
  44.         ])
  45.     })
  46.  
  47.     message.channel.send('Discord has now been unlocked');
  48. }
Add Comment
Please, Sign In to add comment