Next.js Discord

Discord Forum

discord.js in nextjs

Answered
basic posted this in #help-forum
Open in Discord
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

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
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?
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
@Anay-208 You can't use discord.js in next.js
okay thanks
i was wondering why it doesnt work for me cause some repos on github use discord.js
@gin use the api
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
this one does respond with the activities from the user?
Answer
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
❤️
👍