#Hmmm how do I fix this?
1 messages · Page 1 of 1 (latest)
I have
import { http } from "@minecraft/server-net";
request.method = HttpRequestMethod.POST;```
Etc
because you have to import HttpRequest, not http
http is nothing
but since you'd likely be needing to use everything in the server-net module, do
import * as http from "@minecraft/server-net"
and then
var req = new http.HttpRequest(url)
nope http is a pre-set http client
meh
aight so apparently request.body does not have a native handle?
any ideas?
ive been trying for hours 😂
code?
function sendDiscordWebhook(message) {
var tempplayer = world.getAllPlayers()[0]
tempplayer.runCommandAsync(`say ${message}`)
var request = new http.HttpRequest(webhookUrl)
request.method = http.HttpRequestMethod.POST
var data = { "content": message, "username": "PlayerPSB", "avatar_url": avatar_url }
request.headers = [new http.HttpHeader("Content-Type", "application/json")]
try {
request.body = data
} catch (e) {
tempplayer.runCommandAsync(`say ${e}`)
}
http.request(request)
}```
ive literally tried so many things
uhhh holdon
i sent a working json request example in here https://discord.com/channels/523663022053392405/1084944676374716516
btw 3 questions:
- why var, u should use const/let
- why tempplayer
- why runCommandAsync to do /say instead of world.sendMessage
I managed to get chat ranks and custom emojis working - thats about all we could do lol
server-net is generally pretty stupid
gotcha
so you should get some experience with other parts of the script api first
I have a decent amount of python knowledge - its just transferring it over lol
ew python
wowww
lol
lol
i hate that snake
always been envious of the JS writers tho - web based programs are goated
especially the syntax
nah the syntax is bliss for me lmao
lol js sucks too just less
on that note, ts ftw
i love typescript lol
oh btw you are on bds right
lool it was ts that i used with gametest - idk i just wanted to learn js too
server-net only works on there
yus
hm
ts is just better js
I moved from shockbyte to Bisect cos omg shockbyte is shocking
you should come use my hosting lulw
its in my about me if you wanna check it out, don't want to advertise in here
lol
lmao
arghh
i hate that there isnt sync methods for webrequests in server-net
async is kinda buggy with the scripting api
fr
things take a lot more time than they should for some reason
i get like 50ms ping with these webrequests just because of how mc handles async
YASSS it worked
lol nice
np lol
<:emojiname:emojiid>
if u mean on discord
yuss