Return username on send, add message to close auth page

This commit is contained in:
Norbi Peti 2020-04-28 18:59:50 +02:00
parent 5192999143
commit 112791e926
No known key found for this signature in database
GPG key ID: DBA4C4549A927E56
2 changed files with 3 additions and 4 deletions

View file

@ -50,7 +50,7 @@ public class DCController {
service.deleteSession(user);
String token = UUID.randomUUID().toString();
service.insertSession(new Session(token, Snowflake.of(channel), user));
return "Run the following command:<br/>\ndcsetup \"" + token + "\"";
return "Run the following command:<br/>\ndcsetup \"" + token + "\"\n<br>Then you can close this window.";
}
@GetMapping("/api/users/get")

View file

@ -6,7 +6,6 @@ import discord4j.core.event.domain.message.MessageCreateEvent;
import discord4j.core.object.entity.GuildMessageChannel;
import discord4j.core.object.entity.Member;
import discord4j.core.object.util.Snowflake;
import io.github.norbipeti.gcdc.Application;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Component;
import org.springframework.web.context.request.async.DeferredResult;
@ -43,9 +42,9 @@ public class DiscordService {
client.getChannelById(Snowflake.of(channel)).cast(GuildMessageChannel.class)
.flatMap(ch -> getUsername(user, ch)
.flatMap(name -> ch.createEmbed(ecs -> ecs.setAuthor(name, null, null)
.setColor(Color.BLUE).setDescription(message))))
.setColor(Color.BLUE).setDescription(message)).map(msg -> name)))
.doOnError(result::setErrorResult)
.subscribe(msg -> result.setResult(Application.RESULT_OK));
.subscribe(name -> result.setResult(Map.of("response", "OK", "username", name)));
return result;
}