mirror of
https://github.com/JonnyBro/JaBa.git
synced 2024-11-22 05:04:58 +05:00
Фикс clear all
This commit is contained in:
parent
0afc33e9c3
commit
8718697115
1 changed files with 49 additions and 45 deletions
|
@ -20,14 +20,13 @@ class Clear extends Command {
|
|||
if (args[0] === "all") {
|
||||
message.channel.send(message.translate("moderation/clear:ALL_CONFIRM"));
|
||||
|
||||
await message.channel.awaitMessages((m) => (m.author.id === message.author.id) && (m.content === "confirm"), {
|
||||
max: 1,
|
||||
time: 20000,
|
||||
errors: ["time"]
|
||||
}).catch(() => {
|
||||
return message.error("misc:TIMES_UP");
|
||||
const filter = m => m.author.id === message.author.id && m.content === "confirm";
|
||||
const collector = message.channel.createMessageCollector({
|
||||
filter,
|
||||
time: 120000 // 2 minutes
|
||||
});
|
||||
|
||||
collector.on("collect", async message => {
|
||||
const position = message.channel.position;
|
||||
const newChannel = await message.channel.clone();
|
||||
await message.channel.delete();
|
||||
|
@ -35,8 +34,12 @@ class Clear extends Command {
|
|||
return newChannel.send({
|
||||
content: message.translate("moderation/clear:CHANNEL_CLEARED")
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
collector.on("end", (_, reason) => {
|
||||
if (reason === "time") return message.error("misc:TIMES_UP");
|
||||
});
|
||||
} else {
|
||||
const amount = args[0];
|
||||
if (!amount || isNaN(amount) || parseInt(amount) < 1) return message.error("moderation/clear:MISSING_AMOUNT");
|
||||
|
||||
|
@ -72,5 +75,6 @@ class Clear extends Command {
|
|||
}, 2000);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
module.exports = Clear;
|
Loading…
Reference in a new issue