use of gg.projecteden.nexus.models.discord.DiscordCaptcha.CaptchaResult in project Nexus by ProjectEdenGG.
the class DiscordCaptchaKickJob method run.
@Override
protected CompletableFuture<JobStatus> run() {
String name = Discord.getName(memberId);
DiscordCaptcha verification = new DiscordCaptchaService().get();
CaptchaResult result = verification.check(memberId);
if (result != CaptchaResult.CONFIRMED) {
Member member = Discord.getGuild().retrieveMemberById(memberId).complete();
if (member != null) {
Discord.staffLog("**[Captcha]** " + name + " - Kicking");
member.kick("Please complete the verification process in your DMs with KodaBear").queue();
} else
Nexus.log("[Captcha] Kick scheduled for " + name + " cancelled, member not found");
}
return completed();
}
use of gg.projecteden.nexus.models.discord.DiscordCaptcha.CaptchaResult in project Nexus by ProjectEdenGG.
the class DiscordCaptchaListener method onMessageReactionAdd.
@Override
public void onMessageReactionAdd(@Nonnull MessageReactionAddEvent event) {
Tasks.async(() -> {
if (event.getChannelType() != ChannelType.PRIVATE)
return;
if (event.getUser() == null) {
Nexus.log("[Captcha] Received reaction from null user");
return;
}
final String id = event.getUser().getId();
DiscordCaptchaService captchaService = new DiscordCaptchaService();
DiscordCaptcha captcha = captchaService.get0();
CaptchaResult result = captcha.check(id);
if (result == CaptchaResult.UNCONFIRMED) {
captcha.confirm(id);
Member member = Discord.getGuild().retrieveMemberById(id).complete();
PrivateChannel complete = event.getUser().openPrivateChannel().complete();
if (member == null) {
Message message = complete.getHistory().getMessageById(event.getMessageId());
if (message == null)
Nexus.warn("[Captcha] Could not find original message");
else
message.editMessage("Account confirmed. You may now join the server again: " + EdenSocialMediaSite.DISCORD.getUrl()).queue();
} else
complete.sendMessage("Account confirmed, thank you!").queue();
captchaService.save(captcha);
}
});
}
use of gg.projecteden.nexus.models.discord.DiscordCaptcha.CaptchaResult in project Nexus by ProjectEdenGG.
the class DiscordCaptchaListener method onGuildMemberJoin.
@Override
public void onGuildMemberJoin(@Nonnull GuildMemberJoinEvent event) {
Tasks.async(() -> {
final String id = event.getUser().getId();
DiscordCaptchaService captchaService = new DiscordCaptchaService();
DiscordCaptcha captcha = captchaService.get0();
CaptchaResult result = captcha.check(id);
if (result == CaptchaResult.CONFIRMED) {
Tasks.waitAsync(1, () -> {
Discord.addRole(id, Role.NERD);
DiscordUser user = new DiscordUserService().getFromUserId(id);
if (user != null)
Discord.addRole(id, Role.VERIFIED);
});
return;
}
Discord.staffLog("**[Captcha]** " + Discord.getName(event.getMember()) + " - Requiring verification");
captcha.require(id);
captchaService.save(captcha);
});
}
Aggregations