Create lockdown.js

This commit is contained in:
unknown 2020-02-06 11:25:27 -08:00
parent e972e33055
commit cbdfe6f935

View 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]"
};