Search in sources :

Example 1 with Plugin

use of me.TechsCode.TechDiscordBot.util.Plugin 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 2 with Plugin

use of me.TechsCode.TechDiscordBot.util.Plugin 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)

Example 3 with Plugin

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

the class WikiCommand method showCurrentChannel.

public void showCurrentChannel(SlashCommandEvent e, TextChannel channel) {
    if (Plugin.isPluginChannel(channel)) {
        Plugin plugin = Plugin.byChannel(channel);
        if (!plugin.hasWiki()) {
            new TechEmbedBuilder("Wikis").error().text(plugin.getEmoji().getAsMention() + " " + plugin.getRoleName() + " unfortunately does not have a wiki!").sendTemporary(channel, 10);
            return;
        }
        e.replyEmbeds(new TechEmbedBuilder("Wikis").text("*Showing the wiki of the support channel you're in.*\n\n" + plugin.getEmoji().getAsMention() + " " + plugin.getWiki() + "\n\nFor more info please execute the command `wiki help`.").build()).queue();
    }
}
Also used : TechEmbedBuilder(me.TechsCode.TechDiscordBot.util.TechEmbedBuilder) Plugin(me.TechsCode.TechDiscordBot.util.Plugin)

Example 4 with Plugin

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

the class ActivitiesModule method checkResources.

public void checkResources() {
    if (!TechDiscordBot.getBot().getSpigotStatus().isUsable())
        return;
    TechDiscordBot.getSpigotAPI().getSpigotResources().forEach(resource -> {
        Plugin plugin = Plugin.fromId(resource.getId());
        if (plugin == null)
            return;
        Update latestUpdate = plugin.getLatestUpdate();
        boolean isNewUpdate = isNewUpdate(resource.getId(), latestUpdate.getId());
        if (isNewUpdate) {
            printUpdate(plugin, latestUpdate);
        }
    });
}
Also used : Update(me.TechsCode.TechDiscordBot.spigotmc.data.Update) Plugin(me.TechsCode.TechDiscordBot.util.Plugin)

Example 5 with Plugin

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

the class PluginCommand method onCommand.

@Override
public void onCommand(TextChannel channel, Member m, SlashCommandEvent e) {
    Plugin plugin = e.getOption("plugin") == null ? null : Plugin.byRoleName(e.getOption("plugin").getAsString());
    if (plugin == null) {
        e.reply("Could not find the plugin, this probably shouldn't be happening.").setEphemeral(true).queue();
        return;
    }
    e.replyEmbeds(new TechEmbedBuilder(plugin.getRoleName()).text(plugin.getDescription() + ".").field("Download Links", plugin.getPluginMarketplace().toString(), true).field("Wiki", plugin.getWiki(), true).color(plugin.getColor()).thumbnail(plugin.getResourceLogo()).build()).queue();
}
Also used : TechEmbedBuilder(me.TechsCode.TechDiscordBot.util.TechEmbedBuilder) Plugin(me.TechsCode.TechDiscordBot.util.Plugin)

Aggregations

Plugin (me.TechsCode.TechDiscordBot.util.Plugin)6 TechEmbedBuilder (me.TechsCode.TechDiscordBot.util.TechEmbedBuilder)5 SubscribeEvent (net.dv8tion.jda.api.hooks.SubscribeEvent)3 List (java.util.List)2 Collectors (java.util.stream.Collectors)2 TechDiscordBot (me.TechsCode.TechDiscordBot.TechDiscordBot)2 Module (me.TechsCode.TechDiscordBot.module.Module)2 DefinedQuery (me.TechsCode.TechDiscordBot.objects.DefinedQuery)2 Query (me.TechsCode.TechDiscordBot.objects.Query)2 Requirement (me.TechsCode.TechDiscordBot.objects.Requirement)2 GuildMessageReceivedEvent (net.dv8tion.jda.api.events.message.guild.GuildMessageReceivedEvent)2 java.awt (java.awt)1 java.util (java.util)1 Arrays (java.util.Arrays)1 HashMap (java.util.HashMap)1 TimeUnit (java.util.concurrent.TimeUnit)1 Consumer (java.util.function.Consumer)1 TicketLogs (me.TechsCode.TechDiscordBot.logs.TicketLogs)1 TranscriptLogs (me.TechsCode.TechDiscordBot.logs.TranscriptLogs)1 Verification (me.TechsCode.TechDiscordBot.mysql.storage.Verification)1