http(...) Uncaught exception in thread, NullPointerException: null
GunnyWaffle opened this issue · 4 comments
I'm using http(...)
to send my Minecraft chat to my Discord server via webhook, utilizing Discarpet's __on_chat_message(...)
event. It works flawlessly using the code below, but every time a response comes back a NullPointerException occurs.
__on_chat_message(message, player, command) -> (
if (command, return());
body = {
'content' -> message,
'embeds' -> null,
'username' -> player,
'avatar_url' -> (global_head_api + player~'uuid'),
};
http('POST', global_webhook, 10000, 10000, encode_json(body), _(r)->print(r));
);
This prints in the server console. It is worth noting that the error occurs at the same moment the webhook displays in Discord.
[19:51:45] [Server thread/INFO]: <GunnyWaffle> error repro test
[19:51:46] [Thread-484/ERROR]: Uncaught exception in thread "Thread-484"
java.lang.NullPointerException: null
I've tried many things to see if this is my doing, but nothing works.
I'm not sure if this is related, but I had another NullPointerException occur. This time resulting in the webhook not having an avatar, but otherwise functioning as expected.
[20:13:35] [Thread-455/ERROR]: Uncaught exception in thread "Thread-455"
java.lang.NullPointerException: Cannot invoke "carpet.script.value.Value.reboundedTo(String)" because the return value of "java.util.List.get(int)" is null
at carpet.script.value.FunctionValue.execute(FunctionValue.java:238) ~[fabric-carpet-1.18-1.4.56+v211130.jar:?]
at carpet.script.value.FunctionValue.callInContext(FunctionValue.java:157) ~[fabric-carpet-1.18-1.4.56+v211130.jar:?]
at ScarpetAdditions.ScarpetFunctions.lambda$apply$2(ScarpetFunctions.java:101) ~[scarpet-additions-1.18-1.4.56.jar:?]
at java.lang.Thread.run(Thread.java:833) [?:?]
Subsequent messages went POSTed without issue. This occurred once.
Thank you, i will look into them.
This looks like an issue with the callback function. I will do the same as i will do with Discarpet, removing all callbacks, making the function blocking, for use in a task().