use of me.TechsCode.TechDiscordBot.github.GithubRelease in project TechDiscordBot by TechsCode-Team.
the class PluginLabModule method detectRelease.
public void detectRelease() {
plugins.forEach((name, channel) -> {
String plugin = name.replace(" ", "");
GithubRelease release = GitHubUtil.getLatestRelease(plugin);
if (release != null) {
try {
Date date = release.getRelease().getCreatedAt();
if (lastUpload.containsKey(plugin)) {
long lastTime = lastUpload.get(plugin);
if (lastTime != date.getTime()) {
lastUpload.put(plugin, date.getTime());
uploadFile(channel, release, plugin);
}
} else {
lastUpload.put(plugin, date.getTime());
}
} catch (IOException ex) {
TechDiscordBot.log("Could not get the last release date from the " + plugin + " repo!");
}
} else {
TechDiscordBot.log("Could not get info from the " + plugin + " repo!");
}
});
}
use of me.TechsCode.TechDiscordBot.github.GithubRelease 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();
}
}
Aggregations