[Resolved] Discord bots are working fine in the editor but are offline in Discord servers


#1

Both my friend and I host our Discord bots on Glitch, and our bots have worked fine until recently.

First, her bot suddenly went offline and she couldn’t figure out why. All the files were correct and there were no errors in her code. In the log, instead of seeing the ‘Ready!’ message, she gets the message ‘Your app is listening on port XXXX.’

I recently tried to create a new bot and everything went fine until I had the same issue. The bot has never come online, and I’m getting the same ‘Your app is listening on port XXXX.’ message.

I’ve tried running enable-pnpm, as well as npm rebuild and pnpm rebuild like I saw in another thread. None of these commands worked. What’s going on?


#2

Your project is working, at least it’s listening on a port as indicated by the message you’re seeing in the log. Perhaps your bot code isn’t in the same file as that being called to run the server. Without seeing your code it’s impossible to tell. Let us know the project name and we’ll take a look. If your project is private, either make it public temporarily or DM me a join link so we can view the code. Thanks.


#3

Sure thing! The project name is please-work-connor-v3 (don’t mind the stupid name haha). My friend’s is private and I’m unable to provide hers currently.


#4

It’s as I thought - in package.json you have "start": "node server.js" which starts server.js when the app loads. Server.js creates an Express server in order to serve a webpage, but it looks like your bot code is in the file index.js and that’s not referenced in server.js so your bot doesn’t start. You need to update the start command in package.json to call index.js like so: "start": "node index.js" and then in index.js require(’./express.js’) file, which is some code that makes the project listen on a port and keep the project awake. And then add in the discord modules you’re using in package.json. Take a look at https://glitch.com/edit/#!/cloudy-william where I’ve made these changes for you.


#5

That solved the problem! Thank you so much!