mirror of
https://github.com/cassoule/flopobot_v2.git
synced 2026-01-18 16:37:40 +01:00
@@ -4,7 +4,7 @@ This project contains a basic rock-paper-scissors-style Discord app written in J
|
||||
|
||||

|
||||
|
||||
> ✨ A version of this code is also hosted **[on Glitch 🎏](https://glitch.com/edit/#!/getting-started-discord)**.
|
||||
> ✨ A version of this code is also hosted **[on Glitch 🎏](https://glitch.com/~getting-started-discord)** and **[on Replit 🌀](https://replit.com/@shaydewael/discord-example-app)**
|
||||
|
||||
## Project structure
|
||||
Below is a basic overview of the project structure:
|
||||
@@ -50,6 +50,8 @@ Fetch the credentials from your app's settings and add them to a `.env` file (se
|
||||
|
||||
Fetching credentials is covered in detail in the [getting started guide](https://discord.com/developers/docs/getting-started).
|
||||
|
||||
> 🔑 Environment variables can be added to the `.env` file in Glitch or when developing locally, and in the Secrets tab in Replit (the lock icon on the left).
|
||||
|
||||
### Run the app
|
||||
|
||||
After your credentials are added, go ahead and run the app:
|
||||
|
||||
6
app.js
6
app.js
@@ -17,6 +17,8 @@ import {
|
||||
|
||||
// Create an express app
|
||||
const app = express();
|
||||
// Get port, or default to 3000
|
||||
const PORT = process.env.PORT || 3000;
|
||||
// Parse request body and verifies incoming requests using discord-interactions package
|
||||
app.use(express.json({ verify: VerifyDiscordRequest(process.env.PUBLIC_KEY) }));
|
||||
|
||||
@@ -173,8 +175,8 @@ app.post('/interactions', async function (req, res) {
|
||||
}
|
||||
});
|
||||
|
||||
app.listen(3000, () => {
|
||||
console.log('Listening on port 3000');
|
||||
app.listen(PORT, () => {
|
||||
console.log('Listening on port', PORT);
|
||||
|
||||
// Check if guild commands from commands.json are installed (if not, install them)
|
||||
HasGuildCommands(process.env.APP_ID, process.env.GUILD_ID, [
|
||||
|
||||
@@ -5,7 +5,8 @@
|
||||
"main": "app.js",
|
||||
"type": "module",
|
||||
"scripts": {
|
||||
"start": "node app.js"
|
||||
"start": "node app.js",
|
||||
"dev": "nodemon app.js"
|
||||
},
|
||||
"author": "Shay DeWael",
|
||||
"license": "MIT",
|
||||
|
||||
Reference in New Issue
Block a user