interactions.js is a powerful Node.js module that allows you to easily interact with Discord interactions.
- Object-oriented
- Performant
- Inbuilt Cache
- Easy to use
Node.js 16.9.0 or newer is required.
npm i interactions.js
const { Application } = require("interactions.js");
require('dotenv').config()
const Client = new Application({
botToken: process.env.TOKEN, // Your Bot Token
publicKey: process.env.PUBLICKEY, // The Application Public Key
applicationId: process.env.APPLICATIONID, // The Application ID
port: 8221, // Your Port (Default: 1337)
});
/**
* After calling start(), the api starts on port 8221 in this example and you need to set your application's interaction url to https://your-domain.com/interactions
*
* The /interactions parts is required and you can't change it.
*/
Client.start().then(() => {
console.log("Client Started");
});
Client.on("debug", debug => console.log(debug));
Client.setAppCommands([
{
name: "ping",
description: "Pong!",
},
]).catch(console.log);
Client.on("interactionCreate", async (i) => {
if (i.commandName === "ping") {
return i.reply({
content: "Pong!",
ephemeral: true,
});
}
});
const { UserManager } = require("interactions.js");
const application = await UserManager.fetchMyApplication();
// Note: This is not the actual guild count, but an approximation
const guildCount = application.approximate_guild_count;
If you don't understand something in the documentation, you are experiencing problems, or you just need a gentle nudge in the right direction, please don't hesitate to join our discord server.
- Himiko
- Imagine
- Memer
- TindCord
- Crypto Helper
- your bot? Join our discord server and let us know!