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
d.js toolkit
d.js toolkit2y ago
• 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.
Siris
Siris2y ago
the nextjs backend is serverless it won't be feasible with the normal discord.js library
RajGM
RajGMOP2y ago
Should I host the discord bot in some nodejs server and then call it from nextjs server?
Siris
Siris2y ago
What are you trying to do?
RajGM
RajGMOP2y ago
A backend that stores some data to firebase from client then send those data to discord server
Siris
Siris2y ago
so you just need access to the firebase backend on your website, right?
RajGM
RajGMOP2y ago
yes
Dave Blunts
Dave Blunts2y ago
@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
Siris
Siris2y ago
Yes, you could but its a bit more complex to setup
Dave Blunts
Dave Blunts2y ago
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
Siris
Siris2y ago
but also if you want to use djs you can host the bot on a nodejs server and access firebase only on the website
RajGM
RajGMOP2y ago
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?
Dave Blunts
Dave Blunts2y ago
@rajgm you could probably just use a webhook if all you want is to send data from a nextjs server to a discord channel
Siris
Siris2y ago
yeah, also you can use a webhook bot, which only recieves interaction events on nextjs
RajGM
RajGMOP2y ago
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.
Dave Blunts
Dave Blunts2y ago
yes <@id> thats how you tag someone with a bot at least thats how i do it
RajGM
RajGMOP2y ago
yes concerned with this
Dave Blunts
Dave Blunts2y ago
ye
RajGM
RajGMOP2y ago
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 👌
Want results from more Discord servers?
Add your server