-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcommands.js
More file actions
72 lines (67 loc) · 2.75 KB
/
Copy pathcommands.js
File metadata and controls
72 lines (67 loc) · 2.75 KB
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
require('dotenv/config')
const {REST, Routes, SlashCommandBuilder } = require('discord.js')
//info needed to create slash comands
const botID= "1250664869859168266"
const serverID = process.env.GUILD_ID
const botToken = process.env.BOT_TOKEN
const rest = new REST().setToken(botToken)
const commandRegister = async () => {
try {
//clear all commands to avoid duplicates
await rest.put(Routes.applicationGuildCommands(botID, serverID), { body: [] })
.then(() => console.log('Successfully deleted all commands.'))
.catch(console.error);
//when done for multi-server registration do:
//await rest.put(Routes.applicationCommands(botID)
await rest.put(Routes.applicationGuildCommands(botID,serverID),
{
body: [
new SlashCommandBuilder()
.setName("nominate")
.setDescription("This command nominates a player for promotion")
.addUserOption(option => {
return option
.setName("member")
.setDescription("The member to be nominated")
.setRequired(true)})
.addStringOption(option =>
option.setName('role')
.setDescription('Role for promotion')
.setRequired(true)
.addChoices(
{ name: 'BLANK', value: '1250623077214191678' },
{ name: 'Member', value: '1250627277868240936' },
)),
new SlashCommandBuilder()
.setName("timestamp")
.setDescription("Generate a Discord timestamp from time and date")
.addStringOption(option =>
option
.setName("time")
.setDescription("Time in HH:MM (24-hour)")
.setRequired(true)
)
.addStringOption(option =>
option
.setName("date")
.setDescription("Date in YYYY-MM-DD format")
.setRequired(true)
)
.addStringOption(option =>
option.setName('tz')
.setDescription('Timezone abbreviation (e.g. PST, AEST)')
.setRequired(false))
.addStringOption(option =>
option.setName('timezone')
.setDescription('Context aware timezone (e.g. America/Los_Angeles)')
.setRequired(false))
,
]
}
)
console.log("Successfully registered application commands")
}catch(error) {
console.error(error)
}
}
commandRegister();