Search in sources :

Example 1 with TechEmbedBuilder

use of me.TechsCode.TechDiscordBot.util.TechEmbedBuilder in project TechDiscordBot by TechsCode-Team.

the class StaffEmbedModule method receive.

@SubscribeEvent
public void receive(GuildMessageReceivedEvent e) {
    if (e.getMember() == null)
        return;
    if (e.getAuthor().isBot())
        return;
    if (!e.getMember().getRoles().contains(STAFF_ROLE.query().first()))
        return;
    String message = e.getMessage().getContentRaw();
    if (message.startsWith("^^ ") && message.endsWith(" ^^")) {
        e.getMessage().delete().queue();
        String text = message.substring(3, message.length() - 3);
        e.getChannel().sendMessage(text).queue();
        return;
    }
    if (message.startsWith("^ ")) {
        e.getMessage().delete().queue();
        String text = message.substring(2);
        String[] arguments = text.split("\\^");
        if (arguments.length != 2 && arguments.length != 3) {
            new TechEmbedBuilder("Invalid Arguments").text("Usage: ^ Title ^ Message ^ (Optional) Thumbnail ^").error().sendTemporary(e.getChannel(), 5);
            return;
        }
        if (arguments.length == 3) {
            if (arguments[2].trim().startsWith("#")) {
                new TechEmbedBuilder(arguments[0]).footer("Posted by " + e.getAuthor().getName()).text(arguments[1]).color(Color.decode(arguments[2].trim())).queue(e.getChannel());
            } else {
                new TechEmbedBuilder(arguments[0]).footer("Posted by " + e.getAuthor().getName()).text(arguments[1]).thumbnail(arguments[2]).queue(e.getChannel());
            }
        } else {
            new TechEmbedBuilder(arguments[0]).footer("Posted by " + e.getAuthor().getName()).text(arguments[1]).queue(e.getChannel());
        }
    }
}
Also used : TechEmbedBuilder(me.TechsCode.TechDiscordBot.util.TechEmbedBuilder) SubscribeEvent(net.dv8tion.jda.api.hooks.SubscribeEvent)

Example 2 with TechEmbedBuilder

use of me.TechsCode.TechDiscordBot.util.TechEmbedBuilder in project TechDiscordBot by TechsCode-Team.

the class SupportWrongChannelModule method triggerMessage.

