DenisD3D / Mc2Discord

Link your Minecraft server chat with your Discord (75k downloads)
https://modrinth.com/mod/mc2discord
Apache License 2.0
41 stars 10 forks source link

1.20.1 "Source was empty" #107

Open TyBraniff opened 2 months ago

TyBraniff commented 2 months ago

Describe the bug

Having an error stating source is empty.

06May2024 22:58:53.047] [ForkJoinPool.commonPool-worker-10/ERROR] [fr.denisd3d.mc2discord.shadow.reactor.core.publisher.Operators/]: Operator called default onErrorDropped
fr.denisd3d.mc2discord.shadow.reactor.core.Exceptions$ErrorCallbackNotImplemented: java.util.NoSuchElementException: Source was empty
Caused by: java.util.NoSuchElementException: Source was empty
    at fr.denisd3d.mc2discord.shadow.reactor.core.publisher.MonoSingle$SingleSubscriber.onComplete(MonoSingle.java:174) ~[?:?]
    at fr.denisd3d.mc2discord.shadow.reactor.core.publisher.FluxSwitchIfEmpty$SwitchIfEmptySubscriber.onComplete(FluxSwitchIfEmpty.java:85) ~[?:?]
    at fr.denisd3d.mc2discord.shadow.reactor.core.publisher.MonoFlatMap$FlatMapMain.onComplete(MonoFlatMap.java:181) ~[?:?]
    at fr.denisd3d.mc2discord.shadow.reactor.core.publisher.FluxMap$MapSubscriber.onComplete(FluxMap.java:144) ~[?:?]
    at fr.denisd3d.mc2discord.shadow.reactor.core.publisher.FluxFilter$FilterSubscriber.onComplete(FluxFilter.java:166) ~[?:?]
    at fr.denisd3d.mc2discord.shadow.reactor.core.publisher.FluxSwitchIfEmpty$SwitchIfEmptySubscriber.onComplete(FluxSwitchIfEmpty.java:85) ~[?:?]
    at fr.denisd3d.mc2discord.shadow.reactor.core.publisher.FluxMapFuseable$MapFuseableSubscriber.onComplete(FluxMapFuseable.java:152) ~[?:?]
    at fr.denisd3d.mc2discord.shadow.reactor.core.publisher.Operators$ScalarSubscription.request(Operators.java:2402) ~[?:?]
    at fr.denisd3d.mc2discord.shadow.reactor.core.publisher.FluxMapFuseable$MapFuseableSubscriber.request(FluxMapFuseable.java:171) ~[?:?]
    at fr.denisd3d.mc2discord.shadow.reactor.core.publisher.Operators$MultiSubscriptionSubscriber.set(Operators.java:2196) ~[?:?]
    at fr.denisd3d.mc2discord.shadow.reactor.core.publisher.Operators$MultiSubscriptionSubscriber.onSubscribe(Operators.java:2070) ~[?:?]
    at fr.denisd3d.mc2discord.shadow.reactor.core.publisher.FluxMapFuseable$MapFuseableSubscriber.onSubscribe(FluxMapFuseable.java:96) ~[?:?]
    at fr.denisd3d.mc2discord.shadow.reactor.core.publisher.MonoJust.subscribe(MonoJust.java:55) ~[?:?]
    at fr.denisd3d.mc2discord.shadow.reactor.core.publisher.Mono.subscribe(Mono.java:4490) ~[?:?]
    at fr.denisd3d.mc2discord.shadow.reactor.core.publisher.FluxSwitchIfEmpty$SwitchIfEmptySubscriber.onComplete(FluxSwitchIfEmpty.java:82) ~[?:?]
    at fr.denisd3d.mc2discord.shadow.reactor.core.publisher.FluxFilter$FilterSubscriber.onComplete(FluxFilter.java:166) ~[?:?]
    at fr.denisd3d.mc2discord.shadow.reactor.core.publisher.MonoFlatMapMany$FlatMapManyMain.onComplete(MonoFlatMapMany.java:210) ~[?:?]
    at fr.denisd3d.mc2discord.shadow.reactor.core.publisher.FluxMap$MapSubscriber.onComplete(FluxMap.java:144) ~[?:?]
    at fr.denisd3d.mc2discord.shadow.reactor.core.publisher.FluxFilter$FilterSubscriber.onComplete(FluxFilter.java:166) ~[?:?]
    at fr.denisd3d.mc2discord.shadow.reactor.core.publisher.FluxSwitchIfEmpty$SwitchIfEmptySubscriber.onComplete(FluxSwitchIfEmpty.java:85) ~[?:?]
    at fr.denisd3d.mc2discord.shadow.reactor.core.publisher.FluxMapFuseable$MapFuseableSubscriber.onComplete(FluxMapFuseable.java:152) ~[?:?]
    at fr.denisd3d.mc2discord.shadow.reactor.core.publisher.Operators$ScalarSubscription.request(Operators.java:2402) ~[?:?]
    at fr.denisd3d.mc2discord.shadow.reactor.core.publisher.FluxMapFuseable$MapFuseableSubscriber.request(FluxMapFuseable.java:171) ~[?:?]
    at fr.denisd3d.mc2discord.shadow.reactor.core.publisher.Operators$MultiSubscriptionSubscriber.set(Operators.java:2196) ~[?:?]
    at fr.denisd3d.mc2discord.shadow.reactor.core.publisher.Operators$MultiSubscriptionSubscriber.onSubscribe(Operators.java:2070) ~[?:?]
    at fr.denisd3d.mc2discord.shadow.reactor.core.publisher.FluxMapFuseable$MapFuseableSubscriber.onSubscribe(FluxMapFuseable.java:96) ~[?:?]
    at fr.denisd3d.mc2discord.shadow.reactor.core.publisher.MonoJust.subscribe(MonoJust.java:55) ~[?:?]
    at fr.denisd3d.mc2discord.shadow.reactor.core.publisher.Mono.subscribe(Mono.java:4490) ~[?:?]
    at fr.denisd3d.mc2discord.shadow.reactor.core.publisher.FluxFlatMap$FlatMapMain.onNext(FluxFlatMap.java:427) ~[?:?]
    at fr.denisd3d.mc2discord.shadow.reactor.core.publisher.FluxIterable$IterableSubscription.slowPath(FluxIterable.java:335) ~[?:?]
    at fr.denisd3d.mc2discord.shadow.reactor.core.publisher.FluxIterable$IterableSubscription.request(FluxIterable.java:294) ~[?:?]
    at fr.denisd3d.mc2discord.shadow.reactor.core.publisher.FluxFlatMap$FlatMapMain.onSubscribe(FluxFlatMap.java:371) ~[?:?]
    at fr.denisd3d.mc2discord.shadow.reactor.core.publisher.FluxIterable.subscribe(FluxIterable.java:201) ~[?:?]
    at fr.denisd3d.mc2discord.shadow.reactor.core.publisher.FluxIterable.subscribe(FluxIterable.java:83) ~[?:?]
    at fr.denisd3d.mc2discord.shadow.reactor.core.publisher.Mono.subscribe(Mono.java:4490) ~[?:?]
    at fr.denisd3d.mc2discord.shadow.reactor.core.publisher.Mono.subscribeWith(Mono.java:4605) ~[?:?]
    at fr.denisd3d.mc2discord.shadow.reactor.core.publisher.Mono.subscribe(Mono.java:4318) ~[?:?]
    at fr.denisd3d.mc2discord.core.events.MinecraftEvents.onMinecraftChatMessageEvent(MinecraftEvents.java:21) ~[?:?]
    at fr.denisd3d.mc2discord.forge.ForgeEvents.onServerChat(ForgeEvents.java:25) ~[?:?]
    at fr.denisd3d.mc2discord.forge.__ForgeEvents_onServerChat_ServerChatEvent.invoke(.dynamic) ~[?:?]
    at net.minecraftforge.eventbus.ASMEventHandler.invoke(ASMEventHandler.java:73) ~[eventbus-6.0.5.jar%2352!/:?]
    at net.minecraftforge.eventbus.EventBus.post(EventBus.java:315) ~[eventbus-6.0.5.jar%2352!/:?]
    at net.minecraftforge.eventbus.EventBus.post(EventBus.java:296) ~[eventbus-6.0.5.jar%2352!/:?]
    at net.minecraftforge.common.ForgeHooks.onServerChatSubmittedEvent(ForgeHooks.java:412) ~[?:?]
    at net.minecraftforge.common.ForgeHooks.lambda$getServerChatSubmittedDecorator$0(ForgeHooks.java:422) ~[?:?]
    at java.util.concurrent.CompletableFuture$AsyncSupply.run(CompletableFuture.java:1768) ~[?:?]
    at java.util.concurrent.CompletableFuture$AsyncSupply.exec(CompletableFuture.java:1760) ~[?:?]
    at java.util.concurrent.ForkJoinTask.doExec(ForkJoinTask.java:373) ~[?:?]
    at java.util.concurrent.ForkJoinPool$WorkQueue.topLevelExec(ForkJoinPool.java:1182) ~[?:?]
    at java.util.concurrent.ForkJoinPool.scan(ForkJoinPool.java:1655) ~[?:?]
    at java.util.concurrent.ForkJoinPool.runWorker(ForkJoinPool.java:1622) ~[?:?]
    at java.util.concurrent.ForkJoinWorkerThread.run(ForkJoinWorkerThread.java:165) ~[?:?]

