-
-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathdeploy-commands.ts
More file actions
209 lines (184 loc) · 5.37 KB
/
deploy-commands.ts
File metadata and controls
209 lines (184 loc) · 5.37 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
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
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
import * as dotenv from 'dotenv';
dotenv.config({ quiet: true });
import { SlashCommandBuilder, PermissionFlagsBits, Routes, REST } from 'discord.js';
import { config } from './modules/util/config.mjs';
// Manual command builder for now
const commands = [
// dump
new SlashCommandBuilder()
.setName('dump')
.setDescription('Dumps info about the bot')
.addBooleanOption((option) =>
option
.setName('post')
.setDescription('publicly post this?')
),
new SlashCommandBuilder()
.setName('file')
.setDescription('Get a given file ')
.addStringOption((option) =>
option
.setName('path')
.setDescription('The path to the file')
.setRequired(true)
.setMaxLength(4095)
)
.addStringOption((option) =>
option
.setName('line')
.setDescription('The line(s) to fetch. Format: 12 or 20-30')
.setRequired(false)
)
.addStringOption((option) =>
option
.setName('org')
.setDescription("Can short-circuit with 'org/repo'. Defaults to 'LMMS'")
.setRequired(false)
.setMinLength(3)
.setMaxLength(39)
)
.addStringOption((option) =>
option
.setName('repo')
.setDescription("The repository to fetch the file from. Defaults to 'lmms'")
.setRequired(false)
.setMinLength(1)
.setMaxLength(100)
),
// restart
new SlashCommandBuilder()
.setName('restart')
.setDescription('Bippidy Boppidy Ska'),
// new SlashCommandBuilder()
// .setName('reload')
// .setDescription('Reloads all of the bot\'s modules'),
// kill bot
new SlashCommandBuilder()
.setName('kill')
.setDescription('Was I not good enough?'),
// say
new SlashCommandBuilder()
.setName('say')
.setDescription('say something as the bot')
.addStringOption(option =>
option.setName('message')
.setDescription('what LoMMuS should say')
.setRequired(true))
.addChannelOption(option =>
option.setName('channel')
.setDescription("Defaults to this channel")
.setRequired(false)
),
// info embed
new SlashCommandBuilder()
.setName('infoembed')
.setDescription('generate the LMMS server info embed')
.setDefaultMemberPermissions(PermissionFlagsBits.BanMembers),
new SlashCommandBuilder()
.setName('ping')
.setDescription('Get latency measurements'),
// rule
new SlashCommandBuilder()
.setName('rule')
.setDescription('display a rule in the chat')
.addIntegerOption(option =>
option.setName('number')
.setDescription('number of rule')
.setRequired(true)),
// rulelist
new SlashCommandBuilder()
.setName('rulelist')
.setDescription('get a private copy of the rules'),
// edit
new SlashCommandBuilder()
.setName('editrule')
.setDescription('edit rules')
.addIntegerOption(option =>
option.setName('number')
.setDescription('rule number to edit')
.setRequired(true))
.addStringOption(option =>
option.setName('target')
.setDescription('select target to edit')
.setRequired(true)
.addChoices(
{ name: 'rule title', value: 'ruleEditTitle' },
{ name: 'rule body', value: 'ruleEditBody' },
))
.addStringOption(option =>
option.setName('input')
.setDescription('what you would like the target to say')
.setRequired(true))
.setDefaultMemberPermissions(PermissionFlagsBits.BanMembers),
// channels
new SlashCommandBuilder()
.setName('channels')
.setDescription('get a list of server channels'),
new SlashCommandBuilder()
.setName('nightly')
.setDescription('Give information about LMMS\'s nightly builds'),
// toggle
new SlashCommandBuilder()
.setName('toggle')
.setDescription('( ͡°( ͡° ͜ʖ( ͡° ͜ʖ ͡°)ʖ ͡°) ͡°)')
.addStringOption(option =>
option.setName('function')
.setDescription('functionality to toggle')
.setRequired(true)
// .addChoices(
// { name: 'color', value: 'toggle_color' },
// )
),
// whois
new SlashCommandBuilder()
.setName('whois')
.setDescription('get info about a user')
.addUserOption(option =>
option.setName('user')
.setDescription('user mention or ID')
.setRequired(true)),
// server
new SlashCommandBuilder()
.setName('server')
.setDescription('get info about the server'),
// bot
new SlashCommandBuilder()
.setName('bot')
.setDescription('get info about this bot'),
// topic
new SlashCommandBuilder()
.setName('topic')
.setDescription('briefly display topic of channel'),
].map(command => command.toJSON());
/* Discord JS command handler is a bunch of bullshit
const fs = require('fs');
const commandFiles = fs.readdirSync('./modules').filter(file => file.endsWith('.js'));
for (const file of commandFiles) {
const command = require(`./modules/${file}`);
if (command.data) {
const data = Object.values(command.data);
console.log(data);
commands.push(data.toJSON());
}
}
*/
/* // Jank Context Menu workaround, thanks Discord.JS
commands.push(
{
name: 'log', type: 3,
},
{
name: 'log (delete)', type: 3,
},
); */
if (process.env.TOKEN) {
const rest = new REST({ version: '9' }).setToken(process.env.TOKEN);
rest.put(Routes.applicationGuildCommands(config.clientId, config.guildId), { body: [] })
.then(() => console.log('Deleted registered application commands, registering again...'))
.catch(console.error);
rest.put(Routes.applicationGuildCommands(config.clientId, config.guildId), { body: commands })
.then(() => console.log('Successfully registered application commands'))
.catch(console.error);
} else {
console.error("Token is missing!");
}