-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathslash.js
44 lines (39 loc) · 1.02 KB
/
slash.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
// Load config
require("dotenv").config();
// Fetch module
const fetch = require("node-fetch");
const COMMANDS = require("./commands.js");
const API_ENDPOINT = `https://discord.com/api/v8/applications/${process.env.APP_ID}/commands`;
async function clear(commandID) {
const response = await fetch(API_ENDPOINT + "/" + commandID, {
method: "delete",
headers: {
Authorization: "Bot " + process.env.BOT_TOKEN,
},
});
}
async function all(commandID) {
const response = await fetch(API_ENDPOINT, {
method: "get",
headers: {
Authorization: "Bot " + process.env.BOT_TOKEN,
},
});
const json = await response.json();
console.info(json);
}
async function main() {
const response = await fetch(API_ENDPOINT, {
method: "post",
body: JSON.stringify(COMMANDS.PLAYER),
headers: {
Authorization: "Bot " + process.env.BOT_TOKEN,
"Content-Type": "application/json",
},
});
const json = await response.json();
console.info(json);
}
// Register commands
main();
// all();