[DiscordArchive] It definitely works, even with eluna-ts.
[DiscordArchive] It definitely works, even with eluna-ts.
Archived author: Honey • Posted: 2024-07-05T20:43:37.283000+00:00
Original source
It definitely works, even with eluna-ts.
Maybe you're using an environment that's not aware of it?
Archived author: johnford2002 • Posted: 2024-07-05T20:49:28.233000+00:00
Original source
Certainly possible, I've had issues with VS Code recognizing the types with the default configuration contained in the `acore-docker` project.
Archived author: johnford2002 • Posted: 2024-07-05T21:02:35.083000+00:00
Original source
K, so it definitely works if I write it into the outputted eluna-ts.lua file, so it IS present. It must have something to do with the TS config.
Archived author: johnford2002 • Posted: 2024-07-05T21:18:05.711000+00:00
Original source
Any idea what types would be missing? I don't see any references to HttpRequest in either of `@azerothcore/eluna-ts-lib` or `@azerothcore/eluna-ts-definitions`.
Archived author: Roboto • Posted: 2024-07-05T21:20:52.764000+00:00
Original source
The TS definitions are pretty out of date and incorrect at times
Archived author: Roboto • Posted: 2024-07-05T21:21:06.511000+00:00
Original source
it's been on my todo list for a while
Archived author: johnford2002 • Posted: 2024-07-05T21:22:28.945000+00:00
Original source
I tried declaring a type locally, which does make TS happy, but the resulting Lua output wants to inject `nil` as the first passed argument instead of the HTTP method argument.
Archived author: johnford2002 • Posted: 2024-07-05T22:02:36.414000+00:00
Original source
Hmm... seems like adding `this: void` to the start of the signature eliminates that issue, but it persists with other declared global functions like `GetPlayerByGuid()`, as I think they suffer from the same problem.
Here's where I landed to get the resulting lua script to actually work:
```
declare function HttpRequest(this: void, method: string, url: string, cb: any): void;
declare function GetPlayerByGUID(this: void, guid: number): Player;
export const OnPlayerRequest: player_event_on_chat = (
event: number,
player: Player,
msg: string
): string | boolean => {
if (msg == "#example") {
const playerGuid = player.GetGUID()
HttpRequest("GET", "https://random-word-api.herokuapp.com/word", () => {
const callbackPlayer = GetPlayerByGUID(playerGuid)
callbackPlayer.SendBroadcastMessage("Hurray!")
});
}
return true;
}
```