Application

Create your Application

Constructor

new Application(options) → {Application}

Parameters:
NameTypeDescription
optionsObject

The options for the application

Properties
NameTypeDescription
botTokenstring

the bot token

publicKeystring

the public key

applicationIdstring

the application id

mongooseStringstring

the mongoose connection string

portnumber

the port for the application

cacheChannelsboolean

whether to cache channels or not

cacheUsersboolean

whether to cache users or not

cacheMembersboolean

whether to cache members or not

cacheGuildsboolean

whether to cache guilds or not

cacheRolesboolean

whether to cache roles or not

useMongooseCacheboolean

whether to use the mongoose cache or not

customCacheCooldownnumber

the custom cache cooldown

runOnAllInterfacesboolean

whether to run the application on all interfaces or not - needed for docker

apiInstance* | null

if you want to use your own express or fastify instance

Returns:

The application

Type: 
Application
Example
const { Application } = require("interactions.js");

const client = new Application({ botToken: "Bot Token", publicKey: "Public Key", applicationId: "Application Id", fetchClient: true });
client.on("debug", debug => {
   console.log(debug);
})
client.start();

Members

apiInstance :*|null

if you want to use your own express or fastify instance

Type:
  • * | null

applicationId :string

the ID of the application (needed)

Type:
  • string

botToken :string

the token of the bot application (needed)

Type:
  • string

cacheChannels :boolean

boolean to enable or disable the client channels cache

Type:
  • boolean

cacheGuilds :boolean

boolean to enable or disable the client guilds cache

Type:
  • boolean

cacheMembers :boolean

boolean to enable or disable the client members cache

Type:
  • boolean

cacheRoles :boolean

boolean to enable or disable the client roles cache

Type:
  • boolean

cacheUsers :boolean

boolean to enable or disable the client users cache

Type:
  • boolean

customCacheCooldown :*|number

set a custom cool down in milliseconds to save the cache in the mongoose database

Type:
  • * | number

mongooseString :string

the mongoose connection string (not needed)

Type:
  • string

port :number

the port for the application (default is "1337")

Type:
  • number

publicKey :string

the public key of the application (needed)

Type:
  • string

readySince :number|null

The unix timestamp since when the bot is ready

Type:
  • number | null

runOnAllInterfaces :boolean

whether to run the application on all interfaces or not - needed for docker

Type:
  • boolean

useMongooseCache :*|boolean

boolean to enable or disable that interactions.js use the mongoose connection to save and load cache

Type:
  • * | boolean

Methods

(async) setAppCommands(arrayOfSlashCommands)

Set the Slash Commands for the Application

Parameters:
NameTypeDescription
arrayOfSlashCommandsarray

an array of slash commands to set

(async) setGuildCommands(arrayOfSlashCommands, GuildId)

Set the Slash Commands for a Guild

Parameters:
NameTypeDescription
arrayOfSlashCommandsarray

an array of slash commands to set

GuildIdstring

the guild id to post the commands to

(async) start(token)

Start the application

Parameters:
NameTypeDescription
token

the bot token if not already set as "botToken" in the application creation

Events

connectionToDatabase

Emitted the database connection to event.

Parameters:
NameTypeDescription
clientApplication

The bot client

databaseConnected

Emitted the database connected event.

Parameters:
NameTypeDescription
clientApplication

The bot client

databaseDisconnected

Emitted the database disconnected event.

Parameters:
NameTypeDescription
clientApplication

The bot client

databaseError

Emitted the database error event.

Parameters:
NameTypeDescription
clientApplication

The bot client

errerr

The error message

interactionCreate

Emitted the interaction event.

Parameters:
NameTypeDescription
interactionInteraction

The Interaction to handle

ready

Emitted the ready event.

Parameters:
NameTypeDescription
ClientApplication

The Client

ready

Emitted the ready event.

Parameters:
NameTypeDescription
ClientApplication

The Client

starting

Emitted the starting event.

Parameters:
NameTypeDescription
cApplication

The Client