-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.mjs
57 lines (51 loc) · 1.06 KB
/
index.mjs
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
45
46
47
48
49
50
51
52
53
54
55
56
57
import fetch from "node-fetch";
//import { config } from "dotenv";
//require('dotenv').config();
import 'dotenv/config';
console.log(process.env.APP_ID);
console.log(process.env.GUILD_ID);
console.log(process.env.BOT_TOKEN);
const appID = process.env.APP_ID;
const guildID = process.env.GUILD_ID;
const apiEndpoint =
`https://discord.com/api/v8/applications/${appID}/guilds/${guildID}/commands`;
const botToken = process.env.BOT_TOKEN;
const commandData = {
name: "vms",
description: "VMServer Commands",
options: [
{
name: "action",
description: "start/stop",
type: 3,
required: true,
choices: [
{
name: "start",
value: "start"
},
{
name: "stop",
value: "stop"
},
{
name: "test",
value: "test"
}
]
},
],
};
async function main() {
const response = await fetch(apiEndpoint, {
method: "post",
body: JSON.stringify(commandData),
headers: {
Authorization: "Bot " + botToken,
"Content-Type": "application/json",
},
});
const json = await response.json();
console.log(json);
}
main();