use of sx.blah.discord.handle.impl.obj.Presence 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));
}
Aggregations