mirror of
https://github.com/discordjs/discord.js.git
synced 2026-03-09 16:13:31 +01:00
30 lines
666 B
JavaScript
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); |