Dragory / modmailbot

Modmail Bot is a bot for Discord that makes it easier for users to contact moderators and admins for help.
MIT License
709 stars 703 forks source link

Bot shutting down #90

Closed xJustxMegx closed 6 years ago

xJustxMegx commented 6 years ago

image How can I fix this?

Dragory commented 6 years ago

It looks like a modmail thread's channel was deleted before/while the thread was being closed. Does this happen every time you start the bot, or on some specific action? And can you reproduce it, or did it only happen once?

xJustxMegx commented 6 years ago

Hey,

It happens only when we close a channel. So I moved it to another folder, but the older logs aren't being opened again, is there a way to get them from the server and put them local on my computer?

xJustxMegx commented 6 years ago

New issue... https://oowoo.club/gockzjmp.jpg

xJustxMegx commented 6 years ago

[NOTE] Creating new thread channel dropbox-0001 Closing thread 3c9463e4-b10c-4c00-945e-327f1598c91f Deleting channel 465225585317249035 [INFO] Auto-closing thread with Dropbox#0001 because the channel no longer exists Error: DiscordRESTError [10003]: Unknown Channel Again, when the thread was there.

Dragory commented 6 years ago

That looks weird. The bot appears to be auto-closing the thread that you just closed, and it shouldn't auto-close a thread unless you had an unclosed thread and deleted its channel.

I could see some network lag causing a race condition, leading to this. Do you (or the server) generally have any network issues (slowness, etc.) with Discord?

xJustxMegx commented 6 years ago

Hey,

Server is working fine for me, only had problems with the npm today after a reboot, but stuff worked good before.

xJustxMegx commented 6 years ago

It happens also, when I close other threads.

xJustxMegx commented 6 years ago

A fix would be great, we can't keep restarting the bot. @Dragory

xJustxMegx commented 6 years ago

It's trying to auto-close a thread when I use the /close command.

xJustxMegx commented 6 years ago

Running it with pm2 now.

Dragory commented 6 years ago

I'd love to fix the issue you're having, but I'm not sure how to reproduce it. If you'd like to experiment a bit to find a proper solution (instead of auto-restarting every time a thread is closed), could you do a fresh modmail install and only set the required config options (token/server ids), and see if that works?

xJustxMegx commented 6 years ago

Hey, then it works fine.

Dragory commented 6 years ago

Hmm, can you post your config file (without the token)?

xJustxMegx commented 6 years ago

https://oowoo.club/55e0eymg.png getting this now, on a new one.

Config: `{ "token": "", "mailGuildId": "458910463070044161", "mainGuildId": "458910463070044161", "logChannelId": "462666043941191680", "prefix": "/", "newThreadCategoryId": "462661219824697426", "snippetPrefix": "/", "typingProxy": "true", "typingProxyReverse": "true",

"status": "Hulp nodig? Stuur een DM!", "responseMessage": "Bedankt voor je bericht, iemand van de staff zal je zo snel mogelijk van een antwoord voorzien." }`

xJustxMegx commented 6 years ago

Best support ever, not.

Dragory commented 6 years ago

I'm currently on vacation, so I'm not answering github issues. I'll get back to you later this week or early next week.

Keep in mind that I'm making and supporting this bot on my free time, without making a dime from it. Considering that we've already had a lot of back and forth in this issue, I think it's pretty rude to make snarky remarks when I haven't replied to you for a week.

That being said, just to confirm, the config you posted was the one with the issues, right? And when you only had the required options set (with a fresh install), everything worked fine? Could you try the "fresh" config with the main bot installation and see if that works? If it does, can you start adding back your config options one by one, and see when it breaks? I'll look into it in more depth after my vacation, but we might make some progress in the meanwhile like this.

JonasPardon commented 6 years ago

Can you be any more self-entitled here. This is obviously an issue that Dragory can't fix just like that if he can't reproduce it himself. Dragory owes nothing to anybody here. I suggest you make your own bot if you think this isn't sufficient.

xJustxMegx commented 6 years ago

@JonasPardon smh, don't make a bot if you don't give support. :/

Like, he's on a holiday, so it's ok now and now I wait.

JonasPardon commented 6 years ago

Don't be so dense. He's not hosting it or anything. He just likes coding something and putting it up here for public use, that still doesn't mean he owes you anything at all.

xJustxMegx commented 6 years ago

Can't open attachments too....

Dragory commented 6 years ago

I still haven't been able to reproduce the issues you mention in this thread (except the EADDRINUSE one - that's usually because there's an old bot process running in the background when you run a new one, so it's trying to use the same port).

