-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathCmdCodeMC.java
664 lines (523 loc) · 27.3 KB
/
CmdCodeMC.java
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
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
/*
* Copyright 2024 CodeMC.io
*
* Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated
* documentation files (the "Software"), to deal in the Software without restriction, including without limitation
* the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software,
* and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all copies or substantial
* portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
* INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
* WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE
* OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
package io.codemc.bot.commands;
import com.jagrosh.jdautilities.command.SlashCommand;
import com.jagrosh.jdautilities.command.SlashCommandEvent;
import io.codemc.api.database.DatabaseAPI;
import io.codemc.api.database.User;
import io.codemc.api.jenkins.JenkinsAPI;
import io.codemc.api.jenkins.JenkinsJob;
import io.codemc.api.nexus.NexusAPI;
import io.codemc.bot.CodeMCBot;
import io.codemc.bot.utils.APIUtil;
import io.codemc.bot.utils.CommandUtil;
import kotlinx.serialization.json.JsonObject;
import kotlinx.serialization.json.JsonPrimitive;
import net.dv8tion.jda.api.EmbedBuilder;
import net.dv8tion.jda.api.entities.Guild;
import net.dv8tion.jda.api.entities.Member;
import net.dv8tion.jda.api.entities.MessageEmbed;
import net.dv8tion.jda.api.entities.Role;
import net.dv8tion.jda.api.exceptions.ErrorHandler;
import net.dv8tion.jda.api.interactions.InteractionHook;
import net.dv8tion.jda.api.interactions.commands.OptionMapping;
import net.dv8tion.jda.api.interactions.commands.OptionType;
import net.dv8tion.jda.api.interactions.commands.build.OptionData;
import net.dv8tion.jda.api.requests.ErrorResponse;
import org.jetbrains.annotations.VisibleForTesting;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.time.Instant;
import java.util.List;
import java.util.concurrent.atomic.AtomicBoolean;
import java.util.concurrent.atomic.AtomicInteger;
public class CmdCodeMC extends BotCommand {
static final Logger LOGGER = LoggerFactory.getLogger(CmdCodeMC.class);
public CmdCodeMC(CodeMCBot bot) {
super(bot);
this.name = "codemc";
this.help = "Commands for the CodeMC Service.";
this.children = new SlashCommand[]{
new Jenkins(bot),
new Nexus(bot),
new Remove(bot),
new Validate(bot),
new Link(bot),
new Unlink(bot),
new ChangePassword(bot),
new CreateUser(bot),
new DeleteUser(bot)
};
}
@Override
public void withModalReply(SlashCommandEvent event) {
}
@Override
public void withHookReply(InteractionHook hook, SlashCommandEvent event, Guild guild, Member member) {
}
@VisibleForTesting
static class Jenkins extends BotCommand {
public Jenkins(CodeMCBot bot) {
super(bot);
this.name = "jenkins";
this.help = "Fetch information about the Jenkins Service.";
this.options = List.of(
new OptionData(OptionType.STRING, "job", "The Jenkins Job Location to fetch. I.e. \"CodeMC/API\".").setRequired(true)
);
}
@Override
public void withModalReply(SlashCommandEvent event) {
}
@Override
public void withHookReply(InteractionHook hook, SlashCommandEvent event, Guild guild, Member member) {
String job = event.getOption("job", null, OptionMapping::getAsString);
if (job == null || !job.contains("/")) {
CommandUtil.EmbedReply.from(hook).error("Invalid Jenkins Job provided!").send();
return;
}
MessageEmbed embed = createInfoEmbed(job);
if (embed == null) {
CommandUtil.EmbedReply.from(hook).error("Failed to fetch Jenkins Job Info!").send();
return;
}
hook.editOriginalEmbeds(embed).queue();
}
@VisibleForTesting
MessageEmbed createInfoEmbed(String job) {
String jenkinsUrl = bot.getConfigHandler().getString("jenkins", "url");
String username = job.split("/")[0];
String jobName = job.split("/")[1];
JenkinsJob info = JenkinsAPI.getJobInfo(username, jobName);
if (info == null) return null;
EmbedBuilder embed = CommandUtil.getEmbed()
.setTitle(job, info.getUrl())
.setAuthor(username, jenkinsUrl + "/job/" + username)
.setDescription(info.getDescription())
.setTimestamp(Instant.now());
if (info.getLastBuild() != null)
embed.addField("Last Build", info.getLastBuild().toString(), false);
if (info.getLastCompletedBuild() != null)
embed.addField("Last Complete Build", info.getLastCompletedBuild().toString(), false);
if (info.getLastFailedBuild() != null)
embed.addField("Last Failed Build", info.getLastFailedBuild().toString(), false);
if (info.getLastStableBuild() != null)
embed.addField("Last Stable Build", info.getLastStableBuild().toString(), false);
return embed.build();
}
}
@VisibleForTesting
static class Nexus extends BotCommand {
public Nexus(CodeMCBot bot) {
super(bot);
this.name = "nexus";
this.help = "Fetch information about the Nexus Service.";
this.options = List.of(
new OptionData(OptionType.STRING, "user", "The user that owns the repository.").setRequired(true)
);
}
@Override
public void withModalReply(SlashCommandEvent event) {
}
@Override
public void withHookReply(InteractionHook hook, SlashCommandEvent event, Guild guild, Member member) {
String user = event.getOption("user", null, OptionMapping::getAsString);
if (user == null || user.isEmpty()) {
CommandUtil.EmbedReply.from(hook).error("Invalid Username provided!").send();
return;
}
MessageEmbed embed = createInfoEmbed(user);
if (embed == null) {
CommandUtil.EmbedReply.from(hook).error("Failed to fetch Nexus Repository Info!").send();
return;
}
hook.sendMessageEmbeds(embed).queue();
}
@VisibleForTesting
MessageEmbed createInfoEmbed(String user) {
String nexusUrl = bot.getConfigHandler().getString("nexus", "url");
String repository = user.toLowerCase();
JsonObject info = NexusAPI.getNexusRepository(repository);
if (info == null) return null;
String format = ((JsonPrimitive) info.get("format")).getContent();
String type = ((JsonPrimitive) info.get("type")).getContent();
MessageEmbed embed = CommandUtil.getEmbed()
.setTitle(user, nexusUrl + "/#browse/browse:" + repository)
.setDescription("Information about the Nexus Repository.")
.addField("Format", format, true)
.addField("Type", type, true)
.setTimestamp(Instant.now())
.build();
return embed;
}
}
@VisibleForTesting
static class Remove extends BotCommand {
public Remove(CodeMCBot bot) {
super(bot);
this.name = "remove";
this.help = "Remove a user from a CodeMC Service.";
this.allowedRoles = bot.getConfigHandler().getLongList("allowed_roles", "commands", "codemc");
this.options = List.of(
new OptionData(OptionType.STRING, "username", "The Jenkins/Nexus username of the user.").setRequired(true)
);
}
@Override
public void withModalReply(SlashCommandEvent event) {
}
@Override
public void withHookReply(InteractionHook hook, SlashCommandEvent event, Guild guild, Member member) {
String username = event.getOption("username", null, OptionMapping::getAsString);
if (username == null || username.isEmpty()) {
CommandUtil.EmbedReply.from(hook).error("Invalid Jenkins User provided!").send();
return;
}
if (JenkinsAPI.getJenkinsUser(username).isBlank()) {
CommandUtil.EmbedReply.from(hook).error("The user does not have a Jenkins account!").send();
return;
}
User dbUser = DatabaseAPI.getUser(username);
DatabaseAPI.removeUser(username);
JenkinsAPI.deleteUser(username);
NexusAPI.deleteNexus(username);
if (dbUser == null) {
CommandUtil.EmbedReply.from(hook).success("Successfully removed " + username + " from the CodeMC Services!").send();
return;
}
long id = dbUser.getDiscord();
Member user = guild.getMemberById(id);
if (user == null) {
CommandUtil.EmbedReply.from(hook).success("Successfully removed " + username + " from the CodeMC Services!").send();
return;
}
Role authorRole = guild.getRoleById(bot.getConfigHandler().getLong("author_role"));
if (authorRole == null) {
CommandUtil.EmbedReply.from(hook).error("The Author role is not set up correctly!").send();
return;
}
boolean hasAuthor = user.getRoles().stream()
.anyMatch(role -> role.getIdLong() == authorRole.getIdLong());
if (!hasAuthor) {
CommandUtil.EmbedReply.from(hook).error("The user is not an Author!").send();
return;
}
guild.removeRoleFromMember(user, authorRole)
.reason("[Access Request] Author Status revoked by " + member.getUser().getEffectiveName())
.queue(
v -> CommandUtil.EmbedReply.from(hook)
.success("Revoked Author Status from " + user.getUser().getEffectiveName() + "!")
.send(),
new ErrorHandler()
.handle(
ErrorResponse.MISSING_PERMISSIONS,
e -> CommandUtil.EmbedReply.from(hook)
.appendWarning("I lack the `Manage Roles` permission to remove the role.")
.send()
)
);
}
}
@VisibleForTesting
static class Validate extends BotCommand{
public Validate(CodeMCBot bot) {
super(bot);
this.name = "validate";
this.help = "Validates the existence of current API services for specific users.";
this.allowedRoles = bot.getConfigHandler().getLongList("allowed_roles", "commands", "codemc");
this.options = List.of(
new OptionData(OptionType.STRING, "username", "Target Username to validate. When left blank, validates all existing Jenkins Users.")
);
}
@Override
public void withModalReply(SlashCommandEvent event) {}
@Override
public void withHookReply(InteractionHook hook, SlashCommandEvent event, Guild guild, Member member) {
AtomicInteger count = new AtomicInteger(0);
AtomicBoolean success = new AtomicBoolean(true);
String username = event.getOption("username", null, OptionMapping::getAsString);
if (username == null) {
CommandUtil.EmbedReply.from(hook)
.success("Validating all Jenkins Users...")
.send();
JenkinsAPI.getAllJenkinsUsers().forEach(user -> {
if (success.get())
success.set(validate(null, user, count));
});
} else {
success.set(validate(hook, username, count));
if (!success.get()) return;
}
if (success.get())
CommandUtil.EmbedReply.from(hook)
.success("Successfully validated " + count.get() + " User(s)")
.send();
else
CommandUtil.EmbedReply.from(hook)
.error("Failed to validate user(s)!")
.send();
}
private boolean validate(InteractionHook hook, String username, AtomicInteger count) {
boolean success = true;
String password = APIUtil.newPassword();
String jenkins = JenkinsAPI.getJenkinsUser(username);
boolean noJenkins = jenkins == null || jenkins.isEmpty();
if (noJenkins)
success &= JenkinsAPI.createJenkinsUser(username, password, APIUtil.isGroup(username));
JenkinsAPI.checkUserConfig(username);
JenkinsAPI.checkCredentials(username, password);
JsonObject info = NexusAPI.getNexusRepository(username);
if (info == null || info.isEmpty()) {
success &= APIUtil.createNexus(hook, username, password);
if (!noJenkins)
success &= JenkinsAPI.changeJenkinsPassword(username, password);
}
count.incrementAndGet();
return success;
}
}
@VisibleForTesting
static class Link extends BotCommand{
public Link(CodeMCBot bot) {
super(bot);
this.name = "link";
this.help = "Links a Discord User to a Jenkins/Nexus User. If it currently exists, it will be overridden.";
this.allowedRoles = bot.getConfigHandler().getLongList("allowed_roles", "commands", "codemc");
this.options = List.of(
new OptionData(OptionType.STRING, "username", "The Jenkins user to validate to.").setRequired(true),
new OptionData(OptionType.USER, "discord", "The discord user to link the account to.").setRequired(true)
);
}
@Override
public void withModalReply(SlashCommandEvent event) {}
@Override
public void withHookReply(InteractionHook hook, SlashCommandEvent event, Guild guild, Member member) {
String username = event.getOption("username", null, OptionMapping::getAsString);
Member target = event.getOption("discord", null, OptionMapping::getAsMember);
if (username == null || username.isEmpty()) {
CommandUtil.EmbedReply.from(hook).error("Invalid Jenkins User provided!").send();
return;
}
if (JenkinsAPI.getJenkinsUser(username).isBlank()) {
CommandUtil.EmbedReply.from(hook).error("The user does not have a Jenkins account!").send();
return;
}
if (target == null) {
CommandUtil.EmbedReply.from(hook).error("Invalid Discord User provided!").send();
return;
}
Role authorRole = guild.getRoleById(bot.getConfigHandler().getLong("author_role"));
if (authorRole == null) {
CommandUtil.EmbedReply.from(hook).error("The Author role is not set up correctly!").send();
return;
}
boolean hasAuthor = target.getRoles().stream().anyMatch(role -> role.getIdLong() == authorRole.getIdLong());
if (!hasAuthor) {
CommandUtil.EmbedReply.from(hook).error("The user is not an Author!").send();
return;
}
if (DatabaseAPI.getUser(username) == null)
DatabaseAPI.addUser(username, target.getIdLong());
else
DatabaseAPI.updateUser(username, target.getIdLong());
CommandUtil.EmbedReply.from(hook).success("Linked Discord User " + target.getUser().getEffectiveName() + " to Jenkins User " + username + "!").send();
}
}
@VisibleForTesting
static class Unlink extends BotCommand {
public Unlink(CodeMCBot bot) {
super(bot);
this.name = "unlink";
this.help = "Unlinks a discord user from their Jenkins/Nexus account.";
this.allowedRoles = bot.getConfigHandler().getLongList("allowed_roles", "commands", "codemc");
this.options = List.of(
new OptionData(OptionType.USER, "discord", "The discord user to unlink.").setRequired(true),
new OptionData(OptionType.STRING, "username", "The Jenkins user to unlink from. Use if the discord user is linked to multiple accounts.").setRequired(false)
);
}
@Override
public void withModalReply(SlashCommandEvent event) {}
@Override
public void withHookReply(InteractionHook hook, SlashCommandEvent event, Guild guild, Member member) {
Member target = event.getOption("discord", null, OptionMapping::getAsMember);
String userTarget = event.getOption("username", null, OptionMapping::getAsString);
if (target == null) {
CommandUtil.EmbedReply.from(hook).error("Invalid Discord User provided!").send();
return;
}
String username = DatabaseAPI.getAllUsers().stream()
.filter(user -> user.getDiscord() == target.getIdLong())
.map(User::getUsername)
.filter(user -> userTarget == null || user.equals(userTarget))
.findFirst()
.orElse(null);
if (username == null) {
if (userTarget == null)
CommandUtil.EmbedReply.from(hook).error("The user is not linked to any Jenkins/Nexus account!").send();
else
CommandUtil.EmbedReply.from(hook).error("The user is not linked to the specified Jenkins/Nexus account!").send();
return;
}
if (DatabaseAPI.getUser(username) == null) {
CommandUtil.EmbedReply.from(hook).error("The user is not linked to any Jenkins/Nexus account!").send();
return;
}
DatabaseAPI.removeUser(username);
CommandUtil.EmbedReply.from(hook).success("Unlinked Discord User " + target.getUser().getEffectiveName() + " from their Jenkins/Nexus account!").send();
}
}
@VisibleForTesting
static class ChangePassword extends BotCommand {
public ChangePassword(CodeMCBot bot) {
super(bot);
this.name = "change-password";
this.help = "Regenerates your Nexus Credentials.";
this.options = List.of(
new OptionData(OptionType.STRING, "username", "The name of the account to regenerate, if you have multiple. Defaults to the first one found.").setRequired(false)
);
}
@Override
public void withModalReply(SlashCommandEvent event) {}
@Override
public void withHookReply(InteractionHook hook, SlashCommandEvent event, Guild guild, Member member) {
Role authorRole = guild.getRoleById(bot.getConfigHandler().getLong("author_role"));
String target = event.getOption("username", null, OptionMapping::getAsString);
if (authorRole == null) {
CommandUtil.EmbedReply.from(hook).error("The Author role is not set up correctly!").send();
return;
}
boolean hasAuthor = member.getRoles().stream().anyMatch(role -> role.getIdLong() == authorRole.getIdLong());
if (!hasAuthor) {
CommandUtil.EmbedReply.from(hook).error("Only Authors can regenerate their credentials.").send();
return;
}
String username = DatabaseAPI.getAllUsers().stream()
.filter(user -> user.getDiscord() == member.getIdLong())
.map(User::getUsername)
.filter(user -> target == null || user.equals(target))
.findFirst()
.orElse(null);
if (username == null) {
if (target == null)
CommandUtil.EmbedReply.from(hook).error("You are not linked to any Jenkins/Nexus accounts!").send();
else
CommandUtil.EmbedReply.from(hook).error("You are not linked to the specified Jenkins/Nexus account!").send();
return;
}
if (JenkinsAPI.getJenkinsUser(username).isBlank()) {
CommandUtil.EmbedReply.from(hook).error("You do not have a Jenkins account!").send();
return;
}
String password = APIUtil.newPassword();
boolean success = APIUtil.changePassword(hook, username, password);
if (!success) return;
CommandUtil.EmbedReply.from(hook)
.success("Successfully changed your password!")
.send();
}
}
@VisibleForTesting
static class CreateUser extends BotCommand{
public CreateUser(CodeMCBot bot) {
super(bot);
this.name = "createuser";
this.help = "Creates a new user in the Jenkins/Nexus services.";
this.allowedRoles = bot.getConfigHandler().getLongList("allowed_roles", "commands", "codemc");
this.options = List.of(
new OptionData(OptionType.STRING, "username", "The name of Jenkins user to create.").setRequired(true),
new OptionData(OptionType.USER, "discord", "The discord user to link the account to.").setRequired(true)
);
}
@Override
public void withModalReply(SlashCommandEvent event) {}
@Override
public void withHookReply(InteractionHook hook, SlashCommandEvent event, Guild guild, Member member) {
String username = event.getOption("username", null, OptionMapping::getAsString);
Member target = event.getOption("discord", null, OptionMapping::getAsMember);
if (username == null || username.isEmpty()) {
CommandUtil.EmbedReply.from(hook).error("Invalid Username provided!").send();
return;
}
if (!JenkinsAPI.getJenkinsUser(username).isBlank()) {
CommandUtil.EmbedReply.from(hook).error("A user with that username already exists.").send();
return;
}
if (target == null) {
CommandUtil.EmbedReply.from(hook).error("Invalid Discord User provided!").send();
return;
}
Role authorRole = guild.getRoleById(bot.getConfigHandler().getLong("author_role"));
if (authorRole == null) {
CommandUtil.EmbedReply.from(hook).error("The Author role is not set up correctly!").send();
return;
}
boolean hasAuthor = target.getRoles().stream().anyMatch(role -> role.getIdLong() == authorRole.getIdLong());
if (!hasAuthor) {
guild.addRoleToMember(target, authorRole)
.reason("[Access Request] Author Status granted by " + member.getUser().getEffectiveName())
.queue(
v -> CommandUtil.EmbedReply.from(hook)
.success("Granted Author Status to " + target.getUser().getEffectiveName() + "!")
.send(),
new ErrorHandler()
.handle(
ErrorResponse.MISSING_PERMISSIONS,
e -> CommandUtil.EmbedReply.from(hook)
.appendWarning("I lack the `Manage Roles` permission to add the role.")
.send()
)
);
}
String password = APIUtil.newPassword();
DatabaseAPI.addUser(username, target.getIdLong());
JenkinsAPI.createJenkinsUser(username, password, APIUtil.isGroup(username));
APIUtil.createNexus(hook, username, password);
CommandUtil.EmbedReply.from(hook).success("Successfully created user " + username + " and linked it to " + target.getUser().getEffectiveName() + "!").send();
LOGGER.info("Created user '" + username + "' in the Jenkins/Nexus services.");
}
}
@VisibleForTesting
static class DeleteUser extends BotCommand{
public DeleteUser(CodeMCBot bot) {
super(bot);
this.name = "deluser";
this.help = "Deletes a user in the Jenkins/Nexus services. Does not affect discord roles.";
this.allowedRoles = bot.getConfigHandler().getLongList("allowed_roles", "commands", "codemc");
this.options = List.of(
new OptionData(OptionType.STRING, "username", "The name of Jenkins user to delete.").setRequired(true)
);
}
@Override
public void withModalReply(SlashCommandEvent event) {}
@Override
public void withHookReply(InteractionHook hook, SlashCommandEvent event, Guild guild, Member member) {
String username = event.getOption("username", null, OptionMapping::getAsString);
if (username == null || username.isEmpty()) {
CommandUtil.EmbedReply.from(hook).error("Invalid Username provided!").send();
return;
}
if (JenkinsAPI.getJenkinsUser(username).isBlank()) {
CommandUtil.EmbedReply.from(hook).error("The user does not exist!").send();
return;
}
DatabaseAPI.removeUser(username);
JenkinsAPI.deleteUser(username);
NexusAPI.deleteNexus(username);
CommandUtil.EmbedReply.from(hook).success("Successfully deleted user " + username + "!").send();
LOGGER.info("Deleted user '" + username + "' from the Jenkins/Nexus services.");
}
}
}