2022-01-13 00:56:24 +05:00
|
|
|
const Command = require("../../base/Command"),
|
2022-01-04 02:18:28 +05:00
|
|
|
ms = require("ms");
|
|
|
|
|
|
|
|
class Slowmode extends Command {
|
|
|
|
constructor(client) {
|
|
|
|
super(client, {
|
|
|
|
name: "slowmode",
|
|
|
|
dirname: __dirname,
|
|
|
|
enabled: true,
|
|
|
|
guildOnly: true,
|
|
|
|
aliases: ["sl"],
|
|
|
|
memberPermissions: ["MANAGE_GUILD"],
|
|
|
|
botPermissions: ["SEND_MESSAGES", "EMBED_LINKS"],
|
|
|
|
nsfw: false,
|
|
|
|
ownerOnly: false,
|
|
|
|
cooldown: 2000
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
async run(message, args, data) {
|
2022-01-05 00:24:57 +05:00
|
|
|
const channel = message.mentions.channels.filter((ch) => ch.type === "GUILD_TEXT" && ch.guild.id === message.guild.id).first();
|
2022-01-04 02:18:28 +05:00
|
|
|
if (!channel) return message.error("misc:INVALID_CHANNEL");
|
|
|
|
|
|
|
|
const time = args[1];
|
|
|
|
if (!time) {
|
|
|
|
if (!data.guild.slowmode.channels.find((ch) => ch.id === channel.id)) return message.error("misc:INVALID_TIME");
|
|
|
|
|
|
|
|
data.guild.slowmode.channels = data.guild.slowmode.channels.filter((ch) => ch.id !== channel.id);
|
|
|
|
data.guild.markModified("slowmode.channels");
|
|
|
|
data.guild.save();
|
|
|
|
message.success("administration/slowmode:DISABLED", {
|
|
|
|
prefix: data.guild.prefix,
|
|
|
|
channel: `#${channel.name}`
|
|
|
|
});
|
|
|
|
} else {
|
|
|
|
if (isNaN(ms(time))) return message.error("misc:INVALID_TIME");
|
|
|
|
if (data.guild.slowmode.channels.find((ch) => ch.id === channel.id)) data.guild.slowmode.channels = data.guild.slowmode.channels.filter((ch) => ch.id !== channel.id);
|
|
|
|
|
|
|
|
data.guild.slowmode.channels.push({
|
|
|
|
id: channel.id,
|
|
|
|
time: ms(time)
|
|
|
|
});
|
|
|
|
data.guild.markModified("slowmode.channels");
|
|
|
|
data.guild.save();
|
|
|
|
message.success("administration/slowmode:ENABLED", {
|
|
|
|
prefix: data.guild.prefix,
|
|
|
|
channel: `#${channel.name}`,
|
|
|
|
time: this.client.functions.convertTime(message.guild, ms(time))
|
|
|
|
});
|
2022-01-13 00:26:23 +05:00
|
|
|
}
|
2022-01-04 02:18:28 +05:00
|
|
|
}
|
2022-01-13 00:26:23 +05:00
|
|
|
}
|
2022-01-04 02:18:28 +05:00
|
|
|
|
|
|
|
module.exports = Slowmode;
|