mirror of
https://github.com/arthur-pbty/xiao.git
synced 2026-06-17 08:17:35 +02:00
Remove Lockdown Timer
This commit is contained in:
+1
-4
@@ -100,17 +100,14 @@ client.setInterval(async () => {
|
|||||||
let battle = client.registry.resolveCommand('games:battle').fighting.size;
|
let battle = client.registry.resolveCommand('games:battle').fighting.size;
|
||||||
let hangman = client.registry.resolveCommand('games:hangman').playing.size;
|
let hangman = client.registry.resolveCommand('games:hangman').playing.size;
|
||||||
let gunfight = client.registry.resolveCommand('games:gunfight').fighting.size;
|
let gunfight = client.registry.resolveCommand('games:gunfight').fighting.size;
|
||||||
let lockdown = client.registry.resolveCommand('moderation:lockdown').channels.size;
|
while (battle > 0 || hangman > 0 || gunfight > 0) {
|
||||||
while (battle > 0 || hangman > 0 || gunfight > 0 || lockdown > 0) {
|
|
||||||
if (battle > 0) console.log(`[RESTART] A battle is going on in Shard ${client.shard.id}, delaying...`);
|
if (battle > 0) console.log(`[RESTART] A battle is going on in Shard ${client.shard.id}, delaying...`);
|
||||||
if (hangman > 0) console.log(`[RESTART] A game of hangman is going on in Shard ${client.shard.id}, delaying...`);
|
if (hangman > 0) console.log(`[RESTART] A game of hangman is going on in Shard ${client.shard.id}, delaying...`);
|
||||||
if (gunfight > 0) console.log(`[RESTART] A gunfight is going on in Shard ${client.shard.id}, delaying...`);
|
if (gunfight > 0) console.log(`[RESTART] A gunfight is going on in Shard ${client.shard.id}, delaying...`);
|
||||||
if (lockdown > 0) console.log(`[RESTART] A channel is locked down on Shard ${client.shard.id}, delaying...`);
|
|
||||||
await wait(300000);
|
await wait(300000);
|
||||||
battle = client.registry.resolveCommand('games:battle').fighting.size;
|
battle = client.registry.resolveCommand('games:battle').fighting.size;
|
||||||
hangman = client.registry.resolveCommand('games:hangman').playing.size;
|
hangman = client.registry.resolveCommand('games:hangman').playing.size;
|
||||||
gunfight = client.registry.resolveCommand('games:gunfight').fighting.size;
|
gunfight = client.registry.resolveCommand('games:gunfight').fighting.size;
|
||||||
lockdown = client.registry.resolveCommand('moderation:lockdown').channels.size;
|
|
||||||
}
|
}
|
||||||
console.log(`[RESTART] Shard ${client.shard.id} Restarted.`);
|
console.log(`[RESTART] Shard ${client.shard.id} Restarted.`);
|
||||||
process.exit(0);
|
process.exit(0);
|
||||||
|
|||||||
@@ -1,6 +1,5 @@
|
|||||||
const Command = require('../../structures/Command');
|
const Command = require('../../structures/Command');
|
||||||
const { stripIndents } = require('common-tags');
|
const { stripIndents } = require('common-tags');
|
||||||
const { wait } = require('../../structures/Util');
|
|
||||||
|
|
||||||
module.exports = class LockdownCommand extends Command {
|
module.exports = class LockdownCommand extends Command {
|
||||||
constructor(client) {
|
constructor(client) {
|
||||||
@@ -23,45 +22,22 @@ module.exports = class LockdownCommand extends Command {
|
|||||||
return 'Invalid action, please enter either start or stop.';
|
return 'Invalid action, please enter either start or stop.';
|
||||||
},
|
},
|
||||||
parse: action => action.toLowerCase()
|
parse: action => action.toLowerCase()
|
||||||
},
|
|
||||||
{
|
|
||||||
key: 'time',
|
|
||||||
prompt: 'How long should the channel be locked down (in minutes)?',
|
|
||||||
type: 'integer',
|
|
||||||
default: '',
|
|
||||||
validate: time => {
|
|
||||||
if (time > 0 && time < 11) return true;
|
|
||||||
return 'Please keep the time under 10 minutes.';
|
|
||||||
},
|
|
||||||
parse: time => time * 60000
|
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
});
|
});
|
||||||
|
|
||||||
this.channels = new Set();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
async run(msg, args) { // eslint-disable-line consistent-return
|
async run(msg, args) { // eslint-disable-line consistent-return
|
||||||
const { action, time } = args;
|
const { action } = args;
|
||||||
if (action === 'start') {
|
if (action === 'start') {
|
||||||
if (this.channels.has(msg.channel.id)) return msg.say('This channel is already locked down.');
|
|
||||||
await msg.channel.overwritePermissions(msg.guild.defaultRole, { SEND_MESSAGES: false });
|
await msg.channel.overwritePermissions(msg.guild.defaultRole, { SEND_MESSAGES: false });
|
||||||
this.channels.add(msg.channel.id);
|
return msg.say(stripIndents`
|
||||||
await msg.say(stripIndents`
|
|
||||||
Lockdown started, users without overwrites can no longer post messages.
|
Lockdown started, users without overwrites can no longer post messages.
|
||||||
${time ? `Please wait ${time / 60000} minutes.` : 'Please use `lockdown stop` to end the lockdown.'}
|
Please use \`lockdown stop\` to end the lockdown.
|
||||||
`);
|
`);
|
||||||
if (!time) return null;
|
|
||||||
await wait(time);
|
|
||||||
if (!this.channels.has(msg.channel.id)) return null;
|
|
||||||
await msg.channel.overwritePermissions(msg.guild.defaultRole, { SEND_MESSAGES: null });
|
|
||||||
this.channels.delete(msg.channel.id);
|
|
||||||
return msg.say('Lockdown ended, all users can now post messages.');
|
|
||||||
}
|
}
|
||||||
if (action === 'stop') {
|
if (action === 'stop') {
|
||||||
if (!this.channels.has(msg.channel.id)) return msg.say('This channel is not locked down.');
|
|
||||||
await msg.channel.overwritePermissions(msg.guild.defaultRole, { SEND_MESSAGES: null });
|
await msg.channel.overwritePermissions(msg.guild.defaultRole, { SEND_MESSAGES: null });
|
||||||
this.channels.delete(msg.channel.id);
|
|
||||||
return msg.say('Lockdown ended, all users can now post messages.');
|
return msg.say('Lockdown ended, all users can now post messages.');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
+1
-1
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "xiaobot",
|
"name": "xiaobot",
|
||||||
"version": "32.0.0",
|
"version": "33.0.0",
|
||||||
"description": "Your personal server companion.",
|
"description": "Your personal server companion.",
|
||||||
"main": "Shard.js",
|
"main": "Shard.js",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
|
|||||||
Reference in New Issue
Block a user