Part of me feels its because I'm using a Forum channel instead of a main channel. Our gaming community runs all of our servers in forum topics.

The main channel ID is 1021543376941748306 and the thread is 1218778350718287872

I attempted to use 1021543376941748306/1218778350718287872 however that gave me errors when reloading the mod.

The bot loads and partially works. Untitled Just cant send messages to discord. But wont fire back messages.

Your config file

http://m2d.denisd3d.fr/uploads/view?key=6953c16e-cdb6-4b78-9136-49da01e34f22

TyBraniff commented 2 months ago

Also restarting generates this error

[06May2024 23:18:35.957] [fr.denisd3d.mc2discord.shadow.reactor-http-nio-5/INFO] [fr.denisd3d.mc2discord.shadow.discord4j.core.shard.LocalShardCoordinator/]: [G:6cd5b1fe, S:0] Shard disconnected
[06May2024 23:18:35.958] [fr.denisd3d.mc2discord.shadow.reactor-http-nio-5/INFO] [fr.denisd3d.mc2discord.shadow.discord4j.core.shard.GatewayBootstrap/]: [G:6cd5b1fe, S:0] All shards disconnected
[06May2024 23:18:35.966] [Server thread/INFO] [fr.denisd3d.mc2discord.shadow.discord4j.core.DiscordClientBuilder/]: Discord4J 3.3.0-RC1 (https://discord4j.com)
[06May2024 23:18:35.967] [Server thread/INFO] [net.minecraft.server.MinecraftServer/]: Mc2Discord restarted
[06May2024 23:18:36.417] [fr.denisd3d.mc2discord.shadow.reactor-http-nio-8/INFO] [fr.denisd3d.mc2discord.shadow.discord4j.gateway.DefaultGatewayClient/]: [G:751960d1, S:0] Connected to Gateway
[06May2024 23:18:36.418] [fr.denisd3d.mc2discord.shadow.reactor-http-nio-8/INFO] [fr.denisd3d.mc2discord.shadow.discord4j.core.shard.LocalShardCoordinator/]: [G:751960d1, S:0] Shard connected
[06May2024 23:18:36.600] [boundedElastic-5/ERROR] [fr.denisd3d.mc2discord.shadow.reactor.core.publisher.Operators/]: Operator called default onErrorDropped
fr.denisd3d.mc2discord.shadow.reactor.core.Exceptions$ErrorCallbackNotImplemented: java.lang.ClassCastException: Cannot cast fr.denisd3d.mc2discord.shadow.discord4j.core.object.entity.channel.ForumChannel to fr.denisd3d.mc2discord.shadow.discord4j.core.object.entity.channel.TopLevelGuildMessageChannel
Caused by: java.lang.ClassCastException: Cannot cast fr.denisd3d.mc2discord.shadow.discord4j.core.object.entity.channel.ForumChannel to fr.denisd3d.mc2discord.shadow.discord4j.core.object.entity.channel.TopLevelGuildMessageChannel
    at java.lang.Class.cast(Class.java:3889) ~[?:?]
    at fr.denisd3d.mc2discord.shadow.reactor.core.publisher.FluxMapFuseable$MapFuseableSubscriber.onNext(FluxMapFuseable.java:113) ~[mc2discord-forge-1.20.1-4.2.3.jar%23729!/:4.2.3]
    at fr.denisd3d.mc2discord.shadow.reactor.core.publisher.FluxHide$SuppressFuseableSubscriber.onNext(FluxHide.java:137) ~[mc2discord-forge-1.20.1-4.2.3.jar%23729!/:4.2.3]
    at fr.denisd3d.mc2discord.shadow.reactor.core.publisher.FluxSwitchIfEmpty$SwitchIfEmptySubscriber.onNext(FluxSwitchIfEmpty.java:74) ~[mc2discord-forge-1.20.1-4.2.3.jar%23729!/:4.2.3]
    at fr.denisd3d.mc2discord.shadow.reactor.core.publisher.FluxMapFuseable$MapFuseableSubscriber.onNext(FluxMapFuseable.java:129) ~[mc2discord-forge-1.20.1-4.2.3.jar%23729!/:4.2.3]
    at fr.denisd3d.mc2discord.shadow.reactor.core.publisher.Operators$ScalarSubscription.request(Operators.java:2400) ~[mc2discord-forge-1.20.1-4.2.3.jar%23729!/:4.2.3]
    at fr.denisd3d.mc2discord.shadow.reactor.core.publisher.FluxMapFuseable$MapFuseableSubscriber.request(FluxMapFuseable.java:171) ~[mc2discord-forge-1.20.1-4.2.3.jar%23729!/:4.2.3]
    at fr.denisd3d.mc2discord.shadow.reactor.core.publisher.Operators$MultiSubscriptionSubscriber.set(Operators.java:2196) ~[mc2discord-forge-1.20.1-4.2.3.jar%23729!/:4.2.3]
    at fr.denisd3d.mc2discord.shadow.reactor.core.publisher.Operators$MultiSubscriptionSubscriber.onSubscribe(Operators.java:2070) ~[mc2discord-forge-1.20.1-4.2.3.jar%23729!/:4.2.3]
    at fr.denisd3d.mc2discord.shadow.reactor.core.publisher.FluxMapFuseable$MapFuseableSubscriber.onSubscribe(FluxMapFuseable.java:96) ~[mc2discord-forge-1.20.1-4.2.3.jar%23729!/:4.2.3]
    at fr.denisd3d.mc2discord.shadow.reactor.core.publisher.MonoJust.subscribe(MonoJust.java:55) ~[mc2discord-forge-1.20.1-4.2.3.jar%23729!/:4.2.3]
    at fr.denisd3d.mc2discord.shadow.reactor.core.publisher.Mono.subscribe(Mono.java:4490) ~[mc2discord-forge-1.20.1-4.2.3.jar%23729!/:4.2.3]
    at fr.denisd3d.mc2discord.shadow.reactor.core.publisher.FluxFlatMap.trySubscribeScalarMap(FluxFlatMap.java:203) ~[mc2discord-forge-1.20.1-4.2.3.jar%23729!/:4.2.3]
    at fr.denisd3d.mc2discord.shadow.reactor.core.publisher.MonoFlatMap.subscribeOrReturn(MonoFlatMap.java:53) ~[mc2discord-forge-1.20.1-4.2.3.jar%23729!/:4.2.3]
    at fr.denisd3d.mc2discord.shadow.reactor.core.publisher.InternalMonoOperator.subscribe(InternalMonoOperator.java:57) ~[mc2discord-forge-1.20.1-4.2.3.jar%23729!/:4.2.3]
    at fr.denisd3d.mc2discord.shadow.reactor.core.publisher.MonoFlatMap$FlatMapMain.onNext(MonoFlatMap.java:157) ~[mc2discord-forge-1.20.1-4.2.3.jar%23729!/:4.2.3]
    at fr.denisd3d.mc2discord.shadow.reactor.core.publisher.MonoPeekTerminal$MonoTerminalPeekSubscriber.onNext(MonoPeekTerminal.java:180) ~[mc2discord-forge-1.20.1-4.2.3.jar%23729!/:4.2.3]
    at fr.denisd3d.mc2discord.shadow.reactor.core.publisher.FluxMap$MapConditionalSubscriber.onNext(FluxMap.java:224) ~[mc2discord-forge-1.20.1-4.2.3.jar%23729!/:4.2.3]
    at fr.denisd3d.mc2discord.shadow.reactor.core.publisher.FluxFilter$FilterConditionalSubscriber.onNext(FluxFilter.java:247) ~[mc2discord-forge-1.20.1-4.2.3.jar%23729!/:4.2.3]
    at fr.denisd3d.mc2discord.shadow.reactor.core.publisher.FluxSwitchIfEmpty$SwitchIfEmptySubscriber.onNext(FluxSwitchIfEmpty.java:74) ~[mc2discord-forge-1.20.1-4.2.3.jar%23729!/:4.2.3]
    at fr.denisd3d.mc2discord.shadow.reactor.core.publisher.FluxMap$MapSubscriber.onNext(FluxMap.java:122) ~[mc2discord-forge-1.20.1-4.2.3.jar%23729!/:4.2.3]
    at fr.denisd3d.mc2discord.shadow.reactor.core.publisher.MonoPublishOn$PublishOnSubscriber.run(MonoPublishOn.java:181) ~[mc2discord-forge-1.20.1-4.2.3.jar%23729!/:4.2.3]
    at fr.denisd3d.mc2discord.shadow.reactor.core.scheduler.SchedulerTask.call(SchedulerTask.java:68) ~[mc2discord-forge-1.20.1-4.2.3.jar%23729!/:4.2.3]
    at fr.denisd3d.mc2discord.shadow.reactor.core.scheduler.SchedulerTask.call(SchedulerTask.java:28) ~[mc2discord-forge-1.20.1-4.2.3.jar%23729!/:4.2.3]
    at java.util.concurrent.FutureTask.run(FutureTask.java:264) ~[?:?]
    at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(ScheduledThreadPoolExecutor.java:304) ~[?:?]
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1136) ~[?:?]
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:635) ~[?:?]
    at java.lang.Thread.run(Thread.java:842) ~[?:?]
