1.1.2 • Published 3 years ago

discord-interactions-server v1.1.2

Weekly downloads
11
License
MIT
Repository
github
Last release
3 years ago

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.

1.1.2

3 years ago

1.1.1

3 years ago

1.1.0

3 years ago

1.0.4

3 years ago

1.0.2

3 years ago

1.0.1

3 years ago

1.0.0

3 years ago

1.0.3

3 years ago

0.0.1

3 years ago