This commit is contained in:
Norbi Peti 2016-10-23 02:02:16 +02:00
parent 6ab6bc9fc6
commit 555faa7f52
2 changed files with 50 additions and 4 deletions

View file

@ -19,6 +19,7 @@ import sx.blah.discord.api.*;
import sx.blah.discord.api.events.IListener;
import sx.blah.discord.handle.impl.events.ReadyEvent;
import sx.blah.discord.handle.obj.IChannel;
import sx.blah.discord.handle.obj.IGuild;
import sx.blah.discord.handle.obj.IMessage;
import sx.blah.discord.handle.obj.Status;
@ -57,15 +58,29 @@ public class DiscordPlugin extends JavaPlugin implements IListener<ReadyEvent> {
public static IChannel botchannel;
public static IChannel annchannel;
public static IChannel genchannel;
public static IChannel issuechannel;
public static final boolean Test = false;
@Override
public void handle(ReadyEvent event) {
try {
botchannel = event.getClient().getGuilds().get(0).getChannelByID("209720707188260864"); // bot
annchannel = event.getClient().getGuilds().get(0).getChannelByID("126795071927353344"); // announcements
genchannel = event.getClient().getGuilds().get(0).getChannelByID("125813020357165056"); // general
final IGuild mainServer = event.getClient().getGuildByID("125813020357165056");
final IGuild devServer = event.getClient().getGuildByID("219529124321034241");
if (!Test) {
botchannel = mainServer.getChannelByID("209720707188260864"); // bot
annchannel = mainServer.getChannelByID("126795071927353344"); // announcements
genchannel = mainServer.getChannelByID("125813020357165056"); // general
issuechannel = devServer.getChannelByID("219643416496046081"); // server_issues
} else {
botchannel = devServer.getChannelByID("239519012529111040"); // bottest
annchannel = devServer.getChannelByID("239519012529111040"); // bottest
genchannel = devServer.getChannelByID("239519012529111040"); // bottest
issuechannel = devServer.getChannelByID("239519012529111040"); // bottest
}
dc.changeStatus(Status.game("on TBMC"));
botchannel.sendMessage("Minecraft server started up");
// TBMCDiscordAPI.SendException(new Exception("This is a test exception"), "This is a test error message");
Runnable r = new Runnable() {
public void run() {
AnnouncementGetterThreadMethod();

View file

@ -1,7 +1,38 @@
package buttondevteam.discordplugin;
import java.io.PrintStream;
import java.nio.charset.StandardCharsets;
import org.apache.commons.io.output.ByteArrayOutputStream;
import org.apache.commons.lang.exception.ExceptionUtils;
public final class TBMCDiscordAPI {
public static void SendException(Exception e, String sourcemessage) {
// TODO
try {
//System.out.println("A");
// ByteArrayOutputStream baos = new ByteArrayOutputStream();
// PrintStream str = new PrintStream(baos, true, "UTF-8");
// PrintStream str = new PrintStream(baos);
StringBuilder sb = new StringBuilder();
//System.out.println("B");
sb.append(sourcemessage).append("\n");
sb.append("```").append("\n");
// e.printStackTrace(str);
sb.append(ExceptionUtils.getStackTrace(e)).append("\n");
sb.append("```");
// str.flush();
// str.close();
//System.out.println("C");
//System.out.println("D");
// final String string = baos.toString(StandardCharsets.UTF_8);
//System.out.println("E");
DiscordPlugin.issuechannel.sendMessage(sb.toString());
//System.out.println("F");
} catch (Exception ex) {
//System.out.println("EX");
//System.out.println(ex);
ex.printStackTrace();
}
//System.out.println("G");
}
}