Search in sources :

Example 1 with User

use of sx.blah.discord.handle.impl.obj.User in project Discord4J by Discord4J.

the class ShardImpl method updatePresence.

private void updatePresence(StatusType status, ActivityType type, String text, String streamUrl) {
    checkLoggedIn("update presence");
    if (streamUrl != null) {
        if (!DiscordUtils.STREAM_URL_PATTERN.matcher(streamUrl).matches()) {
            throw new IllegalArgumentException("Stream URL must be a twitch.tv url.");
        }
    }
    IUser ourUser = getClient().getOurUser();
    IPresence oldPresence = ourUser.getPresence();
    IPresence newPresence = new Presence(text, streamUrl, status, type);
    if (!newPresence.equals(oldPresence)) {
        ((User) ourUser).setPresence(newPresence);
        getClient().getDispatcher().dispatch(new PresenceUpdateEvent(ourUser, oldPresence, newPresence));
    }
    ws.send(GatewayOps.STATUS_UPDATE, new PresenceUpdateRequest(status, type, text, streamUrl));
}
Also used : User(sx.blah.discord.handle.impl.obj.User) PresenceUpdateRequest(sx.blah.discord.api.internal.json.requests.PresenceUpdateRequest) Presence(sx.blah.discord.handle.impl.obj.Presence) PresenceUpdateEvent(sx.blah.discord.handle.impl.events.user.PresenceUpdateEvent)

Aggregations

PresenceUpdateRequest (sx.blah.discord.api.internal.json.requests.PresenceUpdateRequest)1 PresenceUpdateEvent (sx.blah.discord.handle.impl.events.user.PresenceUpdateEvent)1 Presence (sx.blah.discord.handle.impl.obj.Presence)1 User (sx.blah.discord.handle.impl.obj.User)1