Search in sources :

Example 1 with NicknameService

use of gg.projecteden.nexus.models.nickname.NicknameService in project Nexus by ProjectEdenGG.

the class NicknameAppCommand method deny.

@Command("Deny a nickname request")
void deny(@Desc("Player") Nickname player, @Desc("Reason") String reason) {
    for (NicknameHistoryEntry entry : player.getNicknameHistory()) {
        if (!entry.isPending())
            continue;
        entry.deny(reason);
        new NicknameService().save(player);
        reply("Successfully denied nickname request");
        return;
    }
    replyEphemeral("No pending nickname request found for " + player.getNickname());
}
Also used : NicknameService(gg.projecteden.nexus.models.nickname.NicknameService) NicknameHistoryEntry(gg.projecteden.nexus.models.nickname.Nickname.NicknameHistoryEntry) Command(gg.projecteden.discord.appcommands.annotations.Command) NexusAppCommand(gg.projecteden.nexus.features.discord.appcommands.NexusAppCommand)

Example 2 with NicknameService

use of gg.projecteden.nexus.models.nickname.NicknameService in project Nexus by ProjectEdenGG.

the class IngameBridgeListener method parseMentions.

public static String parseMentions(String message) {
    if (message != null && message.contains("@")) {
        Matcher matcher = Pattern.compile("@[\\w]+").matcher(message);
        while (matcher.find()) {
            String group = matcher.group();
            String search = group.replace("@", "");
            Nerd nerd = new NerdService().findExact(search);
            if (nerd != null) {
                DiscordUser mentioned = new DiscordUserService().get(nerd);
                if (mentioned.getUserId() != null) {
                    message = message.replace(group, "<@" + mentioned.getUserId() + ">");
                } else {
                    Nickname fromNickname = new NicknameService().getFromNickname(search);
                    if (fromNickname != null) {
                        mentioned = new DiscordUserService().get(fromNickname);
                        if (mentioned.getUserId() != null)
                            message = message.replace(group, "<@" + mentioned.getUserId() + ">");
                    }
                }
            }
        }
    }
    return message;
}
Also used : DiscordUser(gg.projecteden.nexus.models.discord.DiscordUser) Matcher(java.util.regex.Matcher) DiscordUserService(gg.projecteden.nexus.models.discord.DiscordUserService) NicknameService(gg.projecteden.nexus.models.nickname.NicknameService) Nerd(gg.projecteden.nexus.models.nerd.Nerd) NerdService(gg.projecteden.nexus.models.nerd.NerdService) Nickname(gg.projecteden.nexus.models.nickname.Nickname)

Aggregations

NicknameService (gg.projecteden.nexus.models.nickname.NicknameService)2 Command (gg.projecteden.discord.appcommands.annotations.Command)1 NexusAppCommand (gg.projecteden.nexus.features.discord.appcommands.NexusAppCommand)1 DiscordUser (gg.projecteden.nexus.models.discord.DiscordUser)1 DiscordUserService (gg.projecteden.nexus.models.discord.DiscordUserService)1 Nerd (gg.projecteden.nexus.models.nerd.Nerd)1 NerdService (gg.projecteden.nexus.models.nerd.NerdService)1 Nickname (gg.projecteden.nexus.models.nickname.Nickname)1 NicknameHistoryEntry (gg.projecteden.nexus.models.nickname.Nickname.NicknameHistoryEntry)1 Matcher (java.util.regex.Matcher)1