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"))
|
2023-02-12 15:52:56 +05:00
|
|
|
.setRequired(true))
|
|
|
|
.addBooleanOption(option => option.setName("important")
|
|
|
|
.setDescription(client.translate("owner/announcement:IMPORTANT"))),
|
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 });
|
2023-02-12 15:52:56 +05:00
|
|
|
const text = interaction.options.getString("message"),
|
|
|
|
important = interaction.options.getBoolean("important");
|
2022-08-02 17:18:47 +05:00
|
|
|
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();
|
|
|
|
|
2023-02-12 15:52:56 +05:00
|
|
|
(await client.guilds.fetch()).forEach(async guild => {
|
2022-08-02 17:18:47 +05:00
|
|
|
if (guild.id === "568120814776614924") return;
|
2023-01-09 01:39:13 +05:00
|
|
|
|
2023-02-12 15:52:56 +05:00
|
|
|
guild = await guild.fetch();
|
2022-08-04 19:41:28 +05:00
|
|
|
const channel = guild.channels.cache.get(guild?.data.plugins.news);
|
2023-02-12 15:52:56 +05:00
|
|
|
if (!channel && !important) return;
|
|
|
|
|
|
|
|
if (!channel && important) {
|
|
|
|
guild.channels.cache.find(c => c.isTextBased()).send({
|
|
|
|
content: `${interaction.options.getBoolean("tag") ? "||@everyone|| " : ""}ВАЖНОЕ ОБЪЯВЛЕНИЕ!`,
|
|
|
|
embeds: [embed],
|
|
|
|
});
|
|
|
|
} else if (channel) 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;
|