File tree Expand file tree Collapse file tree 2 files changed +21
-3
lines changed
example/echo-bot/src/main/java/com/javadiscord/jdi/example
models/src/main/java/com/javadiscord/jdi/core/models/application Expand file tree Collapse file tree 2 files changed +21
-3
lines changed Original file line number Diff line number Diff line change 1
1
package com .javadiscord .jdi .example ;
2
2
3
3
import com .javadiscord .jdi .core .CommandOptionType ;
4
+ import com .javadiscord .jdi .core .Guild ;
4
5
import com .javadiscord .jdi .core .annotations .CommandOption ;
5
6
import com .javadiscord .jdi .core .annotations .SlashCommand ;
6
7
import com .javadiscord .jdi .core .interaction .SlashCommandEvent ;
@@ -24,10 +25,10 @@ public class ExampleSlashCommand {
24
25
),
25
26
}
26
27
)
27
- public void handle (SlashCommandEvent event ) {
28
+ public void handle (SlashCommandEvent event , Guild guild ) {
28
29
ApplicationCommandOption [] options = event .options ();
29
30
for (ApplicationCommandOption option : options ) {
30
- System .out .println ("Received " + option .name () + " value " + option .value ());
31
+ System .out .println ("Received " + option .name () + " value " + option .valueAsString ());
31
32
}
32
33
}
33
34
}
Original file line number Diff line number Diff line change @@ -12,4 +12,21 @@ public record ApplicationCommandOption(
12
12
@ JsonProperty ("value" ) Object value ,
13
13
@ JsonProperty ("options" ) List <ApplicationCommandOption > options ,
14
14
@ JsonProperty ("focused" ) boolean focused
15
- ) {}
15
+ ) {
16
+
17
+ public String valueAsString () {
18
+ return String .valueOf (value );
19
+ }
20
+
21
+ public int valueAsInt () {
22
+ return (int ) value ;
23
+ }
24
+
25
+ public double valueAsDouble () {
26
+ return (double ) value ;
27
+ }
28
+
29
+ public boolean valueAsBoolean () {
30
+ return (boolean ) value ;
31
+ }
32
+ }
You can’t perform that action at this time.
0 commit comments