From 91d959af9a4b8bc4721d8b2980258cf8180f22cb Mon Sep 17 00:00:00 2001 From: Colin Loretz Date: Thu, 23 Jan 2025 11:29:19 -0800 Subject: [PATCH] update getting started guide (#66) --- app.js | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/app.js b/app.js index 2210545..b358737 100644 --- a/app.js +++ b/app.js @@ -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