Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

03090ac: new file: API_KEY … #8

Closed
wants to merge 9 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 0 additions & 3 deletions .env.sample

This file was deleted.

14 changes: 14 additions & 0 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
version: 2
updates:
- package-ecosystem: "npm"
directory: "/"
schedule:
interval: "weekly"
ignore:
- dependency-name: "*"
update-types:
["version-update:semver-patch", "version-update:semver-minor"]
commit-message:
prefix: fix
prefix-development: chore
include: scope
1 change: 1 addition & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{}
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ Below is a basic overview of the project structure:
├── commands.js -> slash command payloads + helpers
├── game.js -> logic specific to the fake game
├── utils.js -> utility functions and enums
|-- package-lock.json
├── package.json
├── README.md
└── .gitignore
Expand Down Expand Up @@ -58,7 +59,7 @@ npm install

Fetch the credentials from your app's settings and add them to a `.env` file (see `.env.sample` for an example). You'll need your app ID (`APP_ID`), bot token (`DISCORD_TOKEN`), and public key (`PUBLIC_KEY`).

Fetching credentials is covered in detail in the [tutorial](http://discord.com/developers/docs/tutorials/developing-a-user-installable-ap).
Fetching credentials is covered in detail in the [tutorial](http://discord.com/developers/docs/tutorials/developing-a-user-installable-app).

> 🔑 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).

Expand Down
4 changes: 2 additions & 2 deletions app.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@ import { getFakeProfile, getWikiItem } from './game.js';

// Create an express app
const app = express();
// Get port, or default to 3000
const PORT = process.env.PORT || 3000;
// Get port, or default to 8080
const PORT = process.env.PORT || 8080;
// Parse request body and verifies incoming requests using discord-interactions package
app.use(express.json({ verify: VerifyDiscordRequest(process.env.PUBLIC_KEY) }));

Expand Down
102 changes: 69 additions & 33 deletions commands.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,40 +3,40 @@ import { fakeGameItems } from './game.js';
import { InstallGlobalCommands } from './utils.js';

// Wiki command for game lookup
const WIKI_COMMAND = {
name: 'wiki',
type: 1,
description: 'Lookup information in wiki',
options: [
{
type: 3,
name: 'item',
description: 'Item to lookup',
choices: fakeGameItems,
required: true,
},
],
integration_types: [0, 1],
contexts: [0, 1, 2],
};
// const WIKI_COMMAND = {
// name: 'wiki',
// type: 1,
// description: 'Lookup information in wiki',
// options: [
// {
// type: 3,
// name: 'item',
// description: 'Item to lookup',
// choices: fakeGameItems,
// required: true,
// },
// ],
// integration_types: [0, 1],
// contexts: [0, 1, 2],
// };

// Leaderboard command, for guild install only
const LEADERBOARD_COMMAND = {
name: 'leaderboard',
type: 1,
description: 'See server leaderboard',
integration_types: [0],
contexts: [0],
};
// const LEADERBOARD_COMMAND = {
// name: 'leaderboard',
// type: 1,
// description: 'See server leaderboard',
// integration_types: [0],
// contexts: [0],
// };

// Profile command
const PROFILE_COMMAND = {
name: 'profile',
type: 1,
description: 'See your game inventory and progress',
integration_types: [1],
contexts: [0, 1, 2],
};
// const PROFILE_COMMAND = {
// name: 'profile',
// type: 1,
// description: 'See your game inventory and progress',
// integration_types: [1],
// contexts: [0, 1, 2],
// };

// Link account command
const LINK_COMMAND = {
Expand All @@ -47,11 +47,47 @@ const LINK_COMMAND = {
contexts: [1],
};

// Scrape command to scrape conversation text
const SCRAPE_COMMAND = {
name: 'scrape',
type: 1,
description: 'Scrape the full text of a conversation with another user',
options: [
{
type: 6,
name: 'user',
description: 'The user to scrape the conversation with',
required: true,
},
],
integration_types: [1],
contexts: [0],
};

// Print command to print conversation text to a file
const PRINT_COMMAND = {
name: 'print',
type: 1,
description: 'Print the scraped conversation text to a .txt file',
options: [
{
type: 3,
name: 'filename',
description: 'The name of the file to print the conversation to',
required: true,
},
],
integration_types: [1],
contexts: [0],
};

const ALL_COMMANDS = [
WIKI_COMMAND,
LEADERBOARD_COMMAND,
PROFILE_COMMAND,
// WIKI_COMMAND,
// LEADERBOARD_COMMAND,
// PROFILE_COMMAND,
LINK_COMMAND,
SCRAPE_COMMAND,
PRINT_COMMAND,
];

InstallGlobalCommands(process.env.APP_ID, ALL_COMMANDS);
Loading