-
Notifications
You must be signed in to change notification settings - Fork 153
Home
A library to create clients for Discord using Node.js.
There is no official API for Discord as of yet, the developers have been kind enough to allow us to reverse engineer their undocumented API for our libs. Things may break suddenly, simply post an issue (or notify me in a channel) and I'll get to it.
Required:
- Node.js 0.12.x or greater
- Needle module
- ws module
Optional:
- ffmpeg/avconv (and added to PATH)
- node-opus module (required for sending audio streams)
npm install discord.io
var DiscordClient = require('discord.io');
var bot = new DiscordClient({
autorun: true,
token: ""
});
bot.on('ready', function() {
console.log(bot.username + " - (" + bot.id + ")");
});
bot.on('message', function(user, userID, channelID, message, rawEvent) {
if (message === "ping") {
bot.sendMessage({
to: channelID,
message: "pong"
});
}
});
Token support has been brought back by request of the Discord Developers. If you provide a token
, your email
and password
will be ignored. If you do not provide a token
, the lib will log into Discord once, attempt to save the token on your file system as tenc
within your bot's launch directory, encrypt it with your email
and password
and proceed to load it the next time you log in. If that fails (you use a different login) the lib will inform you that it was unable to parse tenc
.