mirror of
https://github.com/danbulant/discord.js
synced 2026-06-19 06:31:20 +00:00
added examples
This commit is contained in:
parent
af3dce6122
commit
ddf74b76d8
3 changed files with 34 additions and 0 deletions
16
examples/avatar.js
Normal file
16
examples/avatar.js
Normal file
|
|
@ -0,0 +1,16 @@
|
|||
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!" );
|
||||
}
|
||||
}
|
||||
} );
|
||||
10
examples/pingpong.js
Normal file
10
examples/pingpong.js
Normal file
|
|
@ -0,0 +1,10 @@
|
|||
var Discord = require( "discord.js" );
|
||||
var myBot = new Discord.Client();
|
||||
|
||||
myBot.login( "hello@example.com", "password1" );
|
||||
|
||||
myBot.on( "message", function( message ) {
|
||||
if ( message.content === "ping" ) {
|
||||
this.sendMessage( message.channel, "pong" );
|
||||
}
|
||||
} );
|
||||
8
examples/presence.js
Normal file
8
examples/presence.js
Normal file
|
|
@ -0,0 +1,8 @@
|
|||
var Discord = require( "discord.js" );
|
||||
var myBot = new Discord.Client();
|
||||
|
||||
myBot.login( "hello@example.com", "password1" );
|
||||
|
||||
myBot.on( "presence", function( user, status, server ) {
|
||||
bot.sendMessage( server.getDefaultChannel(), user.mention() + " is " + status + "!" );
|
||||
} );
|
||||
Loading…
Reference in a new issue