use of net.dv8tion.jda.core.events.guild.member.GuildMemberRoleAddEvent in project MantaroBot by Mantaro.
the class MantaroListener method onEvent.
@Override
public void onEvent(Event event) {
if (event instanceof ShardMonitorEvent) {
if (MantaroBot.getInstance().getShardedMantaro().getShards()[shardId].getEventManager().getLastJDAEventTimeDiff() > 30000)
return;
((ShardMonitorEvent) event).alive(shardId, ShardMonitorEvent.MANTARO_LISTENER);
return;
}
if (event instanceof GuildMessageReceivedEvent) {
MantaroBot.getInstance().getStatsClient().increment("messages_received");
GuildMessageReceivedEvent e = (GuildMessageReceivedEvent) event;
onMessage(e);
return;
}
if (event instanceof GuildMemberJoinEvent) {
shard.getThreadPool().execute(() -> onUserJoin((GuildMemberJoinEvent) event));
return;
}
if (event instanceof GuildMemberLeaveEvent) {
shard.getThreadPool().execute(() -> onUserLeave((GuildMemberLeaveEvent) event));
return;
}
// Doesn't run on the thread pool as there's no need for it.
if (event instanceof GuildMemberRoleAddEvent) {
// It only runs on the thread pool if needed.
handleNewPatron((GuildMemberRoleAddEvent) event);
}
if (event instanceof GuildMessageUpdateEvent) {
logEdit((GuildMessageUpdateEvent) event);
return;
}
if (event instanceof GuildMessageDeleteEvent) {
logDelete((GuildMessageDeleteEvent) event);
return;
}
if (event instanceof GuildUnbanEvent) {
logUnban((GuildUnbanEvent) event);
return;
}
if (event instanceof GuildBanEvent) {
logBan((GuildBanEvent) event);
return;
}
// Internal events
if (event instanceof GuildJoinEvent) {
GuildJoinEvent e = (GuildJoinEvent) event;
if (e.getGuild().getSelfMember().getJoinDate().isBefore(OffsetDateTime.now().minusSeconds(30)))
return;
onJoin(e);
if (MantaroCore.hasLoadedCompletely()) {
MantaroBot.getInstance().getStatsClient().gauge("guilds", MantaroBot.getInstance().getGuildCache().size());
MantaroBot.getInstance().getStatsClient().gauge("users", MantaroBot.getInstance().getUserCache().size());
}
return;
}
if (event instanceof GuildLeaveEvent) {
onLeave((GuildLeaveEvent) event);
if (MantaroCore.hasLoadedCompletely()) {
MantaroBot.getInstance().getStatsClient().gauge("guilds", MantaroBot.getInstance().getGuildCache().size());
MantaroBot.getInstance().getStatsClient().gauge("users", MantaroBot.getInstance().getUserCache().size());
}
return;
}
// debug
if (event instanceof StatusChangeEvent) {
logStatusChange((StatusChangeEvent) event);
return;
}
if (event instanceof DisconnectEvent) {
onDisconnect((DisconnectEvent) event);
return;
}
if (event instanceof ExceptionEvent) {
MantaroBot.getInstance().getStatsClient().increment("exceptions");
onException((ExceptionEvent) event);
return;
}
if (event instanceof HttpRequestEvent) {
MantaroBot.getInstance().getStatsClient().incrementCounter("http_requests");
return;
}
if (event instanceof ReconnectedEvent) {
MantaroBot.getInstance().getStatsClient().increment("shard.reconnect");
MantaroBot.getInstance().getStatsClient().recordEvent(com.timgroup.statsd.Event.builder().withTitle("shard.reconnect").withText("Shard reconnected").withDate(new Date()).build());
return;
}
if (event instanceof ResumedEvent) {
MantaroBot.getInstance().getStatsClient().increment("shard.resume");
MantaroBot.getInstance().getStatsClient().recordEvent(com.timgroup.statsd.Event.builder().withTitle("shard.resume").withText("Shard resumed").withDate(new Date()).build());
}
}
Aggregations