How do I mention a user with the blue highlight in Discord Embed? - discord.js

I'm well aware pinging someone with mentions in an embed is impossible, but I still want the blue highlight.
Example:
An image that shows a random bot that is able to mention with blue highlights in an embed that doesn't ping but only mention.
Here's mine, an image that shows my bot that mentions without a blue highlight in an embed.
Here's What I Did:
if(command === 'hug2') {
let targetMember = message.mentions.members.first();
if(!targetMember) return message.reply('you need to mention a user in order to hug them!!');
const exampleEmbed = new EmbedBuilder()
.setTitle(`${message.author.tag} Just Gave <#${targetMember.user.id}> a Hug!`)
.setColor('0x0099FF')
.setImage('http://25.media.tumblr.com/tumblr_ma7l17EWnk1rq65rlo1_500.gif')
.setTimestamp()
.setFooter({ text: 'Made With Horikita Bot!', iconURL: 'https://i.pximg.net/c/250x250_80_a2/img-master/img/2021/01/26/23/55/26/87326371_p0_square1200.jpg' });
message.channel.send({ embeds: [exampleEmbed] });
}

The problem here is probably the fact that you're trying to mention a user in the title of the embed. Try setting the description instead.
if(command === 'hug2') {
let targetMember = message.mentions.members.first();
if(!targetMember) return message.reply('you need to mention a user in order to hug them!!');
const exampleEmbed = new EmbedBuilder()
.setTitle('hug')
.setDescription(`${message.author.tag} Just Gave <#${targetMember.user.id}> a Hug!`)
.setColor('0x0099FF')
.setImage('http://25.media.tumblr.com/tumblr_ma7l17EWnk1rq65rlo1_500.gif')
.setTimestamp()
.setFooter({ text: 'Made With Horikita Bot!', iconURL: 'https://i.pximg.net/c/250x250_80_a2/img-master/img/2021/01/26/23/55/26/87326371_p0_square1200.jpg' });
message.channel.send({ embeds: [exampleEmbed] });
}
I'm not sure of any reason for it to be impossible to mention in an embed's title, but at the very least, this should work.

Related

discordjs v14 - How to modify embed?

i try make embed
const exampleEmbed = new EmbedBuilder()
.setAuthor({ name: `name : ${name}` })
.setColor(0x0099ff)
.setTitle(`title: ${title}`)
.setDescription(`content : ${content}`)
make embed!!
looking for discordjs14 guide
// Resending a received embed
const receivedEmbed = message.embeds[0];
const exampleEmbed = EmbedBuilder.from(receivedEmbed).setTitle('New title');
channel.send({ embeds: [exampleEmbed] });
----------------------------------------------
// Editing the embedded message content
const exampleEmbed = new EmbedBuilder()
.setTitle('Some title')
.setDescription('Description after the edit');
message.edit({ embeds: [exampleEmbed] });
i try to get message.embed[0]
async execute(interaction) {
...
console.log(interaction.embed[0])
...
}
error:
i hope search title and edit embed...
If you want to send an embed and edit it on an event, You should make thay message a var.
const channel = <client>.channels.cache.get('channel_id');
let message = await channel.send({embeds: [exampleEmbed] });
// editing it
await message.edit({ embeds: [exampleEmbed1] });
Notes: Replace <client> with what you declared your client. it could be client , bot or anything you have declared it.
fist you need to make embed message
const embed = new EmbedBuilder()
.setColor("Your Color")
.setTitle("YourTitle")
.setThumbnail("your google image address")
.setImage("Your Google Image address")
.setDescription("Your Description")
and so much more stuff just type .set or .add it will show you so many of them
and for send the embed
message.reply({embeds : [embed]});

Why this avatarURL() didn't work on discordjs?

So i want to make greetings card, when someone join it will send the information about username etc, everything work great, but not with the .setThumbnail(member.avatarURL()) i have no idea why it didnt work.
this is my full code
// ---- GREETINGS ----
client.on('guildMemberAdd', member => {
const exampleEmbed = new MessageEmbed()
.setTitle('Wellcome to the server :hatching_chick: ')
.setDescription(`Hello <#${member.id}> don't forget to register ^^`)
.setThumbnail(member.avatarURL())
.setFooter({ text: "Please read pinned messages",
iconURL: 'https://s3.getstickerpack.com/8c0f922eae5097'});
member.guild.channels.cache.get('981582630317338656').send({ embeds: [exampleEmbed] });
});
i use .setThumbnail(member.displayAvatarURL()) thank you #Elitezen

