Skip to content

Commit 5dd7dd4

Browse files
committed
Spotless...
1 parent c95f899 commit 5dd7dd4

File tree

4 files changed

+43
-20
lines changed

4 files changed

+43
-20
lines changed

annotations/src/main/java/com/javadiscord/jdi/core/processor/SlashCommandLoader.java

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,10 +27,12 @@ private void loadInteractionListeners() {
2727
try {
2828

2929
String name = ClassFileUtil.getClassName(classFile);
30-
if(name.contains("io.netty")
30+
if (
31+
name.contains("io.netty")
3132
|| name.contains("org.apache")
3233
|| name.contains("io.vertx")
33-
|| name.contains("com.fasterxml")) {
34+
|| name.contains("com.fasterxml")
35+
) {
3436
continue;
3537
}
3638

core/src/main/java/com/javadiscord/jdi/core/Discord.java

Lines changed: 22 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -125,17 +125,22 @@ private void registerLoadedAnnotationsWithDiscord() {
125125
loadedSlashCommands.forEach((commandName, slashCommandClassInstance) -> {
126126
try {
127127
Class<?> slashCommandClassInstanceClass = slashCommandClassInstance.getClass();
128-
Method method = (Method) slashCommandClassInstanceClass
128+
Method method =
129+
(Method) slashCommandClassInstanceClass
129130
.getMethod("method")
130131
.invoke(slashCommandClassInstance);
131132

132133
Annotation[] annotations = method.getAnnotations();
133134
for (Annotation annotation : annotations) {
134-
if(annotation.annotationType().getName().equals("com.javadiscord.jdi.core.annotations.SlashCommand")) {
135+
if (
136+
annotation.annotationType().getName()
137+
.equals("com.javadiscord.jdi.core.annotations.SlashCommand")
138+
) {
135139
Method nameMethod = annotation.annotationType().getMethod("name");
136140
String name = (String) nameMethod.invoke(annotation);
137141

138-
Method descriptionMethod = annotation.annotationType().getMethod("description");
142+
Method descriptionMethod =
143+
annotation.annotationType().getMethod("description");
139144
String description = (String) descriptionMethod.invoke(annotation);
140145

141146
Method optionsMethod = annotation.annotationType().getMethod("options");
@@ -147,8 +152,10 @@ private void registerLoadedAnnotationsWithDiscord() {
147152
Method optionNameMethod = option.getClass().getMethod("name");
148153
String optionName = (String) optionNameMethod.invoke(option);
149154

150-
Method optionDescriptionMethod = option.getClass().getMethod("description");
151-
String optionDescription = (String) optionDescriptionMethod.invoke(option);
155+
Method optionDescriptionMethod =
156+
option.getClass().getMethod("description");
157+
String optionDescription =
158+
(String) optionDescriptionMethod.invoke(option);
152159

153160
Method optionTypeMethod = option.getClass().getMethod("type");
154161
Enum<?> optionType = (Enum<?>) optionTypeMethod.invoke(option);
@@ -157,11 +164,14 @@ private void registerLoadedAnnotationsWithDiscord() {
157164
Method optionRequiredMethod = option.getClass().getMethod("required");
158165
boolean optionRequired = (boolean) optionRequiredMethod.invoke(option);
159166

160-
builder.addOption(new CommandOption(
167+
builder.addOption(
168+
new CommandOption(
161169
optionName,
162170
optionDescription,
163171
CommandOptionType.fromName(optionTypeValue),
164-
optionRequired));
172+
optionRequired
173+
)
174+
);
165175
}
166176

167177
createInteractionRequests.add(builder);
@@ -208,7 +218,11 @@ private void loadSlashCommands() {
208218
if (constructor.getParameterCount() == 1) {
209219
Parameter parameters = constructor.getParameters()[0];
210220
if (parameters.getType().equals(Map.class)) {
211-
eventListeners.add(new InteractionEventHandler(constructor.newInstance(loadedSlashCommands)));
221+
eventListeners.add(
222+
new InteractionEventHandler(
223+
constructor.newInstance(loadedSlashCommands)
224+
)
225+
);
212226
return;
213227
}
214228
return;

core/src/main/java/com/javadiscord/jdi/core/interaction/InteractionEventHandler.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
import com.javadiscord.jdi.core.EventListener;
66
import com.javadiscord.jdi.core.Guild;
77
import com.javadiscord.jdi.core.models.guild.Interaction;
8+
89
import org.apache.logging.log4j.LogManager;
910
import org.apache.logging.log4j.Logger;
1011

@@ -29,7 +30,7 @@ public void onInteractionCreate(Interaction interaction, Guild guild) {
2930
Object commandClassMethodInstance =
3031
getSlashCommandClassMethod.invoke(slashCommandLoader, command);
3132

32-
if(commandClassMethodInstance == null) {
33+
if (commandClassMethodInstance == null) {
3334
LOGGER.warn("No handler found for /{} command", command);
3435
return;
3536
}

example/echo-bot/src/main/java/com/javadiscord/jdi/example/ExampleSlashCommand.java

Lines changed: 15 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -9,16 +9,22 @@
99
public class ExampleSlashCommand {
1010

1111
@SlashCommand(
12-
name = "quiz",
13-
description = "A fun Java quiz",
14-
options = {
15-
@CommandOption(name = "q1", description = "What is an Integer?", type = CommandOptionType.STRING),
16-
@CommandOption(name = "q2", description = "What package is List in?", type = CommandOptionType.STRING),
17-
@CommandOption(name = "q3", description = "What does JVM stand for?", type = CommandOptionType.STRING),
18-
@CommandOption(name = "q4", description = "Is a String a primitive?", type = CommandOptionType.STRING),
19-
}
12+
name = "quiz", description = "A fun Java quiz", options = {
13+
@CommandOption(
14+
name = "q1", description = "What is an Integer?", type = CommandOptionType.STRING
15+
),
16+
@CommandOption(
17+
name = "q2", description = "What package is List in?", type = CommandOptionType.STRING
18+
),
19+
@CommandOption(
20+
name = "q3", description = "What does JVM stand for?", type = CommandOptionType.STRING
21+
),
22+
@CommandOption(
23+
name = "q4", description = "Is a String a primitive?", type = CommandOptionType.STRING
24+
),
25+
}
2026
)
2127
public void handle() {
22-
//TODO: Logic to handle the slash command
28+
// TODO: Logic to handle the slash command
2329
}
2430
}

0 commit comments

Comments
 (0)