mirror of
https://github.com/discordjs/discord.js.git
synced 2026-03-16 11:33:30 +01:00
Added send files example
This commit is contained in:
33
examples/send-files.js
Normal file
33
examples/send-files.js
Normal file
@@ -0,0 +1,33 @@
|
|||||||
|
/* 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.channel, "./test/image.png", "photo.png", (err, msg) => {
|
||||||
|
if(err)
|
||||||
|
console.log("couldn't send image:", err);
|
||||||
|
});
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
if( msg.content === "file" ) {
|
||||||
|
bot.sendFile( msg.channel, new Buffer("Text in a file!"), "file.txt", (err, msg) => {
|
||||||
|
if(err)
|
||||||
|
console.log("couldn't send file:", err);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
})
|
||||||
|
|
||||||
|
bot.login(AuthDetails.email, AuthDetails.password);
|
||||||
Reference in New Issue
Block a user