// SupportBot | Emerald Services // Embed Command const fs = require("fs"); const Discord = require("discord.js"); const yaml = require("js-yaml"); const supportbot = yaml.load( fs.readFileSync("./Configs/supportbot.yml", "utf8") ); const cmdconfig = yaml.load(fs.readFileSync("./Configs/commands.yml", "utf8")); const Command = require("../Structures/Command.js"); module.exports = new Command({ name: cmdconfig.Embed.Command, description: cmdconfig.Embed.Description, type: Discord.ApplicationCommandType.ChatInput, options: [ { name: "title", description: "Embed Title", type: Discord.ApplicationCommandOptionType.String, required: true, }, { name: "message", description: "Embed Message", type: Discord.ApplicationCommandOptionType.String, required: true, }, { name: "color", description: "Embed HEX Color", type: Discord.ApplicationCommandOptionType.String, required: false, }, { name: "fieldtitle", description: "Add an additional Embed Field", type: Discord.ApplicationCommandOptionType.String, required: false, }, { name: "fieldcontent", description: "Add an additional Embed Field", type: Discord.ApplicationCommandOptionType.String, required: false, }, { name: "thumbnail", description: "Embed Thumbnail URL", type: Discord.ApplicationCommandOptionType.String, required: false, }, { name: "image", description: "Embed Image URL", type: Discord.ApplicationCommandOptionType.String, required: false, }, ], permissions: cmdconfig.Embed.Permission, async run(interaction) { let disableCommand = true; if (cmdconfig.Embed.Enabled === false) { if (interaction.type === Discord.InteractionType.ApplicationCommand && disableCommand) return interaction.reply({ content: ":x: This command is `disabled`", ephemeral: true, }); } const { getRole } = interaction.client; let SupportStaff = await getRole(supportbot.Staff, interaction.guild); let Admin = await getRole(supportbot.Admin, interaction.guild); if (!SupportStaff || !Admin) return interaction.reply( "Some roles seem to be missing!\nPlease check for errors when starting the bot." ); const NoPerms = new Discord.EmbedBuilder() .setTitle("Invalid Permissions!") .setDescription( `${supportbot.IncorrectPerms}\n\nRole Required: \`${supportbot.Staff}\` or \`${supportbot.Admin}\`` ) .setColor(supportbot.WarningColour); if ( interaction.member.roles.cache.has(SupportStaff.id) || interaction.member.roles.cache.has(Admin.id) ) { const EmbedTitle = interaction.options.getString("title"); const EmbedSubject = interaction.options.getString("message"); const GeneralColour = interaction.options.getString("color"); const EmbedThumbnail = interaction.options.getString("thumbnail"); const EmbedImage = interaction.options.getString("image"); const EmbedFieldContent = interaction.options.getString("fieldcontent"); const EmbedFieldTitle = interaction.options.getString("fieldtitle"); const EmbedMsg = new Discord.EmbedBuilder() .setTitle(EmbedTitle) .setDescription(EmbedSubject) .setColor(GeneralColour) .setThumbnail(EmbedThumbnail) .setImage(EmbedImage) if (EmbedFieldTitle && EmbedFieldContent) { EmbedMsg.addField(EmbedFieldTitle, EmbedFieldContent) }; interaction.reply({ embeds: [EmbedMsg], }); } else { return interaction.reply({ embeds: [NoPerms] }); } }, });