1.0.2 • Published 1 year ago

serverless-discord-lambda v1.0.2

Weekly downloads
-
License
MIT
Repository
github
Last release
1 year ago

serverless-discord-lambda

serverless-discord-lambda is an extension of serverless-discord to provide a streamlined experience on lambda. It can be found on npm.

Quick Start

Please note that this library is still in pre-release status and is not production-ready. We are still making large changes to the API, so please come back for a more polished project.

To get started, install the serverless-discord package from npm:

npm install serverless-discord serverless-discord-lambda

Next, create a simple command like this one:

import { ServerlessDiscordCommandChatInput, DiscordInteractionApplicationCommand, DiscordInteractionResponse, DiscordInteractionResponseTypes } from "serverless-discord";
import { initLambdaRouter } from "serverless-discord-lambda";

// You can get this from the Discord Developer Portal
const DISCORD_PUBLIC_KEY = process.env?.DISCORD_PUBLIC_KEY || "";

class HelloWorldCommand extends ServerlessDiscordCommandChatInput {
    constructor() {
        super({
            name: "test",
            options: [],
        });
    }
    async handleInteraction(interaction: DiscordInteractionApplicationCommand): Promise<DiscordInteractionResponse> {
        return {
            type: DiscordInteractionResponseTypes.CHANNEL_MESSAGE_WITH_SOURCE,
            data: {
                content: "Hello World!",
            },
        }
    }
}

const router = initLambdaRouter({ commands: [new HelloWorldCommand()], applicationPublicKey: DISCORD_PUBLIC_KEY });