This is an embed builder discord.js v14
can anyone make it simpler ??
const { SlashCommandBuilder } = require('@discordjs/builders');
const { EmbedBuilder } = require('discord.js');
module.exports = {
data: new SlashCommandBuilder()
.setName('embed')
.setDescription('Send a message in an embed')
.addStringOption(option =>
option.setName('line1')
.setDescription('The first line of text for the embed')
.setRequired(true))
.addStringOption(option =>
option.setName('line2')
.setDescription('The second line of text for the embed')
.setRequired(false))
.addStringOption(option =>
option.setName('line3')
.setDescription('The third line of text for the embed')
.setRequired(false))
.addStringOption(option =>
option.setName('line4')
.setDescription('The fourth line of text for the embed')
.setRequired(false))
.addStringOption(option =>
option.setName('line5')
.setDescription('The fifth line of text for the embed')
.setRequired(false))
.addStringOption(option =>
option.setName('line6')
.setDescription('The sixtsh line of text for the embed')
.setRequired(false))
.addStringOption((option) =>
option.setName('title')
.setDescription('The Title Of Your Embed')
.setRequired(false))
.addStringOption(option =>
option.setName('image')
.setDescription('The image to display in the embed')
.setRequired(false)),
async execute(interaction) {
const embedTitle = interaction.options.getString('title');
const image = interaction.options.getString('image');
const line1 = interaction.options.getString('line1');
const line2 = interaction.options.getString('line2');
const line3 = interaction.options.getString('line3');
const line4 = interaction.options.getString('line4');
const line5 = interaction.options.getString('line5');
const line6 = interaction.options.getString('line6');
const descriptionParts = [];
if (line1) {
descriptionParts.push(`> **${line1}**`);
}
if (line2) {
descriptionParts.push(`> **${line2}**`);
}
if (line3) {
descriptionParts.push(`> **${line3}**`);
}
if (line4) {
descriptionParts.push(`> **${line4}**`);
}
if (line5) {
descriptionParts.push(`> **${line5}**`);
}
if (line6) {
descriptionParts.push(`> **${line6}**`);
}
const embed = new EmbedBuilder()
.setColor('Gold')
.setDescription(descriptionParts.join('nn'));
if (embedTitle) {
embed.setTitle(embedTitle)
}
if (image) {
if (image.startsWith('http')) {
embed.setImage(image);
} else {
return interaction.reply({ content: 'Invalid image URL provided.', ephemeral: true});
}
}
await interaction.reply({ content: 'Done Sending The Embed 🟢', ephemeral: true })
await interaction.channel.send({ embeds: });
},
};
I want to make The Command More Simpler
can anyone make it simpler
so the user won’t select 99 lines
i don’t have a specific idea about the method that the command should work like it, but can anyone help me make it more simpler ??
I want to make The Command More Simpler
can anyone make it simpler
so the user won’t select 99 lines
i don’t have a specific idea about the method that the command should work like it, but can anyone help me make it more simpler ??
I want to make The Command More Simpler
can anyone make it simpler
so the user won’t select 99 lines
i don’t have a specific idea about the method that the command should work like it, but can anyone help me make it more simpler ??
2
Answers
You can make a loop instead of conditions:
One word: Modals.
Instead of using a load of command options you could make the command trigger a modal with a paragraph text input. This approach is a lot simpler
Here’s an example:
There’s a full Modals guide on the DiscordJS documentation page to help you get started: Modals | discord.js Guide
Hope this helps!