Save current Discord user in Discord service
Signed-off-by: Tomas Slusny <slusnucky@gmail.com>
This commit is contained in:
@@ -29,6 +29,7 @@ import java.util.concurrent.ScheduledExecutorService;
|
|||||||
import java.util.concurrent.TimeUnit;
|
import java.util.concurrent.TimeUnit;
|
||||||
import javax.inject.Inject;
|
import javax.inject.Inject;
|
||||||
import javax.inject.Singleton;
|
import javax.inject.Singleton;
|
||||||
|
import lombok.Getter;
|
||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
import net.runelite.client.RuneLiteProperties;
|
import net.runelite.client.RuneLiteProperties;
|
||||||
import net.runelite.client.discord.events.DiscordDisconnected;
|
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
|
// Hold a reference to the event handlers to prevent the garbage collector from deleting them
|
||||||
private final DiscordEventHandlers discordEventHandlers;
|
private final DiscordEventHandlers discordEventHandlers;
|
||||||
|
|
||||||
|
@Getter
|
||||||
|
private DiscordUser currentUser;
|
||||||
|
|
||||||
@Inject
|
@Inject
|
||||||
private DiscordService(
|
private DiscordService(
|
||||||
final EventBus eventBus,
|
final EventBus eventBus,
|
||||||
@@ -190,6 +194,7 @@ public class DiscordService implements AutoCloseable
|
|||||||
private void ready(DiscordUser user)
|
private void ready(DiscordUser user)
|
||||||
{
|
{
|
||||||
log.info("Discord RPC service is ready with user {}.", user.username);
|
log.info("Discord RPC service is ready with user {}.", user.username);
|
||||||
|
currentUser = user;
|
||||||
eventBus.post(new DiscordReady(
|
eventBus.post(new DiscordReady(
|
||||||
user.userId,
|
user.userId,
|
||||||
user.username,
|
user.username,
|
||||||
@@ -204,6 +209,7 @@ public class DiscordService implements AutoCloseable
|
|||||||
|
|
||||||
private void errored(int errorCode, String message)
|
private void errored(int errorCode, String message)
|
||||||
{
|
{
|
||||||
|
log.warn("Discord error: {} - {}", errorCode, message);
|
||||||
eventBus.post(new DiscordErrored(errorCode, message));
|
eventBus.post(new DiscordErrored(errorCode, message));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user