ncls.
Explore posts from serversReact to route change in layout
Hello,
I have a sidenav in my layout which has URLs depending on the route parameter.
So e.g. I have the URL
/items/12
and now my sidenav should have links like /items/12/buy
, however that only works if I reload since the layout is static. If I now navigate to /item/13
, the link will say /items/undefined
I tried using a computed like this:
But this results in the exact same behavior.
What can I do to prevent this?11 replies
PPrisma
•Created by ncls. on 7/12/2024 in #help-and-questions
How to reference/store a joined primary key?
I have a program that imports data from a CSV file into the database using Prisma. In the Excel the rows have something similar to an ID, a category and other non-important stuff. Since the ID is not unique in this CSV, I created a joined primary key in my schema file (
@@id([category, id])
).
Is there any way I can reference this joined primary key in a relation?
E.g.:
10 replies
DIAdiscord.js - Imagine an app
•Created by ncls. on 6/2/2023 in #djs-questions
deferReply not working on specific server
Hello.
We are running a small hosting service for Discord bots but one of our servers can't execute
editReply
from DIscord.js. Discord.py works just fine.
The bots just stay on "is thinking..." until that eventually times out. After around 35 minutes the console shows an API error "Invalid Webhook Token".
The weird thing is that everything else works fine and as I said, with Python bots it works as well. It's just the editReply
function on this one particular server.
Does anyone have an idea what the issue might be or how to solve this?26 replies
DIAdiscord.js - Imagine an app
•Created by ncls. on 11/3/2022 in #djs-questions
How to remove this listener in another file?
Hello,
So I have set up a listener like this:
notify.js
obviously includes the function that should get triggered once the voice state of the specific user updates.
Now I want to remove that listener again in another file later on. Issue is that I have no idea how to do that.
Can someone help?36 replies
DIAdiscord.js - Imagine an app
•Created by ncls. on 11/3/2022 in #djs-questions
removeListener of anonymous or imported function
Hello,
I am currently building a bot that notifies people when someone goes live in a voice chat.
The issue is, that when I want to remove the listener, I can't because it's an anonymous function. When I try to introduce an imported/required function, it crashes because
oldState
and newState
are not defined.
How can I remove the listener?
6 replies
DIAdiscord.js - Imagine an app
•Created by ncls. on 11/3/2022 in #djs-questions
How to check if a specific user is streaming (screen share or camera) in any voice channel?
Hello,
I'm currently trying to figure out how to check whether a specific user is streaming in any voice channel on the server. Streaming means either screen share or camera (If camera isn't possible, let me know)
What's the best way to do this? Currently I'm just listening to the user's
presenceUpdate
event.6 replies
DIAdiscord.js - Imagine an app
•Created by ncls. on 11/1/2022 in #djs-questions
Check if a custom emoji is a valid emoji my bot can use
Hello,
I'm trying to get my bot to check it the emoji code a user enters is a valid emoji that the bot can use in a button or not but I have no idea how to do that.
Does someone have a solution?
15 replies
DIAdiscord.js - Imagine an app
•Created by ncls. on 10/31/2022 in #djs-questions
switch statement not triggering in catch function
Hi,
I'm trying to handle errors when trying to fetch a message but it just doesn't run the switch statement.
Does someone have an idea why?
9 replies
DIAdiscord.js - Imagine an app
•Created by ncls. on 10/31/2022 in #djs-questions
Handle Subcommands in SubcommandGroups
Hello,
I'm working with SubcommandGroups atm and I'm trying to figure out how I can handle SubcommandGoups aswell.
The issue is that I'm loading my commands and Subcommands into collections as every bot tutorial tells you to.
Now I have
client.slashCommands
and client.subcommands
as collections for my commands. Now, how do I properly manage subcommandgroups in there as well so that it's still clear to what subcommand they belong?
Does it make sense to store them as an object? Like
10 replies
DIAdiscord.js - Imagine an app
•Created by ncls. on 7/27/2022 in #djs-voice
Somehow getVoiceConnection(guildId) returns undefined
Well, as the title already says, Somehow
getVoiceConnection(guildId)
returns undefined.
I'm following this tutorial: https://youtu.be/oRWAuXqCuYA?t=841 (Timestamp is where the function is used).
Node v16.14.2
discord.js v14.0.3
discordjs/voice v0.11.06 replies