use of tk.ardentbot.rethink.models.Rankable in project Ardent by adamint.
the class Join method onJoinUser.
@SubscribeEvent
public void onJoinUser(GuildMemberJoinEvent event) throws SQLException {
userJoinEvents.add(Instant.now());
Member joined = event.getMember();
User joinedUser = joined.getUser();
Guild guild = event.getGuild();
Role role = DefaultRole.getDefaultRole(guild);
if (role != null) {
try {
guild.getController().addRolesToMember(event.getMember(), role).queue();
} catch (PermissionException ex) {
}
}
Triplet<String, String, String> automessageSettings = Automessage.getMessagesAndChannel(guild);
String channelId = automessageSettings.getA();
String welcome = automessageSettings.getB();
if (channelId != null && welcome != null) {
TextChannel channel = guild.getTextChannelById(channelId);
if (channel != null) {
try {
welcome = welcome.replace("{user}", joinedUser.getAsMention()).replace("{servername}", guild.getName()).replace("{amtusers}", String.valueOf(guild.getMembers().size()));
channel.sendMessage(welcome).queue();
} catch (PermissionException ex) {
}
}
}
GuildModel guildModel = BaseCommand.asPojo(r.table("guilds").get(guild.getId()).run(connection), GuildModel.class);
guildModel.role_permissions.forEach(rolePermission -> {
Rankable rankable = rolePermission.getRankable();
if (rankable != null && rankable.getStartsOnServerJoin()) {
rankable.getQueued().put(joinedUser.getId(), Instant.now().getEpochSecond());
}
});
}
Aggregations