Skip to content

Commit 011f09a

Browse files
committed
Added @Inject and @component for JShell
1 parent c1acab7 commit 011f09a

File tree

3 files changed

+23
-1
lines changed

3 files changed

+23
-1
lines changed

api/src/main/java/com/javadiscord/jdi/core/api/ChannelRequest.java

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
import com.javadiscord.jdi.core.models.invite.Invite;
1010
import com.javadiscord.jdi.core.models.message.Message;
1111
import com.javadiscord.jdi.core.models.message.MessageReaction;
12+
import com.javadiscord.jdi.core.models.message.embed.Embed;
1213
import com.javadiscord.jdi.core.models.user.User;
1314
import com.javadiscord.jdi.internal.api.channel.*;
1415

@@ -49,6 +50,18 @@ public AsyncResponse<Message> createMessage(CreateMessageBuilder builder) {
4950
return responseParser.callAndParse(Message.class, builder.build());
5051
}
5152

53+
public AsyncResponse<Message> sendMessage(long channelId, String message) {
54+
return responseParser.callAndParse(
55+
Message.class, new CreateMessageBuilder(channelId).content(message).build()
56+
);
57+
}
58+
59+
public AsyncResponse<Message> sendEmbed(long channelId, Embed... embeds) {
60+
return responseParser.callAndParse(
61+
Message.class, new CreateMessageBuilder(channelId).embeds(embeds).build()
62+
);
63+
}
64+
5265
public AsyncResponse<MessageReaction> createReaction(
5366
long channelId,
5467
long messageId,

example/lj-discord-bot/src/main/java/com/javadiscord/bot/Main.java

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
package com.javadiscord.bot;
22

3+
import com.javadiscord.bot.commands.slash.jshell.JShellService;
34
import com.javadiscord.bot.utils.chatgpt.ChatGPT;
45
import com.javadiscord.jdi.core.Discord;
56
import com.javadiscord.jdi.core.annotations.Component;
@@ -14,4 +15,9 @@ public static void main(String[] args) {
1415
public static ChatGPT chatGpt() {
1516
return new ChatGPT();
1617
}
18+
19+
@Component
20+
public static JShellService jShellService() {
21+
return new JShellService();
22+
}
1723
}

example/lj-discord-bot/src/main/java/com/javadiscord/bot/commands/slash/jshell/JShellCommand.java

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,14 +4,17 @@
44

55
import com.javadiscord.jdi.core.CommandOptionType;
66
import com.javadiscord.jdi.core.annotations.CommandOption;
7+
import com.javadiscord.jdi.core.annotations.Inject;
78
import com.javadiscord.jdi.core.annotations.SlashCommand;
89
import com.javadiscord.jdi.core.interaction.SlashCommandEvent;
910
import com.javadiscord.jdi.core.models.message.embed.Embed;
1011
import com.javadiscord.jdi.core.models.message.embed.EmbedAuthor;
1112
import com.javadiscord.jdi.core.models.user.User;
1213

1314
public class JShellCommand {
14-
private final JShellService jShellService = new JShellService();
15+
16+
@Inject
17+
private JShellService jShellService;
1518

1619
@SlashCommand(
1720
name = "jshell", description = "Run Java code using JShell", options = {

0 commit comments

Comments
 (0)