Save current Discord user in Discord service

Signed-off-by: Tomas Slusny <slusnucky@gmail.com>
This commit is contained in:
Tomas Slusny
2019-01-26 13:54:23 +01:00
committed by Adam
parent c198433bb6
commit 6a93ee2ffe

View File

@@ -29,6 +29,7 @@ import java.util.concurrent.ScheduledExecutorService;
import java.util.concurrent.TimeUnit;
import javax.inject.Inject;
import javax.inject.Singleton;
import lombok.Getter;
import lombok.extern.slf4j.Slf4j;
import net.runelite.client.RuneLiteProperties;
import net.runelite.client.discord.events.DiscordDisconnected;
@@ -55,6 +56,9 @@ public class DiscordService implements AutoCloseable
// Hold a reference to the event handlers to prevent the garbage collector from deleting them
private final DiscordEventHandlers discordEventHandlers;
@Getter
private DiscordUser currentUser;
@Inject
private DiscordService(
final EventBus eventBus,
@@ -190,6 +194,7 @@ public class DiscordService implements AutoCloseable
private void ready(DiscordUser user)
{
log.info("Discord RPC service is ready with user {}.", user.username);
currentUser = user;
eventBus.post(new DiscordReady(
user.userId,
user.username,
@@ -204,6 +209,7 @@ public class DiscordService implements AutoCloseable
private void errored(int errorCode, String message)
{
log.warn("Discord error: {} - {}", errorCode, message);
eventBus.post(new DiscordErrored(errorCode, message));
}