discord.js in nextjs
Answered
basic posted this in #help-forum
basicOP
everytime i try to use or even import discord.js my application breaks. but i dont know how to fix it 😭 maybe someone can help me
Answered by gin
29 Replies
What are you using discord.js for in instrumentation.ts?
Instrumentation is used for multiple runtimes, you need to check which runtime is running:
https://nextjs.org/docs/app/building-your-application/optimizing/instrumentation#importing-runtime-specific-code
Instrumentation is used for multiple runtimes, you need to check which runtime is running:
https://nextjs.org/docs/app/building-your-application/optimizing/instrumentation#importing-runtime-specific-code
Discord.js seems to be a node-specific package
American black bear
discord.js is (primarily) for discord bots, which are persistent processes, what are you trying to implement in next with it?
@basic everytime i try to use or even import discord.js my application breaks. but i dont know how to fix it 😭 maybe someone can help me
You can't use discord.js in next.js
Thats a simple explaination
You need a plain node.js app
and for hosted, you can just purchase a bot hosting, which would only go like for $1-2/month
@American black bear discord.js is (primarily) for discord bots, which are persistent processes, what are you trying to implement in next with it?
basicOP
i want to get the member Informations like activities
@Julienng What are you using discord.js for in instrumentation.ts?
Instrumentation is used for multiple runtimes, you need to check which runtime is running:
https://nextjs.org/docs/app/building-your-application/optimizing/instrumentation#importing-runtime-specific-code
basicOP
it was just for trying smth
@Anay-208 You can't use discord.js in next.js
basicOP
okay thanks
i was wondering why it doesnt work for me cause some repos on github use discord.js
@gin use the api
basicOP
the api doesnt send any activities
https://discord.com/developers/docs/resources/guild#get-guild-member this one only response with a guild member object
maybe there is an endpoint but i didnt find it
@gin https://discord.com/developers/docs/topics/gateway#activity-object-activity-structure
basicOP
this one does respond with the activities from the user?
Answer
basicOP
ill look
@basic ill look
but as the guy above said listening for events is a continuous operation and cant be done in a event driven project, so u have to selfhost an api that runs on serverside
discord.js is just a wrapper of the discord api
@basic okay thanks
np, make sure to mark my answer as solution
v
@basic this one?
yup, if that answered ur question
❤️
basicOP
👍