Search in sources :

Example 1 with DiscordCaptcha

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();
}
Also used : DiscordCaptchaService(gg.projecteden.nexus.models.discord.DiscordCaptchaService) CaptchaResult(gg.projecteden.nexus.models.discord.DiscordCaptcha.CaptchaResult) DiscordCaptcha(gg.projecteden.nexus.models.discord.DiscordCaptcha) Member(net.dv8tion.jda.api.entities.Member)

Example 2 with DiscordCaptcha

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));
    });
}
Also used : DiscordCaptchaService(gg.projecteden.nexus.models.discord.DiscordCaptchaService) DiscordCaptcha(gg.projecteden.nexus.models.discord.DiscordCaptcha) Path(gg.projecteden.nexus.framework.commands.models.annotations.Path) Async(gg.projecteden.annotations.Async) Permission(gg.projecteden.nexus.framework.commands.models.annotations.Permission)

Example 3 with DiscordCaptcha

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);
}
Also used : DiscordCaptchaService(gg.projecteden.nexus.models.discord.DiscordCaptchaService) User(net.dv8tion.jda.api.entities.User) DiscordUser(gg.projecteden.nexus.models.discord.DiscordUser) DiscordCaptcha(gg.projecteden.nexus.models.discord.DiscordCaptcha) Member(net.dv8tion.jda.api.entities.Member) TeamMechanic.getVoiceChannelMember(gg.projecteden.nexus.features.minigames.models.mechanics.multiplayer.teams.TeamMechanic.getVoiceChannelMember) Path(gg.projecteden.nexus.framework.commands.models.annotations.Path) Async(gg.projecteden.annotations.Async) Permission(gg.projecteden.nexus.framework.commands.models.annotations.Permission)

Example 4 with DiscordCaptcha

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);
        }
    });
}
Also used : PrivateChannel(net.dv8tion.jda.api.entities.PrivateChannel) DiscordCaptchaService(gg.projecteden.nexus.models.discord.DiscordCaptchaService) Message(net.dv8tion.jda.api.entities.Message) CaptchaResult(gg.projecteden.nexus.models.discord.DiscordCaptcha.CaptchaResult) DiscordCaptcha(gg.projecteden.nexus.models.discord.DiscordCaptcha) Member(net.dv8tion.jda.api.entities.Member)

Example 5 with DiscordCaptcha

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);
    });
}
Also used : DiscordUser(gg.projecteden.nexus.models.discord.DiscordUser) DiscordCaptchaService(gg.projecteden.nexus.models.discord.DiscordCaptchaService) CaptchaResult(gg.projecteden.nexus.models.discord.DiscordCaptcha.CaptchaResult) DiscordCaptcha(gg.projecteden.nexus.models.discord.DiscordCaptcha) DiscordUserService(gg.projecteden.nexus.models.discord.DiscordUserService)

Aggregations

DiscordCaptcha (gg.projecteden.nexus.models.discord.DiscordCaptcha)5 DiscordCaptchaService (gg.projecteden.nexus.models.discord.DiscordCaptchaService)5 CaptchaResult (gg.projecteden.nexus.models.discord.DiscordCaptcha.CaptchaResult)3 Member (net.dv8tion.jda.api.entities.Member)3 Async (gg.projecteden.annotations.Async)2 Path (gg.projecteden.nexus.framework.commands.models.annotations.Path)2 Permission (gg.projecteden.nexus.framework.commands.models.annotations.Permission)2 DiscordUser (gg.projecteden.nexus.models.discord.DiscordUser)2 TeamMechanic.getVoiceChannelMember (gg.projecteden.nexus.features.minigames.models.mechanics.multiplayer.teams.TeamMechanic.getVoiceChannelMember)1 DiscordUserService (gg.projecteden.nexus.models.discord.DiscordUserService)1 Message (net.dv8tion.jda.api.entities.Message)1 PrivateChannel (net.dv8tion.jda.api.entities.PrivateChannel)1 User (net.dv8tion.jda.api.entities.User)1