public void triggerMessage(Message sentMessage, Member member) {
    if (messages.containsValue(member.getId()))
        return;
    TextChannel verificationChannel = bot.getChannel("907349490556616745");
    TechEmbedBuilder teb = new TechEmbedBuilder().text("Hello, " + member.getAsMention() + "! I've detected that you might be trying to get help in this channel! To verify your purchase, we ask you to fill out this [form](https://forms.gle/PBX7z5LaXqdYh7wF6) in order to get help, thanks!\n\n*If you are not trying to get help, you can delete this message by reacting to it!*").error();
    // TextChannel verificationChannel = bot.getChannel("907349490556616745");
    // TechEmbedBuilder teb = new TechEmbedBuilder()
    // .text("Hello, " + member.getAsMention() + "! I've detected that you might be trying to get help in this channel! Please verify in " + verificationChannel.getAsMention() + " in order to get help, thanks!\n\n*If you are not trying to get help, you can delete this message by reacting to it!*")
    // .error();
    Message message;
    Verification verification = TechDiscordBot.getStorage().retrieveVerificationWithDiscord(member);
    if (verification != null) {
        List<Plugin> pc = Arrays.stream(Plugin.values()).filter(p -> member.getRoles().stream().anyMatch(r -> r.getName().equals(p.getRoleName()))).collect(Collectors.toList());
        if (pc.size() > 0) {
            StringBuilder sb = new StringBuilder();
            String plugins = Plugin.getEmotesByList(pc.stream().map(Plugin::getRoleName).collect(Collectors.toList()));
            sb.append("Hello, ").append(member.getAsMention()).append("!\n\n It looks like you have bought ").append(pc.size() == 1 ? "this plugin" : "these plugins").append(" already: ").append(plugins).append("\nHere are the corresponding channels:\n\n");
            StringBuilder channels = new StringBuilder();
            pc.forEach(p -> channels.append("- ").append(TechDiscordBot.getJDA().getTextChannelById(p.getChannelId()).getAsMention()).append("\n"));
            sb.append(channels.toString());
            sb.append("\nPlease use the corresponding plugin channel above to get support.\nThis channel is **not** a support channel.\n\n*If you are not trying to get help, you can delete this message by reacting to it!*");
            message = new TechEmbedBuilder().text(sb.toString()).error().reply(sentMessage);
        } else {
            message = teb.reply(sentMessage);
        }
    } else {
        message = teb.reply(sentMessage);
    }
    if (message != null) {
        message.addReaction("\u274C").queue();
        messages.put(message.getId(), member.getId());
    }
}
Also used : Message(net.dv8tion.jda.api.entities.Message) GuildMessageReceivedEvent(net.dv8tion.jda.api.events.message.guild.GuildMessageReceivedEvent) TechEmbedBuilder(me.TechsCode.TechDiscordBot.util.TechEmbedBuilder) Arrays(java.util.Arrays) TechDiscordBot(me.TechsCode.TechDiscordBot.TechDiscordBot) Plugin(me.TechsCode.TechDiscordBot.util.Plugin) HashMap(java.util.HashMap) Member(net.dv8tion.jda.api.entities.Member) TextChannel(net.dv8tion.jda.api.entities.TextChannel) Collectors(java.util.stream.Collectors) Requirement(me.TechsCode.TechDiscordBot.objects.Requirement) SubscribeEvent(net.dv8tion.jda.api.hooks.SubscribeEvent) List(java.util.List) Module(me.TechsCode.TechDiscordBot.module.Module) Verification(me.TechsCode.TechDiscordBot.mysql.storage.Verification) GuildMessageReactionAddEvent(net.dv8tion.jda.api.events.message.guild.react.GuildMessageReactionAddEvent) DefinedQuery(me.TechsCode.TechDiscordBot.objects.DefinedQuery) Query(me.TechsCode.TechDiscordBot.objects.Query) TextChannel(net.dv8tion.jda.api.entities.TextChannel) Message(net.dv8tion.jda.api.entities.Message) TechEmbedBuilder(me.TechsCode.TechDiscordBot.util.TechEmbedBuilder) Verification(me.TechsCode.TechDiscordBot.mysql.storage.Verification) Plugin(me.TechsCode.TechDiscordBot.util.Plugin)

Example 3 with TechEmbedBuilder

use of me.TechsCode.TechDiscordBot.util.TechEmbedBuilder in project TechDiscordBot by TechsCode-Team.

the class TicketModule method createTicket.

public void createTicket(Member member, Plugin plugin, String issue) {
    String name = "ticket-" + member.getEffectiveName().replaceAll("[^a-zA-Z\\d\\s_-]", "").toLowerCase();
    if (name.equals("ticket-"))
        // Make sure the ticket has an actual name. In case the regex result is empty.
        name = "ticket-" + member.getUser().getId();
    TextChannel ticketChannel = TechDiscordBot.getGuild().createTextChannel(name).setParent(getTicketCategory()).setTopic(member.getAsMention() + "'s Ticket | Problem Solved? Please execute /ticket close.").complete();
    ticketChannel.getManager().clearOverridesAdded().complete();
    ticketChannel.getManager().clearOverridesRemoved().complete();
    List<Permission> permissionsAllow = new ArrayList<>(Arrays.asList(Permission.MESSAGE_ADD_REACTION, Permission.MESSAGE_ATTACH_FILES, Permission.MESSAGE_EMBED_LINKS, Permission.MESSAGE_READ, Permission.MESSAGE_WRITE, Permission.MESSAGE_HISTORY));
    ticketChannel.getManager().putPermissionOverride(STAFF_ROLE.query().first(), permissionsAllow, Collections.singletonList(Permission.MESSAGE_TTS)).putPermissionOverride(member, permissionsAllow, Collections.singletonList(Permission.MESSAGE_TTS)).putPermissionOverride(TechDiscordBot.getGuild().getPublicRole(), new ArrayList<>(), Arrays.asList(Permission.MESSAGE_READ, Permission.MESSAGE_WRITE)).queue();
    String plugins = Plugin.getMembersPluginsinEmojis(member);
    new TechEmbedBuilder(member.getEffectiveName() + " - " + member.getUser().getId()).field("Plugin", plugin.getEmoji().getAsMention(), true).field("Owned Plugins", plugins, true).field("Issue", issue, false).queue(ticketChannel);
    if (TechDiscordBot.getStorage().isSubVerifiedUser(member.getId())) {
        new TechEmbedBuilder("Sub Verified User Support").text("Original Plugin-holder: " + TechDiscordBot.getGuild().getMemberById(TechDiscordBot.getStorage().getVerifiedIdFromSubVerifiedId(member.getId())).getAsMention()).color(Color.ORANGE).queue(ticketChannel);
    }
    TicketLogs.log(new TechEmbedBuilder("New Ticket").text(member.getAsMention() + " created a new ticket (" + ticketChannel.getAsMention() + ")"));
    reset();
}
Also used : TechEmbedBuilder(me.TechsCode.TechDiscordBot.util.TechEmbedBuilder) Permission(net.dv8tion.jda.api.Permission)

