parent
abd9f39f44
commit
1d8cf6c2d4
4 changed files with 52 additions and 46 deletions
@ -0,0 +1,9 @@ |
|||||||
|
package zoltan.vari.spotify_mixer_discord_bot.config; |
||||||
|
|
||||||
|
public class DiscordBotConstants { |
||||||
|
|
||||||
|
public static final String CREATE_SESSION_COMMAND = "createSession"; |
||||||
|
public static final String CREATE_SESSION_DESCRIPTION = "Creates a spotify mixer session, sends you a link to join the session. It will ask you to first authorize the app to use your spotify data."; |
||||||
|
|
||||||
|
|
||||||
|
} |
@ -0,0 +1,24 @@ |
|||||||
|
package zoltan.vari.spotify_mixer_discord_bot.eventListener; |
||||||
|
|
||||||
|
import discord4j.common.util.Snowflake; |
||||||
|
import discord4j.core.DiscordClient; |
||||||
|
import discord4j.core.GatewayDiscordClient; |
||||||
|
import discord4j.core.event.domain.interaction.ApplicationCommandInteractionEvent; |
||||||
|
import discord4j.core.object.entity.Member; |
||||||
|
import discord4j.core.object.entity.channel.PrivateChannel; |
||||||
|
import discord4j.core.spec.InteractionApplicationCommandCallbackReplyMono; |
||||||
|
import org.springframework.stereotype.Service; |
||||||
|
|
||||||
|
@Service |
||||||
|
public class DiscordCommandService { |
||||||
|
|
||||||
|
public InteractionApplicationCommandCallbackReplyMono processCommand(GatewayDiscordClient gw, DiscordClient client, ApplicationCommandInteractionEvent event){ |
||||||
|
|
||||||
|
PrivateChannel userChannel = event.getInteraction().getUser().getPrivateChannel().block(); |
||||||
|
|
||||||
|
client.getChannelById(userChannel.getId()).createMessage("test").block(); |
||||||
|
return event.reply(event.toString()); |
||||||
|
} |
||||||
|
|
||||||
|
|
||||||
|
} |
@ -1,43 +0,0 @@ |
|||||||
package zoltan.vari.spotify_mixer_discord_bot.eventListener; |
|
||||||
|
|
||||||
import discord4j.core.DiscordClient; |
|
||||||
import discord4j.core.GatewayDiscordClient; |
|
||||||
import discord4j.core.event.domain.interaction.ApplicationCommandInteractionEvent; |
|
||||||
import discord4j.core.event.domain.message.MessageCreateEvent; |
|
||||||
import discord4j.core.object.command.ApplicationCommandOption; |
|
||||||
import discord4j.core.object.entity.Message; |
|
||||||
import discord4j.discordjson.json.ApplicationCommandOptionData; |
|
||||||
import discord4j.discordjson.json.ApplicationCommandRequest; |
|
||||||
import jakarta.annotation.PostConstruct; |
|
||||||
import org.springframework.beans.factory.annotation.Autowired; |
|
||||||
import org.springframework.stereotype.Service; |
|
||||||
|
|
||||||
@Service |
|
||||||
public class DiscordEventListener { |
|
||||||
|
|
||||||
@Autowired |
|
||||||
private GatewayDiscordClient gw; |
|
||||||
|
|
||||||
@Autowired |
|
||||||
private DiscordClient client; |
|
||||||
|
|
||||||
@PostConstruct |
|
||||||
public void init(){ |
|
||||||
ApplicationCommandRequest greetCmdRequest = ApplicationCommandRequest.builder() |
|
||||||
.name("create") |
|
||||||
.description("creates a new spotify mixer room") |
|
||||||
.build(); |
|
||||||
client.getApplicationService() |
|
||||||
.createGlobalApplicationCommand(client.getApplicationId().block(), greetCmdRequest) |
|
||||||
.subscribe(); |
|
||||||
|
|
||||||
gw.on(ApplicationCommandInteractionEvent.class, event -> { |
|
||||||
if (event.getCommandName().equals("greet")) { |
|
||||||
return event.reply("Pong!"); |
|
||||||
} |
|
||||||
return event.reply("default"); |
|
||||||
}).subscribe(); |
|
||||||
} |
|
||||||
|
|
||||||
|
|
||||||
} |
|
Loading…
Reference in new issue