10.1.0 • Published 3 years ago

discord.dev v10.1.0

Weekly downloads
-
License
MIT
Repository
github
Last release
3 years ago

Discord.dev NPM version

A Node.js wrapper for interfacing with Discord.

Installing

npm install discord.bots

Ping Pong Example

const Bots = require("discord.bots");

var bot = new Bots("Bot TOKEN");
// Replace TOKEN with your bot account's token

bot.on("ready", () => { // When the bot is ready
    console.log("Ready!"); // Log "Ready!"
});

bot.on("messageCreate", (msg) => { // When a message is created
    if(msg.content === "!ping") { // If the message content is "!ping"
        bot.createMessage(msg.channel.id, "Pong!");
        // Send a message in the same channel with "Pong!"
    } else if(msg.content === "!pong") { // Otherwise, if the message is "!pong"
        bot.createMessage(msg.channel.id, "Ping!");
        // Respond with "Ping!"
    }
});

bot.login(); // Get the bot to connect to Discord

Useful Links

License

Refer to the LICENSE file.