-
Notifications
You must be signed in to change notification settings - Fork 1
/
deploy-commands.js
84 lines (77 loc) · 3.37 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
const { SlashCommandBuilder, REST, Routes, PermissionFlagsBits } = require('discord.js');
const { clientId, guildId, token } = require('./_SECRET/config.js');
const commands = [
new SlashCommandBuilder()
.setName('ical')
.setDescription('Get an ical-feed of your events.').setDescriptionLocalizations({de: 'Erstelle einen ical-Feed für deine Events.'})
.setDMPermission(false)
,
new SlashCommandBuilder()
.setName('top10')
.setDescription('List the top 10 games by player count.').setDescriptionLocalizations({de: 'Zeigt die Top 10-Spiele nach Anzahl von Mitspielern.'})
.addIntegerOption(option => option
.setName('days').setNameLocalizations({de: 'tage'})
.setDescription('Top 10 for what period?').setDescriptionLocalizations({de: 'Top 10 für welchen Zeitraum?'})
.setRequired(false)
)
.setDMPermission(false)
,
new SlashCommandBuilder()
.setName('serverprofile').setNameLocalizations({de: 'serverprofil'})
.setDescription('USER')
.setDMPermission(false)
,
new SlashCommandBuilder()
.setName('lfg').setNameLocalizations({de: 'zocken'})
.setDescription('You want to game and need fellow gamers?').setDescriptionLocalizations({de: 'Du willst was zocken und suchst Mitspieler?'})
.addStringOption(option => option
.setName('day').setNameLocalizations({de: 'tag'})
.setDescription('Select the day you want to play.').setDescriptionLocalizations({de: 'Wähle den Tag an dem du zocken möchtest.'})
.setRequired(false)
.addChoices(
{ name: 'Today', value: 'today', name_localizations: {de: 'Heute'} },
{ name: 'Tomorrow', value: 'tomorrow', name_localizations: {de: 'Morgen'} }
)
)
.addStringOption(option => option
.setName('time').setNameLocalizations({de: 'uhrzeit'})
.setDescription('Select the time you want to play (HH:MM). Use 24h time format.').setDescriptionLocalizations({de: 'Setze die Uhrzeit zu der du spielen möchtest (SS:MM).'})
.setRequired(false)
)
.addStringOption(option => option
.setName('title').setNameLocalizations({de: 'titel'})
.setDescription('Give your gaming session a name.').setDescriptionLocalizations({de: 'Gib deinem /zocken-Aufruf einen Namen.'})
.setRequired(false)
)
.setDMPermission(false)
,
new SlashCommandBuilder()
.setName('setlang').setNameLocalizations({de: 'setzesprache'})
.setDescription('Set you personal language as preferred server language.').setDescriptionLocalizations({de: 'Setze deine persönliche Sprache als bevorzugte Serversprache.'})
.setDefaultMemberPermissions(PermissionFlagsBits.Administrator)
.setDMPermission(false)
,
]
.map(command => command.toJSON());
function capitalizeFirstLetter(string) {
return string.charAt(0).toUpperCase() + string.slice(1);
};
commands.forEach(cmd => {
if (cmd.description == 'USER') {
cmd.type = 2;
cmd.name = capitalizeFirstLetter(cmd.name);
cmd.name_localizations.de = capitalizeFirstLetter(cmd.name_localizations.de)
delete cmd.description;
}
if (cmd.description == 'MESSAGE') {
cmd.type = 3;
cmd.name = capitalizeFirstLetter(cmd.name);
cmd.name_localizations.de = capitalizeFirstLetter(cmd.name_localizations.de)
delete cmd.description;
}
});
console.log(commands);
const rest = new REST({ version: '10' }).setToken(token);
rest.put(Routes.applicationGuildCommands(clientId, guildId), { body: commands })
.then(() => console.log('Successfully registered application commands.'))
.catch(console.error);