mirror of
https://github.com/cassoule/flopobot_v2.git
synced 2026-03-18 21:40:27 +01:00
Use native node.js fetch (#53)
This commit is contained in:
1171
package-lock.json
generated
Normal file
1171
package-lock.json
generated
Normal file
File diff suppressed because it is too large
Load Diff
@@ -1,11 +1,12 @@
|
||||
{
|
||||
"name": "getting-started",
|
||||
"name": "discord-getting-started",
|
||||
"private": true,
|
||||
"version": "1.0.0",
|
||||
"description": "Discord example app",
|
||||
"main": "app.js",
|
||||
"type": "module",
|
||||
"engines": {
|
||||
"node": "16.x"
|
||||
"node": ">=18.x"
|
||||
},
|
||||
"scripts": {
|
||||
"start": "node app.js",
|
||||
@@ -17,8 +18,7 @@
|
||||
"dependencies": {
|
||||
"discord-interactions": "^3.2.0",
|
||||
"dotenv": "^16.0.3",
|
||||
"express": "^4.18.2",
|
||||
"node-fetch": "^3.3.0"
|
||||
"express": "^4.18.2"
|
||||
},
|
||||
"devDependencies": {
|
||||
"nodemon": "^2.0.15"
|
||||
|
||||
3
utils.js
3
utils.js
@@ -1,5 +1,4 @@
|
||||
import 'dotenv/config';
|
||||
import fetch from 'node-fetch';
|
||||
import { verifyKey } from 'discord-interactions';
|
||||
|
||||
export function VerifyDiscordRequest(clientKey) {
|
||||
@@ -20,7 +19,7 @@ export async function DiscordRequest(endpoint, options) {
|
||||
const url = 'https://discord.com/api/v10/' + endpoint;
|
||||
// Stringify payloads
|
||||
if (options.body) options.body = JSON.stringify(options.body);
|
||||
// Use node-fetch to make requests
|
||||
// Use fetch to make requests
|
||||
const res = await fetch(url, {
|
||||
headers: {
|
||||
Authorization: `Bot ${process.env.DISCORD_TOKEN}`,
|
||||
|
||||
Reference in New Issue
Block a user