forked from funnbot/Nitro
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathhidechannel.js
More file actions
51 lines (50 loc) · 2.2 KB
/
Copy pathhidechannel.js
File metadata and controls
51 lines (50 loc) · 2.2 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
exports.run = (message, bot) => {
let num = parseInt(message.args[0]) || false;
if (num > 3600) return message.channel.send("Channel hiding must last less than an hour.");
if (num <= 1) return message.channel.send("Channel hide time too short.");
let prefix = bot.config.getPrefix(message.guild.id);
if (!message.args[0] || num === false) return message.channel.send("You can hide a channel with:\n" + prefix + "hidechannel <seconds>");
message.channel.send("**This channel has been hidden for " + num + " seconds.**\nYou can end hiding by typing `unlock` in chat or by waiting the alloted time.").then((m) => {
let before = m.channel.permissionOverwrites.get(message.guild.id);
if (before) {
if (before.allow & 1 << 10) before = true
else if (before.deny & 1 << 10) before = false
else before = null
} else before = null
message.channel.overwritePermissions(message.guild.id, {
READ_MESSAGES: false
}).then(() => {
let collect = message.channel.createCollector(ms => ms.author.id === message.author.id, {
time: num * 1000
});
collect.on('collect', (msg) => {
if (msg.content === "unlock") {
m.channel.overwritePermissions(message.guild.id, {
READ_MESSAGES: before
}).then(() => {
clearTimeout(timer);
m.channel.send("**The hiding has ended**");
collect.stop();
});
}
})
let timer = setTimeout(function () {
m.channel.overwritePermissions(message.guild.id, {
READ_MESSAGES: before
}).then(() => {
m.channel.send("**The hiding has ended**");
collect.stop();
});
}, num * 1000);
})
});
}
exports.conf = {
userPerm: ["MANAGE_CHANNELS", "MANAGE_GUILD"],
botPerm: ["SEND_MESSAGES", "MANAGE_CHANNELS"],
coolDown: 0,
dm: true,
category: "Moderation",
help: "Hide a channel for a number of seconds",
args: "<seconds>",
}