Files
discord.js/docs/examples/avatars.js
2021-03-29 05:51:42 +02:00

32 lines
870 B
JavaScript

'use strict';
/**
* Send a user a link to their avatar
*/
// Import the discord.js module
const { Client, Intents } = require('discord.js');
// Create an instance of a Discord client
const client = new Client({ intents: [Intents.FLAGS.GUILDS, Intents.FLAGS.GUILD_MESSAGES] });
/**
* The ready event is vital, it means that only _after_ this will your bot start reacting to information
* received from Discord
*/
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.channel.send(message.author.displayAvatarURL());
}
});
// Log our bot in using the token from https://discord.com/developers/applications
client.login('your token here');