#Hello guys, tell me how a bot should send a text if there is no command in the code structure to per

11 messages · Page 1 of 1 (latest)

twin heron
#

const { EmbedBuilder } = require('discord.js');

// inside a command, event listener, etc.
const exampleEmbed = new EmbedBuilder()
.setColor(0x0099FF)
.setTitle('Some title')
.setURL('https://discord.js.org/')
.setAuthor({ name: 'Some name', iconURL: 'https://i.imgur.com/AfFp7pu.png', url: 'https://discord.js.org' })
.setDescription('Some description here')
.setThumbnail('https://i.imgur.com/AfFp7pu.png')
.addFields(
{ name: 'Regular field title', value: 'Some value here' },
{ name: '\u200B', value: '\u200B' },
{ name: 'Inline field title', value: 'Some value here', inline: true },
{ name: 'Inline field title', value: 'Some value here', inline: true },
)
.addFields({ name: 'Inline field title', value: 'Some value here', inline: true })
.setImage('https://i.imgur.com/AfFp7pu.png')
.setTimestamp()
.setFooter({ text: 'Some footer text here', iconURL: 'https://i.imgur.com/AfFp7pu.png' });

channel.send({ embeds: [exampleEmbed] });

cosmic sorrel
#

there's a small mistake in your code. The class is called MessageEmbed instead of EmbedBuilder

#

const { MessageEmbed } = require('discord.js');

// inside a command, event listener, etc.
const exampleEmbed = new MessageEmbed()
.setColor(0x0099FF)
.setTitle('Some title')
.setURL('https://discord.js.org/')
.setAuthor({ name: 'Some name', iconURL: 'https://i.imgur.com/AfFp7pu.png', url: 'https://discord.js.org' })
.setDescription('Some description here')
.setThumbnail('https://i.imgur.com/AfFp7pu.png')
.addFields(
{ name: 'Regular field title', value: 'Some value here' },
{ name: '\u200B', value: '\u200B' },
{ name: 'Inline field title', value: 'Some value here', inline: true },
{ name: 'Inline field title', value: 'Some value here', inline: true },
)
.addFields({ name: 'Inline field title', value: 'Some value here', inline: true })
.setImage('https://i.imgur.com/AfFp7pu.png')
.setTimestamp()
.setFooter({ text: 'Some footer text here', iconURL: 'https://i.imgur.com/AfFp7pu.png' });

channel.send({ embeds: [exampleEmbed] });

#

And for your question of this post:
If you want your bot to respond with a specific text or perform an action when no command is matched in your code structure, you can use the message event provided by the Discord.js library. This event is triggered whenever a message is sent in any channel that the bot can see. You can check if the message doesn't match any command and respond accordingly.

#

Here's an example:

#

const { Client, Intents } = require('discord.js');
const client = new Client({ intents: [Intents.FLAGS.GUILDS, Intents.FLAGS.GUILD_MESSAGES] });

const prefix = '!'; // Your bot's command prefix

client.on('messageCreate', (message) => {
// Ignore messages from bots
if (message.author.bot) return;

// Check if the message starts with the command prefix
if (!message.content.startsWith(prefix)) {
    // Respond with a default message when no command is matched
    message.channel.send('I didn\'t recognize that as a command. Type !help for a list of commands.');
}

// Your command handling logic goes here...

});

client.login('YOUR_BOT_TOKEN');

#

@twin heron

#

Understand

twin heron
#

oh thanks, I'll try to figure it out