Skip to content

Commit 1ffaec8

Browse files
committed
apply fix from boss
1 parent 8f13b27 commit 1ffaec8

File tree

2 files changed

+8
-3
lines changed

2 files changed

+8
-3
lines changed

src/main/java/net/discordjug/javabot/data/config/ReflectionUtils.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@ private static Field findDeclaredField(Class<?> cl, String name) throws NoSuchFi
8484
* @throws IllegalAccessException If the field cannot be set.
8585
*/
8686
public static Object set(@NotNull Field field, @NotNull Object parent, @NotNull String s) throws IllegalAccessException {
87-
Object value = GsonUtils.fromJson(s, field.getGenericType());
87+
Object value = field.getType() == String.class ? s : GsonUtils.fromJson(s, field.getGenericType());
8888
field.set(parent, value);
8989
return value;
9090
}

src/main/java/net/discordjug/javabot/systems/configuration/SetConfigSubcommand.java

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -59,11 +59,16 @@ public InteractionCallbackAction<?> handleConfigSubcommand(@Nonnull SlashCommand
5959
if (resolved == null) {
6060
return Responses.error(event, "Config `%s` not found", property);
6161
}
62-
String json = GsonUtils.toJson(resolved);
62+
String value;
63+
if (resolved instanceof String s) {
64+
value = s;
65+
} else {
66+
value = GsonUtils.toJson(resolved);
67+
}
6368
return event.replyModal(
6469
Modal.create(ComponentIdBuilder.build("config-set", property), "Change configuration value")
6570
.addComponents(Label.of("new value", TextInput.create("value", TextInputStyle.PARAGRAPH)
66-
.setValue(json)
71+
.setValue(value)
6772
.build()))
6873
.build());
6974
}

0 commit comments

Comments
 (0)