[06May2024 23:18:36.978] [fr.denisd3d.mc2discord.shadow.reactor-http-nio-8/INFO] [Mc2Discord/]: Mc2Discord started as Block Buddy#5842
DenisD3D commented 1 month ago

After more investigation, the Discord library doesn't support yet webhook for thread channels. See https://github.com/Discord4J/Discord4J/issues/1174 for progress.

Azn9 commented 1 month ago

After more investigation, the Discord library doesn't support yet webhook for thread channels. See Discord4J/Discord4J#1174 for progress.

A PR to fix that has been created: https://github.com/Discord4J/Discord4J/pull/1232 ;)

However, the second error is not related to this. A ForumChannel is not a TopLevelGuildMessageChannel. The first common type is BaseTopLevelGuildChannel. Please also note that a TopLevelGuildMessageChannel does not mean that threads can be created within, as a VoiceChannel is a TopLevelGuildMessageChannel but cannot have threads. This PR aims to partially fix this issue by adding a TopLevelGuildMessageWithThreadsChannel interface; however, ThreadChannel nor ForumChannel extends it. You will unfortunately have to change some logic in your mod :(

DenisD3D commented 1 month ago

Thanks for the update. TopLevelGuildMessageChannel was first used because it was common to all channels supporting text message, will make some change to support your feature as soon as it get merge :+1: