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

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

Related

How do I mention a user with the blue highlight in Discord Embed?

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.

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]});

Discord.js Send content of used command to admin

I am not 100% sure on how to do this or if its possible but is there a way that a user could do
#command issue here
and send the issue towards a specific channel or admin?
So its basically like a way to report issues towards admins of the bot
I would appreciate the help and thanks in advance
module.exports = {
name: "reportissue",
description: "Report an issue you are experiencing with the bot",
permissions: {
channel: ["VIEW_CHANNEL", "SEND_MESSAGES", "EMBED_LINKS"],
member: ["ADMINISTRATOR"],
},
aliases: ["report", "issue"],
run: async (client, message, args, { GuildDB }) => {
// I have removed this since its not the correct usage
// message.channel.send("issue");
};
}
}
Yes, this would work
const query = args.join (" ")
if(!query) return message.channel.send("Please specify the bug you want to report")
const reportEmbed = new MessageEmbed()
.setTitle('Bug!')
.addField('Author', message.author.toString(), true)
.addField('Report', query)
.addField('Guild', message.guild.name, true)
.setThumbnail(message.author.displayAvatarURL({ dynamic: true }))
.setTimestamp()
message.channel.send('We are extremely sorry for this issue. Your report has successfully been submitted and will be looked into. \n Regards, AuraBot Team')
client.channels.cache.get('id').send(reportEmbed);

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.

How do i use the command that uses mention on discord.js bot

Ok so I have made a command, that sends an embed on users info
case 'playerinfo'
const embed = new discord.MessageEmbed()
.setTitle('User information')
.addField('Player Name', message.author.username)
.addField('Current server', message.guild.name)
.setColor(0x34eb8f)
.setThumbnail(message.author.displayAvatarURL())
message.channel.send(embed)
now what it does is if I do !playerinfo, it tells us our username, and our profile picture and the server we are using it on. But what I want it to do is that if I type !playerinfo #randomname, I want it to give info on that player. Please tell me how to do that?
You can use message.mentions.users to get the mentioned user, if that is not provided then it'd just use your own user
case 'playerinfo'
const user = message.mentions.users.first() || message.author
const embed = new discord.MessageEmbed()
.setTitle('User information')
.addField('Player Name', user.username)
.addField('Current server', message.guild.name)
.setColor(0x34eb8f)
.setThumbnail(user.displayAvatarURL())
message.channel.send(embed)

Resources