For the original channel issues: Can you make a fresh installation of the bot with only the required config options, see if it works, and then keep adding your old config options and restarting until you start seeing the channel issues again? If you get the EADDRINUSE error, make sure you only have 1 bot process running (check Task Manager for old node.exe processes).

For the attachment problem: I'll need more details on this. What exactly happens? Is there a black page, a browser error, an error in the console?

And finally: This bot is not the main priority in my life. I will answer to issues here when I have time. The bot is provided as-is, and I have not promised any specific level of support. Contrary to what you seem to believe, creating a bot does not come with an obligation to provide support for it, but I'm doing that anyway - however, I'm doing it on my terms, when I can. If you can't accept this, you're free to use another bot instead, but don't start complaining in unrelated issues.

xJustxMegx commented 6 years ago

Fresh install, default config, on a other folder gives the error I said earlier, somehow. PM2 works fine for me.

ERR_EMPTY_RESPONSE for the attachment issue.

Dragory commented 6 years ago

You're getting the EADDRINUSE error even when there are no other node.exes running? The error only means that the port (8890) is already in use by another process, so that other process needs to be shut down first.

xJustxMegx commented 6 years ago

Even on a other folder? :S And when I stop the bot I cant start it...

Dragory commented 6 years ago

Yeah, the port needs to be unique on the same machine, regardless of the folder. You can use the port config option to change the port to something else in the new folder, e.g. 9000. When you say you "can't start it", are you getting the EADDRINUSE error or something else?

xJustxMegx commented 6 years ago

Not getting a error now for the second one, but I'm scared to shutdown the main one now...

Dragory commented 6 years ago

Okay, what if you start moving over your config options one at a time from the main one? Is there a point where it stops working?

xJustxMegx commented 6 years ago

No, but when I stop it, does it keep running a node?

Dragory commented 6 years ago

When you close the window, it should close the Node.exe process as well, though I remember there was a bug at one point where it didn't. I recommend confirming it's actually shut down in task manager.

xJustxMegx commented 6 years ago

Stuff works fine now, but attachments doesn't seem to be saved on the vps?

Dragory commented 6 years ago

Are the attachments not being saved at all, or are the attachment links not working? Does this happen on both the old installation and a clean installation?

xJustxMegx commented 6 years ago

The links aren't working and the new version isn't tested anymore, but the old keeps crashing without pm2.

Dragory commented 6 years ago

And there's also nothing in the bot's attachments folder (in the bot's folder)?

xJustxMegx commented 6 years ago

There is, and I'm scared too reinstall it because we can't lose the logs.

xJustxMegx commented 6 years ago

Also on the other bot, same issue.

Dragory commented 6 years ago

So what happens when you try to open an attachment link?

xJustxMegx commented 6 years ago

Deze pagina werkt niet x heeft geen gegevens verzonden. ERR_EMPTY_RESPONSE

xJustxMegx commented 6 years ago

Attachments arent getting an extension on the vps when they are saved.

Dragory commented 6 years ago

That is intended. The extension and mime type are based on the attachment's data from Discord and should be served properly via the URL. When you get ERR_EMPTY_RESPONSE, is there an error in the console at the same time?

xJustxMegx commented 6 years ago

Yeah, something with mime. Running it now with npm because we cant have crashes.

Dragory commented 6 years ago

What's the exact error?

xJustxMegx commented 6 years ago

image Here you go.

Dragory commented 6 years ago

I released a new update yesterday that also updated that specific line. Can you give it a try?

xJustxMegx commented 6 years ago

Can you tell me how I update it without losing stuff?

Dragory commented 6 years ago

I'll write some update instructions in the README later. The TL;DR is:

  1. Shut down the bot
  2. Take a backup of the db/data.sqlite and config.json files and the attachments folder
  3. Download the latest release from the releases page and extract the files over the old ones
  4. Start the bot. If any of the files you backed up went missing for some reason, restore them from the backup.
xJustxMegx commented 6 years ago

Does this keep the snippets?

Dragory commented 6 years ago

Yes - snippets, logs, and other bot data (apart from attachments) are kept in db/data.sqlite. That's the most important file to back up!

xJustxMegx commented 6 years ago

Amazing! Are now also able to make snippets to be anonymous?

Ok, fixed that issue; but a timed close doenst give a response.

Dragory commented 6 years ago

You seem to have "closeMessage:" twice there. It should be just:

"closeMessage": "Bedankt dat je contact...",
xJustxMegx commented 6 years ago

Alright, everything seems to work now! Thanks so much, you can close this one.