Create lockdown.js
This commit is contained in:
parent
e972e33055
commit
cbdfe6f935
1 changed files with 51 additions and 0 deletions
51
commands/Moderation/lockdown.js
Normal file
51
commands/Moderation/lockdown.js
Normal file
|
@ -0,0 +1,51 @@
|
|||
const ms = require('ms');
|
||||
|
||||
exports.run = async (client, message, args, level) => {
|
||||
if (!client.lockit) client.lockit = [];
|
||||
const time = args.join(' ');
|
||||
const validUnlocks = ['release', 'unlock'];
|
||||
if (!time) return message.reply('you must set a duration for the lockdown in either hours, minutes or seconds.');
|
||||
|
||||
if (validUnlocks.includes(time)) {
|
||||
message.channel.overwritePermissions(message.guild.id, {
|
||||
SEND_MESSAGES: null
|
||||
}).then(() => {
|
||||
message.channel.send('Lockdown has been lifted.');
|
||||
clearTimeout(client.lockit[message.channel.id]);
|
||||
delete client.lockit[message.channel.id];
|
||||
}).catch(error => {
|
||||
console.log(error);
|
||||
});
|
||||
} else {
|
||||
message.channel.overwritePermissions(message.guild.id, {
|
||||
SEND_MESSAGES: false
|
||||
}).then(() => {
|
||||
message.channel.send(`Channel has been locked down for ${ms(ms(time), { long:true })}.`).then(() => {
|
||||
|
||||
client.lockit[message.channel.id] = setTimeout(() => {
|
||||
message.channel.overwritePermissions(message.guild.id, {
|
||||
SEND_MESSAGES: null
|
||||
}).then(message.channel.send('Lockdown has been lifted.')).catch(console.error);
|
||||
delete client.lockit[message.channel.id];
|
||||
}, ms(time));
|
||||
|
||||
}).catch(error => {
|
||||
console.log(error);
|
||||
});
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
exports.conf = {
|
||||
enabled: true,
|
||||
guildOnly: true,
|
||||
aliases: ["ld"],
|
||||
permLevel: "Administrator"
|
||||
};
|
||||
|
||||
exports.help = {
|
||||
name: "lockdown",
|
||||
category: "Moderation",
|
||||
description: "People being a pest somewhere? Lock it down!",
|
||||
usage: "lockdown [duration]"
|
||||
};
|
Loading…
Reference in a new issue