mirror of
https://github.com/discordjs/discord.js.git
synced 2026-03-09 16:13:31 +01:00
17 lines
619 B
JavaScript
17 lines
619 B
JavaScript
var Discord = require( "discord.js" );
|
|
var myBot = new Discord.Client();
|
|
|
|
myBot.login( "hello@example.com", "password1" );
|
|
|
|
myBot.on( "message", function( message ) {
|
|
if ( message.content === "$avatar" ) {
|
|
var user = message.author; //the user who wants an avatar is the author
|
|
if ( user.avatar ) {
|
|
var url = "https://discordapp.com/api/users/" + user.id + "/avatars/" + user.avatar + ".jpg";
|
|
bot.sendMessage( message.channel, message.author.mention() + ", here's your avatar: " + url );
|
|
} else {
|
|
bot.sendMessage( message.channel, message.author.mention() + ", you don't have an avatar!" );
|
|
}
|
|
}
|
|
} );
|