-
Notifications
You must be signed in to change notification settings - Fork 0
/
deploy-commands.js
151 lines (143 loc) · 4.32 KB
/
deploy-commands.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
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
const { REST, Routes } = require('discord.js');
const { clientId, guildId, token } = require('./config.json');
const fs = require('node:fs');
const path = require('node:path');
const commands = [
{
"name": 'ip',
"description": 'Shows you the ip of the server.',
"options": [
{
"name": "region",
"description": "Server Region",
"type": 3,
"choices": [
{
"name": "EU",
"value": "eu",
},
{
"name": "NA",
"value": "na",
},
],
"required": false,
},
]
},
{
"name": 'playercount',
"description": 'Shows you how many players are online on the server.',
"options": [
{
"name": "region",
"description": "Server Region",
"type": 3,
"choices": [
{
"name": "EU",
"value": "eu",
},
{
"name": "NA",
"value": "na",
},
],
"required": false
},
]
},
{
"name": 'playerlist',
"description": 'Shows you the players are online on the server.',
"options": [
{
"name": "region",
"description": "Server Region",
"type": 3,
"choices": [
{
"name": "EU",
"value": "eu",
},
{
"name": "NA",
"value": "na",
},
],
"required": false
},
]
},
{
"name": 'sendmsg',
"description": 'Sends a message in the current channel (developer only)',
"options": [
{
"name": "msg",
"description": "Message to send",
"type": 3,
"default_member_permissions": "0x0000000000100000",
"choices": [
{
"name": "Join Ping",
"value": "joinping",
},
{
"name": "Rules",
"value": "rules",
},
{
"name": "Info",
"value": "info",
},
{
"name": "How to Install CTS",
"value": "installcts",
},
{
"name": "How to Install Fabric CTS",
"value": "installfabriccts",
}
],
"required": true
},
]
},
/*
{
"name": 'test',
"description": 'frfr',
},
*/
];
// Grab all the command files from the commands directory you created earlier
const commandsPath = path.join(__dirname, 'commands');
/*
const commandFiles = fs.readdirSync(commandsPath).filter(file => file.endsWith('.js'));
for (const file of commandFiles) {
const filePath = path.join(commandsPath, file);
const command = require(filePath);
if ('data' in command && 'execute' in command) {
commands.push(command.data.toJSON());
}
}
*/
// doesnt work (buggy)
// Construct and prepare an instance of the REST module
const rest = new REST().setToken(token);
// and deploy your commands!
(async () => {
try {
console.log(`Started refreshing ${commands.length} application (/) commands.`);
// The put method is used to fully refresh all commands in the guild with the current set
const data = await rest.put(
Routes.applicationGuildCommands(clientId, guildId),
{ body: commands },
);
console.log(`Successfully reloaded ${data.length} application (/) commands.`);
} catch (error) {
// And of course, make sure you catch and log any errors!
console.error(error);
}
})();