Vatuu / discord-rpc

Java Wrapper of the Discord-RPC Library for Discord Rich Presence.
MIT License
194 stars 42 forks source link

Callback and RPC not running. #42

Open Stanlyhalo opened 4 years ago

Stanlyhalo commented 4 years ago

So I'm trying to log the user username + tag (given my the readme), but it's not running the callback and it's not making my profile show I'm playing something

public void check(Logger LOGGER)
{
    LOGGER.info("Getting USER.");
    DiscordEventHandlers handlers = new DiscordEventHandlers.Builder().setReadyEventHandler((user) -> {
        LOGGER.info("Got USER.");
        LOGGER.info("Welcome " + user.username + "#" + user.discriminator + "!");
    }).build();
    DiscordRPC.discordInitialize( client ID of the bot , handlers, true);
    DiscordRPC.discordRegister( client ID of the bot , "");
}
public DiscordRichPresence createRPC(Logger LOGGER)
{
    DiscordRichPresence rich = new DiscordRichPresence.Builder("This is the current state.").setDetails("These are some details.").build();
    return rich;
}
public void updateRPC(Logger LOGGER, DiscordRichPresence rich)
{
    DiscordRPC.discordRunCallbacks();
    DiscordRPC.discordUpdatePresence(rich);
}

Each function is called from top to bottom, what am I doing wrong?

Edit*: I made the RP work, but the ".setReadyEventListener()" isn't work, here's the event code now (and I do have a thread that loops, and runs "DiscordRPC.discordRunCallbacks();"):

DiscordEventHandlers handlers = new DiscordEventHandlers.Builder().setReadyEventHandler(new ReadyCallback() {
    @Override
    public void apply(DiscordUser user) {
        LOGGER.info("DiscordManager: Got user" + user.username + "#" + user.discriminator);
    }
}).build();
CDFN commented 3 years ago

Facing same issue.