1.1.2 • Published 3 years ago
discord-interactions-server v1.1.2
About
Express Middleware to handle Discord interactions.
This library handles the creation of commands, as well as updating and deleting. It also handles Security and Authorization.
Installation
This is a NodeJS module available through the npm registry.
Installation is done using the npm install
command:
$ npm install discord-interactions-server
Example
const express = require('express')
const { Server, SlashCommand } = require('discord-interactions-server')
const app = express()
const server = Server({
applicationId: 'your client id',
publicKey: 'your public key',
authorization: 'Bot <my bot token>'
})
class HelloWorldCommand extends SlashCommand {
constructor(server, guild) {
super(server, guild, {
name: 'hellooworld',
description: 'Sends Hello World! with your message to the chat',
options: [
{
type: 3,
name: 'message',
description: 'The message to send',
required: true
}
]
})
}
execute(interaction, { message }) {
interaction.respond({
content: `Hello world! ${message}`
})
}
}
server.global.commands
.addCommand(HelloWorldCommand)
.update()
app.listen(3000, () => {
console.log('App is listening on port 3000')
})
Contributing
Pull requests are welcome. For major changes, please open an issue first to discuss what you would like to change.