use of org.javacord.core.entity.user.UserImpl in project Javacord by BtoBastian.
the class GuildBanAddHandler method handle.
@Override
public void handle(JsonNode packet) {
api.getPossiblyUnreadyServerById(packet.get("guild_id").asLong()).map(server -> (ServerImpl) server).ifPresent(server -> {
User user = new UserImpl(api, packet.get("user"), (MemberImpl) null, server);
server.removeMember(user.getId());
ServerMemberBanEvent event = new ServerMemberBanEventImpl(server, user);
api.getEventDispatcher().dispatchServerMemberBanEvent(server, server, user, event);
});
}
use of org.javacord.core.entity.user.UserImpl in project Javacord by BtoBastian.
the class GuildMemberRemoveHandler method handle.
@Override
public void handle(JsonNode packet) {
api.getPossiblyUnreadyServerById(packet.get("guild_id").asLong()).map(server -> (ServerImpl) server).ifPresent(server -> {
User user = new UserImpl(api, packet.get("user"), (MemberImpl) null, server);
server.removeMember(user.getId());
server.decrementMemberCount();
ServerMemberLeaveEvent event = new ServerMemberLeaveEventImpl(server, user);
api.getEventDispatcher().dispatchServerMemberLeaveEvent(server, server, user, event);
});
}
use of org.javacord.core.entity.user.UserImpl in project Javacord by BtoBastian.
the class ChannelCreateHandler method handlePrivateChannel.
/**
* Handles a private channel creation.
*
* @param channel The channel data.
*/
private void handlePrivateChannel(JsonNode channel) {
// A CHANNEL_CREATE packet was sent every time a bot account receives a message, see
// https://github.com/discord/discord-api-docs/issues/184 and
// https://github.com/discord/discord-api-docs/issues/2248
UserImpl recipient = new UserImpl(api, channel.get("recipients").get(0), (MemberImpl) null, null);
if (!recipient.getPrivateChannel().isPresent()) {
PrivateChannel privateChannel = new PrivateChannelImpl(api, channel.get("id").asText(), recipient, recipient.getId());
PrivateChannelCreateEvent event = new PrivateChannelCreateEventImpl(privateChannel);
api.getEventDispatcher().dispatchPrivateChannelCreateEvent(api, recipient, event);
}
}
use of org.javacord.core.entity.user.UserImpl in project Javacord by BtoBastian.
the class GuildBanRemoveHandler method handle.
@Override
public void handle(JsonNode packet) {
api.getPossiblyUnreadyServerById(packet.get("guild_id").asLong()).map(server -> (ServerImpl) server).ifPresent(server -> {
User user = new UserImpl(api, packet.get("user"), (MemberImpl) null, server);
ServerMemberUnbanEvent event = new ServerMemberUnbanEventImpl(server, user);
api.getEventDispatcher().dispatchServerMemberUnbanEvent(server, server, user, event);
});
}
use of org.javacord.core.entity.user.UserImpl in project Javacord by BtoBastian.
the class GuildMemberAddHandler method handle.
@Override
public void handle(JsonNode packet) {
api.getPossiblyUnreadyServerById(packet.get("guild_id").asLong()).map(server -> (ServerImpl) server).ifPresent(server -> {
MemberImpl member = server.addMember(packet);
server.incrementMemberCount();
User user = new UserImpl(api, packet.get("user"), member, server);
ServerMemberJoinEvent event = new ServerMemberJoinEventImpl(server, user);
api.getEventDispatcher().dispatchServerMemberJoinEvent(server, server, user, event);
});
}
Aggregations