main
zoli 7 months ago
parent 1d8cf6c2d4
commit 3ac0a7479d
  1. 4
      src/main/java/zoltan/vari/spotify_mixer_discord_bot/config/DiscordBotConstants.java
  2. 18
      src/main/java/zoltan/vari/spotify_mixer_discord_bot/eventListener/DiscordCommandService.java
  3. 4
      src/main/resources/application.properties

@ -2,8 +2,8 @@ package zoltan.vari.spotify_mixer_discord_bot.config;
public class DiscordBotConstants { public class DiscordBotConstants {
public static final String CREATE_SESSION_COMMAND = "createSession"; public static final String CREATE_SESSION_COMMAND = "new";
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."; public static final String CREATE_SESSION_DESCRIPTION = "creates new mixer session";
} }

@ -8,15 +8,29 @@ import discord4j.core.object.entity.Member;
import discord4j.core.object.entity.channel.PrivateChannel; import discord4j.core.object.entity.channel.PrivateChannel;
import discord4j.core.spec.InteractionApplicationCommandCallbackReplyMono; import discord4j.core.spec.InteractionApplicationCommandCallbackReplyMono;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import zoltan.vari.spotify_mixer_discord_bot.config.DiscordBotConstants;
@Service @Service
public class DiscordCommandService { public class DiscordCommandService {
public InteractionApplicationCommandCallbackReplyMono processCommand(GatewayDiscordClient gw, DiscordClient client, ApplicationCommandInteractionEvent event){ public InteractionApplicationCommandCallbackReplyMono processCommand(GatewayDiscordClient gw, DiscordClient client, ApplicationCommandInteractionEvent event){
PrivateChannel userChannel = event.getInteraction().getUser().getPrivateChannel().block(); switch(event.getCommandName()){
case DiscordBotConstants.CREATE_SESSION_COMMAND -> {
return createSession(gw, client, event);
}
default -> {
PrivateChannel userChannel = event.getInteraction().getUser().getPrivateChannel().block();
client.getChannelById(userChannel.getId()).createMessage("test").block();
return event.reply(event.toString());
}
}
}
client.getChannelById(userChannel.getId()).createMessage("test").block(); private InteractionApplicationCommandCallbackReplyMono createSession(GatewayDiscordClient gw, DiscordClient client, ApplicationCommandInteractionEvent event) {
PrivateChannel userChannel = event.getInteraction().getUser().getPrivateChannel().block();
client.getChannelById(userChannel.getId()).createMessage("create session result").block();
return event.reply(event.toString()); return event.reply(event.toString());
} }

@ -1,3 +1,5 @@
spring.application.name=spotify-mixer-discord-bot spring.application.name=spotify-mixer-discord-bot
discord.bot.token=MTI5ODI3MzM4NDY1MTU1NDgzNg.G7AacR.wfhywscBK7tj3qkHXBWtC-lN3CguKTf7yTdc7M discord.bot.token=MTI5ODI3MzM4NDY1MTU1NDgzNg.G7AacR.wfhywscBK7tj3qkHXBWtC-lN3CguKTf7yTdc7M
server.port=8081

Loading…
Cancel
Save