Kawaxte
Kawaxte
Explore posts from servers
DDeno
Created by Kawaxte on 6/26/2024 in #help
How to define local import maps?
I got these things in the tests above:
import { assertAlmostEquals, assertEquals } from "@std/assert";
import { Vector2 } from "../src/math/mod.ts";
import { QUARTER_PI } from "../src/utils/math.util.ts";
import { assertAlmostEquals, assertEquals } from "@std/assert";
import { Vector2 } from "../src/math/mod.ts";
import { QUARTER_PI } from "../src/utils/math.util.ts";
Notice how I have to do a lot of ./ js to get to the next? I understand there'st the "imports": {}" support in deno.json(c), and I do remember using smth like Bun's package.json's "workspace": [] system to create localised @one/two, complete with index.ts in their respective folders for exports. Are there are examples on defining local import maps?
35 replies
DIAdiscord.js - Imagine an app
Created by Kawaxte on 5/21/2024 in #djs-questions
Unwrapping `Promise<x>` where `void` expected?
Hi. It's my first time moving to TypeScript from Rust (serenity+poise->discord.js) and I am trying to handle a GuildUpdate event where ownership has been transferred to another. It seems that doing this gives me a Promise<string> which I can't seem to unwrap.
const oldOwnerUsername = await client.users.fetch(oldGuild.ownerId).then(user => user.username);
const oldOwnerUsername = await client.users.fetch(oldGuild.ownerId).then(user => user.username);
When attempting to do so, it asks me to async the part after the event, like so:
client.on(Events.GuildUpdate, async (oldGuild, newGuild) => {
// ..
}
client.on(Events.GuildUpdate, async (oldGuild, newGuild) => {
// ..
}
...but then, it tells me that it expects a void return? In serenity, I just made a function async and handled everything else by calling .await or .await? at the end, depending on whether or not something was a Result<x, y> or not. How exactly am I able to handle the case here?
51 replies