mirror of
https://github.com/DiscordSRV/Ascension.git
synced 2024-12-28 17:37:52 +01:00
A couple fixes
This commit is contained in:
parent
f0427d4890
commit
c4ab582d62
@ -171,7 +171,7 @@ public class DiscordAPIImpl implements DiscordAPI {
|
||||
"Failed to deliver message to thread \""
|
||||
+ threadConfig.threadName + "\" in channel " + container
|
||||
).accept(t);
|
||||
throw new RuntimeException("Failed to deliver message to one or more threads");
|
||||
return null;
|
||||
}
|
||||
|
||||
if (threadChannel != null) {
|
||||
@ -198,7 +198,7 @@ public class DiscordAPIImpl implements DiscordAPI {
|
||||
|
||||
private CompletableFuture<DiscordThreadChannel> findOrCreateThread(boolean unarchive, ThreadConfig threadConfig, DiscordThreadContainer container) {
|
||||
if (!unarchive) {
|
||||
return container.createThread(threadConfig.threadName, threadConfig.privateThread);
|
||||
return createThread(container, threadConfig.threadName, threadConfig.privateThread);
|
||||
}
|
||||
|
||||
CompletableFuture<DiscordThreadChannel> completableFuture = new CompletableFuture<>();
|
||||
@ -271,16 +271,7 @@ public class DiscordAPIImpl implements DiscordAPI {
|
||||
return;
|
||||
}
|
||||
|
||||
CompletableFuture<DiscordThreadChannel> createFuture;
|
||||
if (container instanceof DiscordForumChannel) {
|
||||
createFuture = ((DiscordForumChannel) container).createPost(
|
||||
config.threadName,
|
||||
SendableDiscordMessage.builder().setContent("\u200B").build() // zero-width-space
|
||||
);
|
||||
} else {
|
||||
createFuture = container.createThread(config.threadName, config.privateThread);
|
||||
}
|
||||
createFuture.whenComplete(((threadChannel, t) -> {
|
||||
createThread(container, config.threadName, config.privateThread).whenComplete(((threadChannel, t) -> {
|
||||
if (t != null) {
|
||||
future.completeExceptionally(t);
|
||||
} else {
|
||||
@ -289,6 +280,17 @@ public class DiscordAPIImpl implements DiscordAPI {
|
||||
}));
|
||||
}
|
||||
|
||||
private CompletableFuture<DiscordThreadChannel> createThread(DiscordThreadContainer container, String name, boolean privateThread) {
|
||||
if (container instanceof DiscordForumChannel) {
|
||||
return ((DiscordForumChannel) container).createPost(
|
||||
name,
|
||||
SendableDiscordMessage.builder().setContent("\u200B").build() // zero-width-space
|
||||
);
|
||||
} else {
|
||||
return container.createThread(name, privateThread);
|
||||
}
|
||||
}
|
||||
|
||||
public void lookupThreads(
|
||||
DiscordThreadContainer container,
|
||||
boolean privateThreads,
|
||||
|
@ -21,6 +21,7 @@ package com.discordsrv.common;
|
||||
import com.discordsrv.api.channel.GameChannel;
|
||||
import com.discordsrv.common.bootstrap.IBootstrap;
|
||||
import com.discordsrv.common.bootstrap.LifecycleManager;
|
||||
import com.discordsrv.common.command.game.executor.CommandExecutorProvider;
|
||||
import com.discordsrv.common.command.game.handler.ICommandHandler;
|
||||
import com.discordsrv.common.config.configurate.manager.ConnectionConfigManager;
|
||||
import com.discordsrv.common.config.configurate.manager.MainConfigManager;
|
||||
@ -36,8 +37,8 @@ import com.discordsrv.common.config.messages.MessagesConfig;
|
||||
import com.discordsrv.common.console.Console;
|
||||
import com.discordsrv.common.debug.data.OnlineMode;
|
||||
import com.discordsrv.common.debug.data.VersionInfo;
|
||||
import com.discordsrv.common.exception.ConfigException;
|
||||
import com.discordsrv.common.logging.Logger;
|
||||
import com.discordsrv.common.logging.backend.LoggingBackend;
|
||||
import com.discordsrv.common.logging.backend.impl.JavaLoggerImpl;
|
||||
import com.discordsrv.common.messageforwarding.game.minecrafttodiscord.MinecraftToDiscordChatModule;
|
||||
import com.discordsrv.common.player.IPlayer;
|
||||
@ -47,6 +48,7 @@ import com.discordsrv.common.scheduler.Scheduler;
|
||||
import com.discordsrv.common.scheduler.StandardScheduler;
|
||||
import com.discordsrv.common.storage.impl.MemoryStorage;
|
||||
import dev.vankka.dependencydownload.classpath.ClasspathAppender;
|
||||
import net.kyori.adventure.audience.Audience;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
@ -124,7 +126,32 @@ public class MockDiscordSRV extends AbstractDiscordSRV<IBootstrap, MainConfig, C
|
||||
|
||||
@Override
|
||||
public Console console() {
|
||||
return null;
|
||||
return new Console() {
|
||||
@Override
|
||||
public LoggingBackend loggingBackend() {
|
||||
return JavaLoggerImpl.getRoot();
|
||||
}
|
||||
|
||||
@Override
|
||||
public CommandExecutorProvider commandExecutorProvider() {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasPermission(String permission) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void runCommand(String command) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public @NotNull Audience audience() {
|
||||
return null;
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -229,7 +256,7 @@ public class MockDiscordSRV extends AbstractDiscordSRV<IBootstrap, MainConfig, C
|
||||
threadConfigs.add(thread);
|
||||
|
||||
ThreadConfig forumThread = new ThreadConfig();
|
||||
thread.channelId = forumId;
|
||||
forumThread.channelId = forumId;
|
||||
threadConfigs.add(forumThread);
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user