Example 4 with TechEmbedBuilder

use of me.TechsCode.TechDiscordBot.util.TechEmbedBuilder in project TechDiscordBot by TechsCode-Team.

the class TicketModule method sendPriorityInstructions.

public void sendPriorityInstructions(Member member) {
    if (isSelection)
        return;
    selectionStep = 1;
    Emote lowPriority = PRIORITY_EMOTES.query().get(0);
    if (lastInstructions != null)
        lastInstructions.delete().queue();
    TechEmbedBuilder priority = new TechEmbedBuilder("Ticket Creation" + (member != null ? " (" + member.getEffectiveName() + ")" : "")).text("Please react below to create a ticket!");
    priority.queue(channel, message -> setLastInstructions(message, msg -> {
        try {
            msg.addReaction(lowPriority).queue();
        } catch (Exception ignored) {
        }
    }));
}
Also used : net.dv8tion.jda.api.entities(net.dv8tion.jda.api.entities) GuildMessageReceivedEvent(net.dv8tion.jda.api.events.message.guild.GuildMessageReceivedEvent) TechEmbedBuilder(me.TechsCode.TechDiscordBot.util.TechEmbedBuilder) java.util(java.util) TechDiscordBot(me.TechsCode.TechDiscordBot.TechDiscordBot) Permission(net.dv8tion.jda.api.Permission) Plugin(me.TechsCode.TechDiscordBot.util.Plugin) MessageReactionAddEvent(net.dv8tion.jda.api.events.message.react.MessageReactionAddEvent) Collectors(java.util.stream.Collectors) SlashCommandEvent(net.dv8tion.jda.api.events.interaction.SlashCommandEvent) java.awt(java.awt) TimeUnit(java.util.concurrent.TimeUnit) Consumer(java.util.function.Consumer) Requirement(me.TechsCode.TechDiscordBot.objects.Requirement) SubscribeEvent(net.dv8tion.jda.api.hooks.SubscribeEvent) List(java.util.List) TicketTranscript(me.TechsCode.TechDiscordBot.transcripts.TicketTranscript) Module(me.TechsCode.TechDiscordBot.module.Module) TicketTranscriptOptions(me.TechsCode.TechDiscordBot.transcripts.TicketTranscriptOptions) TranscriptLogs(me.TechsCode.TechDiscordBot.logs.TranscriptLogs) TicketPriority(me.TechsCode.TechDiscordBot.objects.TicketPriority) TicketLogs(me.TechsCode.TechDiscordBot.logs.TicketLogs) DefinedQuery(me.TechsCode.TechDiscordBot.objects.DefinedQuery) Query(me.TechsCode.TechDiscordBot.objects.Query) TechEmbedBuilder(me.TechsCode.TechDiscordBot.util.TechEmbedBuilder)

Example 5 with TechEmbedBuilder

use of me.TechsCode.TechDiscordBot.util.TechEmbedBuilder in project TechDiscordBot by TechsCode-Team.

the class TicketModule method sendPluginInstructions.

