Added logout and a small fix

This commit is contained in:
Norbi Peti 2016-10-08 16:57:54 +02:00
parent bd51083568
commit 4db7bb7082

View file

@ -38,7 +38,7 @@ public class DiscordPlugin extends JavaPlugin implements IListener<ReadyEvent> {
if (file.exists()) {
BufferedReader reader = Files.newReader(file, StandardCharsets.UTF_8);
String line = reader.readLine();
lastannouncementtime = Integer.parseInt(line);
lastannouncementtime = Long.parseLong(line);
}
ClientBuilder cb = new ClientBuilder();
cb.withToken(IOUtils.toString(getClass().getResourceAsStream("/Token.txt"), Charsets.UTF_8));
@ -72,6 +72,11 @@ public class DiscordPlugin extends JavaPlugin implements IListener<ReadyEvent> {
@Override
public void onDisable() {
stop = true;
try {
dc.logout();
} catch (Exception e) {
e.printStackTrace();
}
}
private long lastannouncementtime = 0;
@ -118,7 +123,7 @@ public class DiscordPlugin extends JavaPlugin implements IListener<ReadyEvent> {
lastannouncementtime = date;
File file = new File("TBMC", "DiscordRedditLastAnnouncement.txt");
Files.write(lastannouncementtime + "", file, StandardCharsets.UTF_8);
channel.sendMessage(msgsb.toString()); //TODO: Mod msgsb for announcements
channel.sendMessage(msgsb.toString()); // TODO: Mod msgsb for announcements
}
try {
Thread.sleep(10000);