Files
discord.js/examples/send-files.js
Manuel Kraus 8d64435def Update Examples (closes #380) (#383)
* Update examples

* Forgot to save send-files
2016-05-28 18:55:39 -07:00

30 lines
666 B
JavaScript

/* this bot will send an image to a channel */
var Discord = require("../");
var AuthDetails = require("./auth.json");
var bot = new Discord.Client();
bot.on("ready", () => {
console.log("Ready to begin!");
});
bot.on("message", (msg) => {
if (msg.content === "photos") {
bot.sendFile(msg, "./test/image.png", "photo.png", (err, sentMessage) => {
if (err)
console.log("Couldn't send image: ", err);
});
}
else if (msg.content === "file") {
bot.sendFile(msg.channel, new Buffer("Text in a file!"), "file.txt", (err, sentMessage) => {
if (err)
console.log("Couldn't send file: ", err)
});
}
});
bot.loginWithToken(AuthDetails.token);