How do I make the returned message a embed? DISCORD.JS

Hey how do I make the returned message an embed?
return message.reply(`**Here is a list of commands:** \n *Type y!catagory for the commands of the catagory!* \n \n **Economy** \n *y!economy* `);
};
exports.help = {
name: "help",
aliases: ["h"],
usage: "help"
}
You can check v12 embeds guide or v13 embeds guide which can help you
Also some code example:
const embed = new Discord.MessageEmbed()
.setDescription(your_text)
.setTitle("Test Embed")
.setColor("RANDOM");
message.channel.send(embed)
Please note this code is for discord.js v12.x
For v13 you need to use the embeds property
const embed = new Discord.MessageEmbed()
.setDescription(your_text)
.setTitle("Test Embed")
.setColor("RANDOM");
message.channel.send({ embeds: [embed] })

Embed message discord.js

Ive seen many discord embed codes like this:
(This is an old question and im new to coding so...)
const { MessageEmbed } = require('discord.js');
const exampleEmbed = new MessageEmbed()
.setColor('#0099ff')
.setTitle('Some title')
.setURL('https://discord.js.org/')
.setAuthor('Some name', 'https://i.imgur.com/AfFp7pu.png', '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 },
)
.addField('Inline field title', 'Some value here', true)
.setImage('https://i.imgur.com/AfFp7pu.png')
.setTimestamp()
.setFooter('Some footer text here', 'https://i.imgur.com/AfFp7pu.png');
channel.send({ embeds: [exampleEmbed] });
So, what i dont understand is what is the trigger? Like you're supposed to type .ping for pong right? so what do i type to get my bot type this embed?
The way you're sending your embed is(afaik) specific to version 13 of discord.js and you most likely haven't updated discord.js yet:
channel.send({ embeds: [exampleEmbed] });
the version I am currently using is 12.5.3 .
Check your version of discord.js in package.json and if the version is not 13 or above, update or if you want to stick with version 12.5.3 try some of the methods below:
channel.send( exampleEmbed );
Or like this:
channel.send({ embed: exampleEmbed });
Sending the embed like this: "{ embeds: [exampleEmbed] }" makes discord think you are sending an empty message and therefore it doesn't send anything.
This code is meant to be inside an event handler (such as on.message). If that code is already inside an event handler (except for this const { MessageEmbed } = require('discord.js');, it should go at the top), and if it is still not sending, then you should change this line:
channel.send({ embeds: [exampleEmbed] });
to
message.channel.send(exampleEmbed)
There is no trigger in the code sample you provided. You need to have a listener for the message event or interactionCreate event to listen to traditional message-based commands and slash commands. You can pass in handlers into these listeners and respond to command usages.
Since it looks like you're reading the discord.js guide, I would suggest reading from the start, where you would be introduced to how to handle messages first.
To send it, just use a message event. Like this:
const { MessageEmbed, Client } = require('discord.js');
const client = new Client();
client.on('message', msg => {
const { channel, content } = msg;
if(msg.content === 'someCommand') {
const exampleEmbed = new MessageEmbed()
//setProperties...
channel.send({ embeds: [exampleEmbed] });
}
})
client.login('[TOKEN_HERE'])
What's happening here is that the client is receiving a Message object when someone messages (msg). We then use the channel and content properties to evaluate the command, and send the embed if the command is correct. I took out the property settings to save space. You can add them back.

Embed not settings image and thumnail

When a user joins the server the bot will send an embed. Everything works fine except the image and thumbnail.
Client.on('guildMemberAdd', member => {
const embed = new Discord.MessageEmbed()
.setTitle(`Welcome ***${member.displayName}***`)
.setColor("#2163D7")
.addFields({ name: `**${member.displayName}**`, value: 'Please read the **rules**'},{ name: `You are our ` , value: `***${member.guild.memberCount}*** member!`})
.setImage(member.user.avatarURL)
.setThumbnail(member.user.avatarURL)
console.log(member.user.avatarURL);
let channel = member.guild.channels.cache.find(channel => channel.name === "🚪┊𝙱𝚒𝚎𝚗𝚟𝚎𝚗𝚞𝚎");
channel.send(embed);
});
Image of what it returns
Thanks for your help :)
In Discord JS v12, avatarURL is a method. So you'll have to use:
member.user.avatarURL()

Resources