discord bot in same server as NEXTJS Backend
How to make (export) discord bot to be alive (import) to rest of the NEXTJS server files?
19 Replies
• What's your exact discord.js
npm list discord.js
and node node -v
version?
• Post the full error stack trace, not just the top part!
• Show your code!
• Explain what exactly your issue is.
• Not a discord.js issue? Check out #useful-servers.the nextjs backend is serverless it won't be feasible with the normal discord.js library
Should I host the discord bot in some nodejs server and then call it from nextjs server?
What are you trying to do?
A backend that stores some data to firebase from client
then send those data to discord server
so you just need access to the firebase backend on your website, right?
yes
@rajgm you could always just make an http bot to send the data to a discord server
much less resource hungry
for a bot that doesn't need all the features of d.js
Yes, you could but its a bit more complex to setup
if all you use it is to send a message
or you could even opt for webhooks
i think webhooks would be the best option
but also if you want to use djs you can host the bot on a nodejs server and access firebase only on the website
that means I need to create another server with some keys and discordbot on the same server
expose it to the first server
is nodejs server fesible for the discord bot for websocket connection all the time?
@rajgm you could probably just use a webhook if all you want is to send data from a nextjs server to a discord channel
yeah, also you can use a webhook bot, which only recieves interaction events on nextjs
is it possible to tag someone in discord server with webhooks?
I think with webhook I can't check if a member exists in discord server.
yes
<@id>
thats how you tag someone with a bot
at least thats how i do it
yes
concerned with this
ye
Thanks a lot, enf and siris.
got it.
use webhook to send message to server
but use rest with discord bot to check member
got it.
only trouble in using bot in NEXTJS backend will be that the bot will be connecting and disconnecting to the server with each request.
am i correct?
but with rest we had to wait for client.on('ready', ... ) to perform any actions?
yes, i was confusing discordJS with the native rest endpoints
I can use the sub-package @discordjs/rest to send and get guild members without worrying about connection issues
👌