Nemokosch
Explore posts from serversSIASapphire - Imagine a framework
•Created by Nemokosch on 8/5/2024 in #sapphire-support
Statefulness and data sharing for Pieces
Hi,
let's imagine the following: you want to keep track of some data about the people who join and leave a certain voice channel. It would be convenient to store this data alongside the listener and maybe provide an interface to it directly from the listener.
However, it's not fully clear how and when Pieces are instantiated. There are no examples of holding (let alone sharing) any state. How to do this right?
1. is it okay to hold state in a Listener instance?
2. if so, how to access the very same instance somewhere else?
3. if not, what to do instead? Exposing all that data via the container sounds quite painful because that's very far from encapsulated. What would you do to expose some data managed by a certain event handler?
52 replies
DIAdiscord.js - Imagine an app
•Created by Nemokosch on 3/2/2024 in #djs-voice
Why does @discordjs/opus only build properly with yarn?
Hello,
I'm not sure how much this is an "issue" because I mostly used yarn anyway but I noticed when I tried to switch to Bun that neither with Bun's built-in package manager, nor with npm, @discordjs/opus is not really built, and I get a runtime error repording that the built version is missing, along with opusscript and node-opus.
Is there something weird going on or is this a known thing? I really wonder because unlike npm, yarn has a "linking stage" for a couple of my native dependencies so it seems like npm just downright doesn't do something necessary.
63 replies
DIAdiscord.js - Imagine an app
•Created by Nemokosch on 8/17/2023 in #djs-questions
Typescript build failure
Hello,
using Typescript 5.1.6 and a one-liner index.ts that imports (version 14.12.1) discord.js, I get two compiler errors from the typings of the library:
version 14.11.0 had no similar problem.
Is there something I should check about the environment? Is this a known problem?
3 replies