Search in sources :

Example 6 with Category

use of net.dv8tion.jda.api.entities.Category in project TechDiscordBot by TechsCode-Team.

the class GetReleaseCommand method onCommand.

@Override
public void onCommand(TextChannel channel, Member m, SlashCommandEvent e) {
    String plugin = e.getOption("plugin").getAsString();
    if (plugin.equals("error"))
        return;
    if (SUPPORT_CATEGORIES.query().stream().anyMatch(c -> c.getId().equals(channel.getParent().getId()))) {
        e.reply("Getting release... please wait.").queue(q -> {
            GithubRelease release = GitHubUtil.getLatestRelease(plugin);
            if (release == null) {
                q.editOriginal("**Failed!** Could not get the release!\n\n**Possible reasons:**\n- The repo isn't valid.\n- There is no release in the repo.\n- Github is down.").queue();
            } else if (release.getFile() != null) {
                q.editOriginal(release.getFile(), plugin + ".jar").queue(msg2 -> release.getFile().delete());
                q.editOriginalEmbeds(new TechEmbedBuilder(release.getRelease().getName()).text("```" + (release.getRelease().getBody().isEmpty() ? "No changes specified." : release.getRelease().getBody().replaceAll(" \\|\\| ", "\n")) + "```").build()).queue();
            } else {
                q.editOriginal("**Failed!** Could not get the file!\n\n**Possible reasons:**\n- The developer messed up.\n- The release has no files for some reason.\n- GitHub is down.").queue();
            }
        });
    } else {
        StringBuilder channels = new StringBuilder();
        SUPPORT_CATEGORIES.query().forEach(c -> channels.append("\n - ").append(c.getAsMention()));
        e.replyEmbeds(new TechEmbedBuilder("Get Release - Error").text("You can not use this command in this channel's category.\n\n**Available Categories:**" + channels).error().build()).setEphemeral(true).queue();
    }
}
Also used : OptionType(net.dv8tion.jda.api.interactions.commands.OptionType) TechEmbedBuilder(me.TechsCode.TechDiscordBot.util.TechEmbedBuilder) TechDiscordBot(me.TechsCode.TechDiscordBot.TechDiscordBot) Category(net.dv8tion.jda.api.entities.Category) OptionData(net.dv8tion.jda.api.interactions.commands.build.OptionData) Member(net.dv8tion.jda.api.entities.Member) TextChannel(net.dv8tion.jda.api.entities.TextChannel) Command(net.dv8tion.jda.api.interactions.commands.Command) Collectors(java.util.stream.Collectors) SlashCommandEvent(net.dv8tion.jda.api.events.interaction.SlashCommandEvent) CommandModule(me.TechsCode.TechDiscordBot.module.CommandModule) GitHubUtil(me.TechsCode.TechDiscordBot.github.GitHubUtil) Role(net.dv8tion.jda.api.entities.Role) GithubRelease(me.TechsCode.TechDiscordBot.github.GithubRelease) CommandPrivilege(net.dv8tion.jda.api.interactions.commands.privileges.CommandPrivilege) DefinedQuery(me.TechsCode.TechDiscordBot.objects.DefinedQuery) Query(me.TechsCode.TechDiscordBot.objects.Query) TechEmbedBuilder(me.TechsCode.TechDiscordBot.util.TechEmbedBuilder) GithubRelease(me.TechsCode.TechDiscordBot.github.GithubRelease)

Aggregations

Category (net.dv8tion.jda.api.entities.Category)6 TextChannel (net.dv8tion.jda.api.entities.TextChannel)3 ElementTag (com.denizenscript.denizencore.objects.core.ElementTag)1 ArrayList (java.util.ArrayList)1 Set (java.util.Set)1 Collectors (java.util.stream.Collectors)1 TechDiscordBot (me.TechsCode.TechDiscordBot.TechDiscordBot)1 GitHubUtil (me.TechsCode.TechDiscordBot.github.GitHubUtil)1 GithubRelease (me.TechsCode.TechDiscordBot.github.GithubRelease)1 CommandModule (me.TechsCode.TechDiscordBot.module.CommandModule)1 DefinedQuery (me.TechsCode.TechDiscordBot.objects.DefinedQuery)1 Query (me.TechsCode.TechDiscordBot.objects.Query)1 TechEmbedBuilder (me.TechsCode.TechDiscordBot.util.TechEmbedBuilder)1 ChannelType (net.dv8tion.jda.api.entities.ChannelType)1 Guild (net.dv8tion.jda.api.entities.Guild)1 GuildChannel (net.dv8tion.jda.api.entities.GuildChannel)1 Member (net.dv8tion.jda.api.entities.Member)1 Role (net.dv8tion.jda.api.entities.Role)1 SlashCommandEvent (net.dv8tion.jda.api.events.interaction.SlashCommandEvent)1 Command (net.dv8tion.jda.api.interactions.commands.Command)1