Supporting clean installs, broadcast toggles, command improvements #92

Merged
NorbiPeti merged 14 commits from dev into master 2019-03-17 01:31:41 +00:00
2 changed files with 12 additions and 2 deletions
Showing only changes of commit 14c42614d8 - Show all commits

View file

@ -126,8 +126,10 @@ public final class DPUtils {
* @return The string for mentioning the channel
*/
public static String botmention() {
if (DiscordPlugin.plugin == null) return "#bot";
return DiscordPlugin.plugin.CommandChannel().get().mention();
IChannel channel;
if (DiscordPlugin.plugin == null
|| (channel = DiscordPlugin.plugin.CommandChannel().get()) == null) return "#bot";
return channel.mention();
}
}

View file

@ -43,6 +43,7 @@ import java.nio.charset.StandardCharsets;
import java.util.Optional;
import java.util.concurrent.TimeUnit;
import java.util.concurrent.TimeoutException;
import java.util.concurrent.atomic.AtomicInteger;
import java.util.stream.Collectors;
public class DiscordPlugin extends ButtonPlugin implements IListener<ReadyEvent> {
@ -116,7 +117,14 @@ public class DiscordPlugin extends ButtonPlugin implements IListener<ReadyEvent>
public void handle(ReadyEvent event) {
try {
dc.changePresence(StatusType.DND, ActivityType.PLAYING, "booting");
val tries = new AtomicInteger();
task = Bukkit.getScheduler().runTaskTimerAsynchronously(this, () -> {
tries.incrementAndGet();
if (tries.get() > 10) { //5 seconds
task.cancel();
getLogger().severe("Main or dev server not found! Set ID and do /discord reset");
return;
}
if (mainServer == null || devServer == null) {
mainServer = event.getClient().getGuildByID(125813020357165056L);
devServer = event.getClient().getGuildByID(219529124321034241L);