Forums

Issues with Discord Bot

So I have been working on a Discord bot and trying to get it hosted here, I have had some success, but there are also some bizarre things that are happening.

The problem isn't that I can't get it to work, the issue is that I can't get it to STOP working.

I essentially have one large .py file that uses discord.py (which is based off of asyncio) and when I run that one file through the console, it runs fine. The task eventually dies at somepoint in the future, which I expect because it's just a script. So I can't really do what I want to do with a file/bash console. So far no problems.

My next idea was to host it as a website, in the hopes that it would run longer and I could use the reload button if it has issues. So I copied and pasted the code into the __init__ file of a new website. This seemed to work fine as the script runs longer and the reload button was working. Then I got some odd results, I would update the code, and would use reload and I would get a message that said there was an error reloading the web app. It would also not stop the web app from running, meaning I have a website running my code that I have no way of stopping. Eventually it stops, but I have absolutely no control over when or why it stops. I deleted the web app, deleted the directory with the code in it, and the app still runs. As of right now I have 0 running process, 0 web app, 0 consoles, and 2 running discord bots that I can't stop.

Next thing I tried was an Always-On Task, witch sounds almost exactly like what I want to use. With this I have had no success at all. I set up the command to be python3.6 home/ArtificialBadger/DOER.py which is a link to my main discord bot file. But no matter what, I can't get it to get passed the Starting phase.

So as far as I can tell, there is no way I can reliably host a Discord bot on here. Anyone else experiance anything similar, or know how to solve any of these issues? I would love to use the Always on Task if possible so I don't have to manually restart.

You're right that an always-on task is exactly the right tool to use for a bot. I think the problem you had when you tried to use one was that you'd asked it to run python3.6 home/ArtificialBadger/DOER.py rather than python3.6 /home/ArtificialBadger/DOER.py -- note the extra "/" at the start of the path to a script. A path that does not start with a slash is interpreted by bash as a path relative to its current working directory, which for an always-on task, would be your home directory, so the path Python was trying to run was /home/ArtificialBadger/home/ArtificialBadger/DOER.py.

The reason the task appeared to be stuck in a starting state was because it was continuously crashing -- the always-on task system started it, ran for a few milliseconds (long enough for Python to print "file not found"), then it crashed, and was restarted a few minutes later.

A good place to look when trying to debug issues with always-on tasks is the task's log file. There's a link to it on the table where you set up the task -- it's the first button in the set of buttons next to the task's command. You also might find the help page useful.