update getting started guide (#66)

This commit is contained in:
Colin Loretz
2025-01-23 11:29:19 -08:00
committed by GitHub
parent 01fe51d04a
commit 91d959af9a

14
app.js
View File

@@ -1,24 +1,30 @@
import 'dotenv/config';
import express from 'express';
import {
InteractionType,
ButtonStyleTypes,
InteractionResponseFlags,
InteractionResponseType,
InteractionType,
MessageComponentTypes,
verifyKeyMiddleware,
} from 'discord-interactions';
import { getRandomEmoji } from './utils.js';
import { getRandomEmoji, DiscordRequest } from './utils.js';
import { getShuffledOptions, getResult } from './game.js';
// Create an express app
const app = express();
// Get port, or default to 3000
const PORT = process.env.PORT || 3000;
// To keep track of our active games
const activeGames = {};
/**
* Interactions endpoint URL where Discord will send HTTP requests
* Parse request body and verifies incoming requests using discord-interactions package
*/
app.post('/interactions', verifyKeyMiddleware(process.env.PUBLIC_KEY), async function (req, res) {
// Interaction type and data
const { type, data } = req.body;
// Interaction id, type and data
const { id, type, data } = req.body;
/**
* Handle verification requests