|
|
@ -8,6 +8,9 @@ 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.beans.factory.annotation.Autowired; |
|
|
|
import org.springframework.beans.factory.annotation.Autowired; |
|
|
|
|
|
|
|
import org.springframework.http.HttpEntity; |
|
|
|
|
|
|
|
import org.springframework.http.HttpHeaders; |
|
|
|
|
|
|
|
import org.springframework.http.HttpMethod; |
|
|
|
import org.springframework.http.ResponseEntity; |
|
|
|
import org.springframework.http.ResponseEntity; |
|
|
|
import org.springframework.stereotype.Service; |
|
|
|
import org.springframework.stereotype.Service; |
|
|
|
import org.springframework.web.client.RestTemplate; |
|
|
|
import org.springframework.web.client.RestTemplate; |
|
|
@ -17,6 +20,8 @@ import spotifymixerapi.api.CreateSessionRequest; |
|
|
|
import spotifymixerapi.api.CreateSessionResponse; |
|
|
|
import spotifymixerapi.api.CreateSessionResponse; |
|
|
|
import zoltan.vari.spotify_mixer_discord_bot.config.DiscordBotConstants; |
|
|
|
import zoltan.vari.spotify_mixer_discord_bot.config.DiscordBotConstants; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
import java.util.Collections; |
|
|
|
|
|
|
|
|
|
|
|
@Service |
|
|
|
@Service |
|
|
|
public class DiscordCommandService { |
|
|
|
public class DiscordCommandService { |
|
|
|
|
|
|
|
|
|
|
@ -48,7 +53,14 @@ public class DiscordCommandService { |
|
|
|
createSessionRequest.setDiscordUserName(event.getInteraction().getUser().getUsername()); |
|
|
|
createSessionRequest.setDiscordUserName(event.getInteraction().getUser().getUsername()); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
CreateSessionResponse result = restTemplate.postForEntity(BACK_END_BASE_URL+"/session/create",createSessionRequest, CreateSessionResponse.class).getBody(); |
|
|
|
HttpHeaders headers = new HttpHeaders(); |
|
|
|
|
|
|
|
headers.add("withCredentials","true"); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
HttpEntity<CreateSessionRequest> entity = new HttpEntity<>(createSessionRequest, headers); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
CreateSessionResponse result = restTemplate.exchange(BACK_END_BASE_URL+"/session/create", HttpMethod.POST, entity, CreateSessionResponse.class).getBody(); |
|
|
|
|
|
|
|
|
|
|
|
client.getChannelById(userChannel.getId()).createMessage(result.getUrl()).block(); |
|
|
|
client.getChannelById(userChannel.getId()).createMessage(result.getUrl()).block(); |
|
|
|
return event.reply("Session link sent to your DMs"); |
|
|
|
return event.reply("Session link sent to your DMs"); |
|
|
|