Server ready fix & main server fix attempt
This commit is contained in:
parent
5472929113
commit
939c6f4970
2 changed files with 8 additions and 5 deletions
|
@ -65,8 +65,11 @@ public class DiscordPlugin extends ButtonPlugin {
|
||||||
return plugin.prefix().get();
|
return plugin.prefix().get();
|
||||||
}
|
}
|
||||||
|
|
||||||
private ConfigData<Guild> mainServer() {
|
private ConfigData<Optional<Guild>> mainServer() {
|
||||||
return getIConfig().getDataPrimDef("mainServer", 219529124321034241L, id -> dc.getGuildById(Snowflake.of((long) id)).block(), g -> g.getId().asLong());
|
return getIConfig().getDataPrimDef("mainServer", 219529124321034241L,
|
||||||
|
id -> dc.getGuildById(Snowflake.of((long) id))
|
||||||
|
.onErrorContinue((t, o) -> getLogger().warning("Failed to get guild: " + t)).blockOptional(),
|
||||||
|
g -> g.map(gg -> gg.getId().asLong()).orElse(0L));
|
||||||
}
|
}
|
||||||
|
|
||||||
public ConfigData<Snowflake> commandChannel() {
|
public ConfigData<Snowflake> commandChannel() {
|
||||||
|
@ -130,7 +133,7 @@ public class DiscordPlugin extends ButtonPlugin {
|
||||||
|
|
||||||
private void handleReady(List<GuildCreateEvent> event) {
|
private void handleReady(List<GuildCreateEvent> event) {
|
||||||
try {
|
try {
|
||||||
mainServer = mainServer().get(); //Shouldn't change afterwards
|
mainServer = mainServer().get().orElse(null); //Shouldn't change afterwards
|
||||||
if (mainServer == null) {
|
if (mainServer == null) {
|
||||||
if (event.size() == 0) {
|
if (event.size() == 0) {
|
||||||
getLogger().severe("Main server not found! Invite the bot and do /discord reset");
|
getLogger().severe("Main server not found! Invite the bot and do /discord reset");
|
||||||
|
@ -139,7 +142,7 @@ public class DiscordPlugin extends ButtonPlugin {
|
||||||
}
|
}
|
||||||
mainServer = event.get(0).getGuild();
|
mainServer = event.get(0).getGuild();
|
||||||
getLogger().warning("Main server set to first one: " + mainServer.getName());
|
getLogger().warning("Main server set to first one: " + mainServer.getName());
|
||||||
mainServer().set(mainServer); //Save in config
|
mainServer().set(Optional.of(mainServer)); //Save in config
|
||||||
}
|
}
|
||||||
SafeMode = false;
|
SafeMode = false;
|
||||||
DPUtils.disableIfConfigError(null, commandChannel(), modRole()); //Won't disable, just prints the warning here
|
DPUtils.disableIfConfigError(null, commandChannel(), modRole()); //Won't disable, just prints the warning here
|
||||||
|
|
|
@ -108,7 +108,7 @@ public class FunModule extends Component<DiscordPlugin> implements Listener {
|
||||||
if (usableServerReadyStrings.size() == 0)
|
if (usableServerReadyStrings.size() == 0)
|
||||||
fm.createUsableServerReadyStrings();
|
fm.createUsableServerReadyStrings();
|
||||||
next = usableServerReadyStrings.remove(serverReadyRandom.nextInt(usableServerReadyStrings.size()));
|
next = usableServerReadyStrings.remove(serverReadyRandom.nextInt(usableServerReadyStrings.size()));
|
||||||
DPUtils.reply(message, null, serverReadyStrings[next]).subscribe();
|
DPUtils.reply(message, null, fm.serverReadyAnswers().get().get(next)).subscribe();
|
||||||
return false; //Still process it as a command/mcchat if needed
|
return false; //Still process it as a command/mcchat if needed
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
|
|
Loading…
Reference in a new issue