Constructor
new Application(options) → {Application}
Name | Type | Description | |||||||||||||||||||||||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
options | Object | The options for the application Properties
|
- Source
The application
- Type:
- Application
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
- * |
null
- Source
applicationId :string
the ID of the application (needed)
- string
- Source
botToken :string
the token of the bot application (needed)
- string
- Source
cacheChannels :boolean
boolean to enable or disable the client channels cache
- boolean
- Source
cacheGuilds :boolean
boolean to enable or disable the client guilds cache
- boolean
- Source
cacheMembers :boolean
boolean to enable or disable the client members cache
- boolean
- Source
cacheRoles :boolean
boolean to enable or disable the client roles cache
- boolean
- Source
cacheUsers :boolean
boolean to enable or disable the client users cache
- boolean
- Source
customCacheCooldown :*|number
set a custom cool down in milliseconds to save the cache in the mongoose database
- * |
number
- Source
mongooseString :string
the mongoose connection string (not needed)
- string
- Source
port :number
the port for the application (default is "1337")
- number
- Source
publicKey :string
the public key of the application (needed)
- string
- Source
readySince :number|null
The unix timestamp since when the bot is ready
- number |
null
- Source
runOnAllInterfaces :boolean
whether to run the application on all interfaces or not - needed for docker
- boolean
- Source
useMongooseCache :*|boolean
boolean to enable or disable that interactions.js use the mongoose connection to save and load cache
- * |
boolean
- Source
Methods
(async) setAppCommands(arrayOfSlashCommands)
Set the Slash Commands for the Application
Name | Type | Description |
---|---|---|
arrayOfSlashCommands | array | an array of slash commands to set |
- Source
(async) setGuildCommands(arrayOfSlashCommands, GuildId)
Set the Slash Commands for a Guild
Name | Type | Description |
---|---|---|
arrayOfSlashCommands | array | an array of slash commands to set |
GuildId | string | the guild id to post the commands to |
- Source
(async) start(token)
Start the application
Name | Type | Description |
---|---|---|
token | the bot token if not already set as "botToken" in the application creation |
- Source
Events
connectionToDatabase
Emitted the database connection to event.
Name | Type | Description |
---|---|---|
client | Application | The bot client |
- Source
databaseConnected
Emitted the database connected event.
Name | Type | Description |
---|---|---|
client | Application | The bot client |
- Source
databaseDisconnected
Emitted the database disconnected event.
Name | Type | Description |
---|---|---|
client | Application | The bot client |
- Source
databaseError
Emitted the database error event.
Name | Type | Description |
---|---|---|
client | Application | The bot client |
err | err | The error message |
- Source
interactionCreate
Emitted the interaction event.
Name | Type | Description |
---|---|---|
interaction | Interaction | The Interaction to handle |
- Source
ready
Emitted the ready event.
Name | Type | Description |
---|---|---|
Client | Application | The Client |
- Source
ready
Emitted the ready event.
Name | Type | Description |
---|---|---|
Client | Application | The Client |
- Source
starting
Emitted the starting event.
Name | Type | Description |
---|---|---|
c | Application | The Client |
- Source