Files
discord.js/docs/examples/avatars.js
Mstrodl 1fadd0f859 Update avatar example for v12.0 (#1610)
User.displayAvatarURL was changed from a property to a method so I changed the example accordingly
2017-06-24 23:12:22 +01:00

31 lines
809 B
JavaScript

/*
Send a user a link to their avatar
*/
// Import the discord.js module
const Discord = require('discord.js');
// Create an instance of a Discord client
const client = new Discord.Client();
// The token of your bot - https://discordapp.com/developers/applications/me
const token = 'your bot token here';
// The ready event is vital, it means that your bot will only start reacting to information
// from Discord _after_ ready is emitted
client.on('ready', () => {
console.log('I am ready!');
});
// Create an event listener for messages
client.on('message', message => {
// If the message is "what is my avatar"
if (message.content === 'what is my avatar') {
// Send the user's avatar URL
message.reply(message.author.displayAvatarURL());
}
});
// Log our bot in
client.login(token);