mezotv / interactions.js

A powerful Javascript library to work with discords interactions

Home Page:https://interactionsjs.com/1.2.9/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

About

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

Installation

Node.js 16.9.0 or newer is required.

npm i interactions.js

Example Application

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,
        });
    }
});

Example way to get the guild count

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;

Help

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.

Example Handler

Bots Using interactions.js

About

A powerful Javascript library to work with discords interactions

https://interactionsjs.com/1.2.9/

License:Apache License 2.0


Languages

Language:JavaScript 100.0%