mirror of
https://github.com/demodude4u/Factorio-FBSR.git
synced 2024-11-24 08:12:21 +02:00
Added error reporting channel.
This commit is contained in:
parent
bab7f7918b
commit
b084316b99
@ -53,7 +53,9 @@ import javafx.util.Pair;
|
||||
import net.dv8tion.jda.core.EmbedBuilder;
|
||||
import net.dv8tion.jda.core.Permission;
|
||||
import net.dv8tion.jda.core.entities.Message;
|
||||
import net.dv8tion.jda.core.entities.MessageEmbed;
|
||||
import net.dv8tion.jda.core.entities.PrivateChannel;
|
||||
import net.dv8tion.jda.core.entities.TextChannel;
|
||||
import net.dv8tion.jda.core.events.message.MessageReceivedEvent;
|
||||
|
||||
public class BlueprintBotDiscordService extends AbstractIdleService {
|
||||
@ -68,6 +70,8 @@ public class BlueprintBotDiscordService extends AbstractIdleService {
|
||||
|
||||
private JSONObject configJson;
|
||||
|
||||
private String reportingChannelID;
|
||||
|
||||
private CommandHandler createDataRawCommandHandler(Function<String, Optional<LuaValue>> query) {
|
||||
return event -> {
|
||||
String content = event.getMessage().getStrippedContent();
|
||||
@ -189,6 +193,8 @@ public class BlueprintBotDiscordService extends AbstractIdleService {
|
||||
processBlueprints(BlueprintFinder.search(content, reporting), event, reporting);
|
||||
}
|
||||
|
||||
reporting.addException(new Exception("I can't believe its not butter!"));
|
||||
|
||||
if (reporting.getImages().isEmpty() && reporting.getDownloads().isEmpty() && reporting.getWarnings().isEmpty()
|
||||
&& reporting.getExceptions().isEmpty() && reporting.getInfo().isEmpty()) {
|
||||
if (content.split("\\s").length == 1) {
|
||||
@ -436,8 +442,15 @@ public class BlueprintBotDiscordService extends AbstractIdleService {
|
||||
false);
|
||||
}
|
||||
|
||||
MessageEmbed embed = builder.build();
|
||||
PrivateChannel privateChannel = bot.getJDA().getUserById(reportingUserID).openPrivateChannel().complete();
|
||||
privateChannel.sendMessage(builder.build()).complete();
|
||||
privateChannel.sendMessage(embed).complete();
|
||||
if (!exceptions.isEmpty()) {
|
||||
TextChannel textChannel = bot.getJDA().getTextChannelById(reportingChannelID);
|
||||
if (textChannel != null) {
|
||||
textChannel.sendMessage(embed).complete();
|
||||
}
|
||||
}
|
||||
|
||||
} catch (Exception e) {
|
||||
PrivateChannel privateChannel = bot.getJDA().getUserById(reportingUserID).openPrivateChannel().complete();
|
||||
@ -516,6 +529,7 @@ public class BlueprintBotDiscordService extends AbstractIdleService {
|
||||
bot.startAsync().awaitRunning();
|
||||
|
||||
reportingUserID = configJson.getString("reporting_user_id");
|
||||
reportingChannelID = configJson.getString("reporting_channel_id");
|
||||
|
||||
ServiceFinder.addService(this);
|
||||
ServiceFinder.addService(WatchdogReporter.class, new WatchdogReporter() {
|
||||
|
Loading…
Reference in New Issue
Block a user