Advertisement
3MoSteve

Timed lock

Jun 30th, 2020
292
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.18 KB | None | 0 0
  1. const ms = require ('ms'); //ازا موجود هيك سطر بملف بوتك ف احذف هل سطر
  2. client.on('message', async (message) => {
  3. if (!message.guild) return;
  4. if (message.author.bot) return;
  5. if (message.content.startsWith('#lock')) {
  6. if (!message.member.hasPermission ('MANAGE_CHANNELS')) return;
  7. var channel = message.mentions.channels.first();
  8. if (!channel) return message.channel.send ('Example: '+message.content.split(' ')[0]+' <mention channel> <time to open>');
  9. var time = message.content.split(' ')[2];
  10. if (!time) return message.channel.send ('Provide a time to open the channel.');
  11. var lastOptions = channel.permissionOverwrites.get (message.guild.roles.everyone.id);
  12. channel.updateOverwrite (message.guild.roles.everyone.id, {
  13. "SEND_MESSAGES": false
  14. }, 'Timed lock');
  15. message.channel.send (`**locked ${message.channel} channel for ${time}.**`)
  16. setTimeout (() => {
  17. channel.permissionOverwrites.get (message.guild.roles.everyone.id).update (lastOptions) //يرجع برمشنات الروم زي ماكان
  18. message.channel.send (`**Unlocked ${message.channel} channel.**`);
  19. }, ms (time));
  20. }
  21. });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement