use of gg.projecteden.nexus.models.discord.DiscordCaptcha 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 in project Nexus by ProjectEdenGG.
the class DiscordCommand method info.
// TODO Restrospective confirmation checks
@Async
@Path("captcha info")
@Permission(Group.STAFF)
void info() {
DiscordCaptcha captcha = new DiscordCaptchaService().get();
captcha.getUnconfirmed().forEach((id, date) -> {
String name = Discord.getName(id);
send("ID: " + name + " / Date: " + shortDateTimeFormat(date));
});
}
use of gg.projecteden.nexus.models.discord.DiscordCaptcha in project Nexus by ProjectEdenGG.
the class DiscordCommand method unconfirm.
@Async
@Path("captcha unconfirm <id>")
@Permission(Group.STAFF)
void unconfirm(String id) {
DiscordCaptchaService captchaService = new DiscordCaptchaService();
DiscordCaptcha captcha = captchaService.get0();
User user = Bot.KODA.jda().retrieveUserById(id).complete();
Member member = Discord.getGuild().retrieveMemberById(id).complete();
if (user == null)
send(PREFIX + "&cWarning: &3User is null");
if (member == null)
send(PREFIX + "&cWarning: &3Member is null");
String name = Discord.getName(id);
if (!captcha.getConfirmed().containsKey(id))
error(name + " is not confirmed");
captcha.getConfirmed().remove(id);
captchaService.save(captcha);
send(PREFIX + "Unconfirmed " + name);
}
use of gg.projecteden.nexus.models.discord.DiscordCaptcha 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 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