mirror of
https://github.com/cassoule/flopobot_v2.git
synced 2026-03-18 21:40:27 +01:00
update getting started guide (#66)
This commit is contained in:
14
app.js
14
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
|
||||
|
||||
Reference in New Issue
Block a user