const { SlashCommandBuilder, EmbedBuilder } = require('discord.js'); module.exports = { data: new SlashCommandBuilder() .setName('announcement') .setDescription('Creates a announcement embed') .addStringOption((option) => option.setName('title') .setDescription('Adds a title for your announcement') .setRequired(true) ) .addStringOption((option) => option.setName('description') .setDescription('Adds a description for your announcement') .setRequired(true) ) .addStringOption((option) => option .setName('color') .setDescription('Adds a hex color for your announcement') .setRequired(true) ) .addChannelOption((option) => option .setName('channel') .setDescription('Sends a channel for your announcement') .setRequired(true) ), async execute(interaction) { const title = interaction.option.getString('title') const description = interaction.option.getString('description') const color = interaction.option.getString('color') const channel = interaction.option.getChannel('channel') const embed = new EmbedBuilder() .setColor(color) .setTitle(title) .setDescription(description); try { if (channel.id === interaction.channel.id) { await interaction.reply({ embeds: [embed] }); } else { await channel.send({ embeds: [embed] }); await interaction.reply({ content: `Announcement sent to ${channel}!`, ephemeral: true }); } } catch (error) { console.log('Error sending announcement:', error); await interaction.reply({ content: 'Failed to send the announcement, Try again later.', ephemeral: true }); } }, };