public void sendPluginInstructions(Member member) {
    if (selectionStep != 1)
        return;
    selectionUserId = member.getId();
    isSelection = true;
    selectionStep = 2;
    String sb = PLUGIN_EMOTES.query().all().stream().map(emote -> emote.getAsMention() + " - " + Plugin.byEmote(emote).getRoleName()).collect(Collectors.joining("\n"));
    if (lastInstructions != null)
        lastInstructions.delete().queue();
    TechEmbedBuilder plugin = new TechEmbedBuilder("Ticket Creation (" + member.getEffectiveName() + ")").text("Please select which plugin the issue corresponds with below:", "", sb, "", ERROR_EMOTE.query().first().getAsMention() + " - Cancel", "");
    plugin.queue(channel, message -> setLastInstructions(message, msg -> {
        PLUGIN_EMOTES.query().all().stream().filter(emote -> msg != null).forEach(emote -> msg.addReaction(emote).queue((msg2) -> {
            try {
                msg.addReaction(ERROR_EMOTE.query().first()).queue();
            } catch (Exception ignored) {
            }
        }));
    }));
}
Also used : net.dv8tion.jda.api.entities(net.dv8tion.jda.api.entities) GuildMessageReceivedEvent(net.dv8tion.jda.api.events.message.guild.GuildMessageReceivedEvent) TechEmbedBuilder(me.TechsCode.TechDiscordBot.util.TechEmbedBuilder) java.util(java.util) TechDiscordBot(me.TechsCode.TechDiscordBot.TechDiscordBot) Permission(net.dv8tion.jda.api.Permission) Plugin(me.TechsCode.TechDiscordBot.util.Plugin) MessageReactionAddEvent(net.dv8tion.jda.api.events.message.react.MessageReactionAddEvent) Collectors(java.util.stream.Collectors) SlashCommandEvent(net.dv8tion.jda.api.events.interaction.SlashCommandEvent) java.awt(java.awt) TimeUnit(java.util.concurrent.TimeUnit) Consumer(java.util.function.Consumer) Requirement(me.TechsCode.TechDiscordBot.objects.Requirement) SubscribeEvent(net.dv8tion.jda.api.hooks.SubscribeEvent) List(java.util.List) TicketTranscript(me.TechsCode.TechDiscordBot.transcripts.TicketTranscript) Module(me.TechsCode.TechDiscordBot.module.Module) TicketTranscriptOptions(me.TechsCode.TechDiscordBot.transcripts.TicketTranscriptOptions) TranscriptLogs(me.TechsCode.TechDiscordBot.logs.TranscriptLogs) TicketPriority(me.TechsCode.TechDiscordBot.objects.TicketPriority) TicketLogs(me.TechsCode.TechDiscordBot.logs.TicketLogs) DefinedQuery(me.TechsCode.TechDiscordBot.objects.DefinedQuery) Query(me.TechsCode.TechDiscordBot.objects.Query) TechEmbedBuilder(me.TechsCode.TechDiscordBot.util.TechEmbedBuilder)

Aggregations

TechEmbedBuilder (me.TechsCode.TechDiscordBot.util.TechEmbedBuilder)32 SubscribeEvent (net.dv8tion.jda.api.hooks.SubscribeEvent)14 Member (net.dv8tion.jda.api.entities.Member)11 TechDiscordBot (me.TechsCode.TechDiscordBot.TechDiscordBot)10 DefinedQuery (me.TechsCode.TechDiscordBot.objects.DefinedQuery)10 Query (me.TechsCode.TechDiscordBot.objects.Query)10 List (java.util.List)9 Module (me.TechsCode.TechDiscordBot.module.Module)9 Requirement (me.TechsCode.TechDiscordBot.objects.Requirement)9 GuildMessageReceivedEvent (net.dv8tion.jda.api.events.message.guild.GuildMessageReceivedEvent)9 java.awt (java.awt)8 TimeUnit (java.util.concurrent.TimeUnit)8 Plugin (me.TechsCode.TechDiscordBot.util.Plugin)8 Collectors (java.util.stream.Collectors)6 SlashCommandEvent (net.dv8tion.jda.api.events.interaction.SlashCommandEvent)5 BufferedReader (java.io.BufferedReader)4 InputStreamReader (java.io.InputStreamReader)4 HttpURLConnection (java.net.HttpURLConnection)4 URL (java.net.URL)4 java.util (java.util)4