2023-05-22 12:36:43 +05:00
|
|
|
const { SlashCommandBuilder, EmbedBuilder, ChannelType } = require("discord.js");
|
2022-08-02 17:18:47 +05:00
|
|
|
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"))
|
2023-06-15 19:46:27 +05:00
|
|
|
.setDescriptionLocalizations({
|
|
|
|
"uk": client.translate("owner/announcement:DESCRIPTION", null, "uk-UA"),
|
|
|
|
"ru": client.translate("owner/announcement:DESCRIPTION", null, "ru-RU"),
|
|
|
|
})
|
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"))
|
2023-06-15 19:46:27 +05:00
|
|
|
.setDescriptionLocalizations({
|
|
|
|
"uk": client.translate("common:MESSAGE", null, "uk-UA"),
|
|
|
|
"ru": client.translate("common:MESSAGE", null, "ru-RU"),
|
|
|
|
})
|
2022-08-09 23:48:33 +05:00
|
|
|
.setRequired(true))
|
|
|
|
.addBooleanOption(option => option.setName("tag")
|
|
|
|
.setDescription(client.translate("owner/announcement:TAG"))
|
2023-06-15 19:46:27 +05:00
|
|
|
.setDescriptionLocalizations({
|
|
|
|
"uk": client.translate("owner/announcement:TAG", null, "uk-UA"),
|
|
|
|
"ru": client.translate("owner/announcement:TAG", null, "ru-RU"),
|
|
|
|
})
|
2023-02-12 15:52:56 +05:00
|
|
|
.setRequired(true))
|
|
|
|
.addBooleanOption(option => option.setName("important")
|
2023-03-26 18:31:19 +05:00
|
|
|
.setDescription(client.translate("owner/announcement:IMPORTANT"))
|
2023-06-15 19:46:27 +05:00
|
|
|
.setDescriptionLocalizations({
|
|
|
|
"uk": client.translate("owner/announcement:IMPORTANT", null, "uk-UA"),
|
|
|
|
"ru": client.translate("owner/announcement:IMPORTANT", null, "ru-RU"),
|
|
|
|
})),
|
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({
|
2023-06-07 23:59:38 +05:00
|
|
|
text: interaction.user.discriminator === "0" ? interaction.user.username : 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();
|
2023-05-22 12:36:43 +05:00
|
|
|
const channel = important ? (guild?.data?.plugins.news ? guild.channels.cache.get(guild?.data?.plugins.news) : guild.channels.cache.find(c => c.type === ChannelType.GuildText)) : guild.channels.cache.get(guild?.data?.plugins.news);
|
2023-02-12 15:52:56 +05:00
|
|
|
|
2023-02-12 16:00:53 +05:00
|
|
|
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;
|