2022-08-02 17:18:47 +05:00
|
|
|
const { SlashCommandBuilder, EmbedBuilder } = require("discord.js");
|
|
|
|
const BaseCommand = require("../../base/BaseCommand");
|
|
|
|
|
|
|
|
class Announcement extends BaseCommand {
|
|
|
|
/**
|
|
|
|
*
|
|
|
|
* @param {import("../base/JaBa")} client
|
|
|
|
*/
|
|
|
|
constructor(client) {
|
|
|
|
super({
|
|
|
|
command: new SlashCommandBuilder()
|
|
|
|
.setName("announcement")
|
|
|
|
.setDescription(client.translate("owner/announcement:DESCRIPTION"))
|
2022-10-13 00:05:36 +05:00
|
|
|
.setDMPermission(true)
|
2022-08-04 19:26:17 +05:00
|
|
|
.addStringOption(option => option.setName("message")
|
|
|
|
.setDescription(client.translate("common:MESSAGE"))
|
2022-08-09 23:48:33 +05:00
|
|
|
.setRequired(true))
|
|
|
|
.addBooleanOption(option => option.setName("tag")
|
|
|
|
.setDescription(client.translate("owner/announcement:TAG"))
|
2022-08-04 19:26:17 +05:00
|
|
|
.setRequired(true)),
|
2022-08-02 17:18:47 +05:00
|
|
|
aliases: [],
|
|
|
|
dirname: __dirname,
|
2022-12-15 21:02:38 +05:00
|
|
|
ownerOnly: true,
|
2022-08-02 17:18:47 +05:00
|
|
|
});
|
|
|
|
}
|
|
|
|
/**
|
|
|
|
*
|
|
|
|
* @param {import("../../base/JaBa")} client
|
|
|
|
*/
|
|
|
|
async onLoad() {
|
|
|
|
//...
|
|
|
|
}
|
|
|
|
/**
|
|
|
|
*
|
|
|
|
* @param {import("../../base/JaBa")} client
|
|
|
|
* @param {import("discord.js").ChatInputCommandInteraction} interaction
|
2022-08-09 23:48:33 +05:00
|
|
|
* @param {Object} data
|
2022-08-02 17:18:47 +05:00
|
|
|
*/
|
|
|
|
async execute(client, interaction) {
|
|
|
|
await interaction.deferReply({ ephemeral: true });
|
|
|
|
const text = interaction.options.getString("message");
|
|
|
|
if (text.length > 1000) return interaction.error("owner/announcement:TOO_LONG");
|
|
|
|
|
|
|
|
const embed = new EmbedBuilder()
|
|
|
|
.setAuthor({
|
2022-12-15 21:02:38 +05:00
|
|
|
name: interaction.translate("owner/announcement:TITLE"),
|
2022-08-02 17:18:47 +05:00
|
|
|
})
|
|
|
|
.setDescription(text)
|
|
|
|
.setColor(client.config.embed.color)
|
|
|
|
.setFooter({
|
2022-12-15 21:02:38 +05:00
|
|
|
text: interaction.user.tag,
|
2022-08-02 17:18:47 +05:00
|
|
|
})
|
|
|
|
.setTimestamp();
|
|
|
|
|
|
|
|
client.guilds.cache.forEach(async guild => {
|
|
|
|
if (guild.id === "568120814776614924") return;
|
2023-01-09 01:39:13 +05:00
|
|
|
|
2022-08-04 19:41:28 +05:00
|
|
|
const channel = guild.channels.cache.get(guild?.data.plugins.news);
|
2022-08-02 17:18:47 +05:00
|
|
|
await channel.send({
|
2022-08-09 23:48:33 +05:00
|
|
|
content: `${interaction.options.getBoolean("tag") ? "||@everyone|| " : ""}ВАЖНОЕ ОБЪЯВЛЕНИЕ!`,
|
2022-12-15 21:02:38 +05:00
|
|
|
embeds: [embed],
|
2022-08-02 17:18:47 +05:00
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
interaction.editReply({
|
|
|
|
content: interaction.translate("owner/announcement:SENDED"),
|
2022-12-15 21:02:38 +05:00
|
|
|
ephemeral: true,
|
2022-08-02 17:18:47 +05:00
|
|
|
});
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
module.exports = Announcement;
|