JaBa/commands/Owner/announcement.js
JonnyBro ed8cc4f0be Перенесена категория Music
Мелкие правки
2022-08-02 17:18:47 +05:00

69 lines
No EOL
1.8 KiB
JavaScript

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"))
.addStringOption(option =>
option.setName("message")
.setDescription(client.translate("owner/say:MESSAGE"))
.setRequired(true)),
aliases: [],
dirname: __dirname,
guildOnly: true,
ownerOnly: true
});
}
/**
*
* @param {import("../../base/JaBa")} client
*/
async onLoad() {
//...
}
/**
*
* @param {import("../../base/JaBa")} client
* @param {import("discord.js").ChatInputCommandInteraction} interaction
* @param {Array} data
*/
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({
name: interaction.translate("owner/announcement:TITLE")
})
.setDescription(text)
.setColor(client.config.embed.color)
.setFooter({
text: interaction.user.tag
})
.setTimestamp();
client.guilds.cache.forEach(async guild => {
if (guild.id === "568120814776614924") return;
const channel = guild.channels.cache.find(g => g.id === guild?.data.plugins.welcome.channel);
await channel.send({
content: "||@everyone|| ВАЖНОЕ ОБЪЯВЛЕНИЕ!",
embeds: [embed]
});
});
interaction.editReply({
content: interaction.translate("owner/announcement:SENDED"),
ephemeral: true
});
}
}
module.exports = Announcement;