I would like an avatar URL of the person I tagged.
Unfortunately it doesn't work, I don't get an error. Code:
var user = message.mentions.members.first();
let embed = new Discord.MessageEmbed()
.setTitle("test")
.setDescription("test")
.setThumbnail(user.avatarURL)
.setTimestamp();
message.channel.send(embed);
}
I hope someone can help me! :-)
Try using:
user.displayAvatarURL()
Hope this helps!
I've found this example on the official documentation:
https://discord.js.org/#/docs/main/stable/examples/avatars
So maybe do:
message.author.displayAvatarURL()
Related
I am trying to code a command so when someone says !embed it sends an embed to their channel with the title, description and the color as they put in the message, can someone help me?
//the message must be like (!embed Title-<> Color-<> Description)
//!embed Title-<test one> Color-<#ffffff> test test test test test
let title = message.content.split("Title-<")[1].split(">")[0];
let color = message.content.split("Color-<")[1].split(">")[0];
let description = message.content
.replace("!embed","")
.replace(`Title-<${title}>`,"")
.replace(`Color-<${color}>`,"")
let embed = new Discord.MessageEmbed()
.setTitle(title)
.setDescription(description)
.setColor(color)
message.channel.send(embed)
well, I am not good at English
but if the answer is not working , plz tell me to modify it
it will work like this
Just a simple unban all users in guild command for my next ban royale in Discord. Any help would be greatly appreciated!
I wrote this based on the fact that you were writing your bot in discord.js as you did not give much information when writing and all i could see was the tags.
Try this-
const member = message.member;
switch(message.content.toLowerCase()){
case (!"unban all"):
if(member.hasPermission('ADMINISTRATOR')){
message.guild.fetchBans().forEach((fB)=>{
message.guild.members.unban(fB.user.id);
})
// All Users get unbanned
} else {
// User does not have permission.
}
}
})
If this does not work please let me know.
P.S. I'm kinda new to coding so if it is wrong please don't be angry with me.
I'm a starting developer in discord.js, and recently attempted at making welcome messages.
Could you help me, please?
client.on('guildMemberAdd', (member) => {
console.log(member)
const message = `Hello <#${member.id}>`
const welcomeChannel = member.guild.channels.cache.get('775672625018961940')
welcomeChannel.send(message)
})
I'm just sharing the same answer from Worthy Alpaca.
This is so that people who are googling can see the answer.
This may answer your question: Discord.js Bot Welcomes Member, Assign a Role and send them a DM
Good luck with the rest of your bot and have a nice day!
You must enable intents. See more here: https://support-dev.discord.com/hc/en-us/articles/360056426994
I get an error when I run a command, this is my code:
let id = message.author.id.toString().substr(0, 4) + message.author.discriminator;
var name = `order-${message.author}-${id}`
guild.channels.create(name)
}
Error:
ReferenceError: guild is not defined
I hope someone can help me! :-)
You need to add message. before guild
message.guild.channels.create(name)
You can do as Syntle said
message.guild.channels.create(name)
or you can define a guild
let guild = message.guild
guild.channels.create(name)
Alright, so basically I just want to know if it's possible to do what I said in the title. If so, could somebody tell me? It'd be much appreciated. Thanks!
Discord.js docs can be found here.
client.on('guildCreate', guild => {
if (!guild.me.hasPermission('CREATE_INSTANT_INVITE')) return console.log('Insufficient permission.');
guild.channels.first().createInvite()
.then(invite => console.log(invite.url))
.catch(err => console.error());
});