Discord.py on glitch

i’m actually trying to host my own bot (done with discord.py and mysql) on glitch but i don’t found any official documentation on that…there is something like that?otherwise is there a good guide to host properly a discord bot on glitch?
thanks so much(sorry if my question is stupid i have no experience in hosting)

1 Like

There is no official documentation on this, to my knowledge. You can create a start.sh or glitch.json file with the command Glitch needs to execute for your bot to become online. If you use a start.sh file, you may need a requirements.txt file for Glitch to understand it is a Python project. (I recommend keeping the requirements.txt file empty or Glitch may install the required modules every time your project wakes up (if your project is not boosted).) You will also need to install Discord.PY with PIP using the project terminal. If you use a glitch.json file, it should look like this-

{
  "start": "python <file-name>"
}

If you use Python 3, then you will need to replace python with python3 since the default Python version on Glitch is 2.

1 Like

only one more thing:
there is a speed way to launch my .sql file with mysql?
i’m gonna try your advices thanks^^

Edit: i’m having troubles using mysql…i mean…there is a default password and username to use?I tried to enter root with no password but that fails…

What are you trying to use MySQL for?

For the database of my bot…i need to enter into the mysql prompt tu run with the SOURCE command a .sql file who will create the database and all the tables…but when i attemp to run mysql command he deny the access for my user and if i try to access with mysql -u root -p he ask for a password that i haven’t

I am afraid I do not know about this. But I have moved this to #discord-help, anyway so that you can get better help.

Based from the hello-rust boilerplate, running non-Javascript on Glitch means you have to upload all of the packager files yourself and then install the language.

I think you mean package.json? You can change this part:

  "scripts": {
    "start": "python <file-name>"
  },

Note that the packager JSONs have their keys as strings.

You cannot host a mysql server on Glitch to my knowledge. I think you have to use a file based one like sqlite

Yes you can! @localhost

No, glitch.json is a feature. Try searching for it yourself (here on the forum) and ask me if you do not understand.

1 Like

Oh, I see. What regex parser/grammar does it use?

lamp-poc has a mysql server somehow which is how I ran a very unreliable wordpress instance see


aboutDavid has also tried improving upon mine

Thank you so much for all this support, i’ll try all those things this morning and if I fail i guess i’ll switch to sqlite for the begginning
edit: when i try to connect to mysql with ‘mysql -u root’ i get the current error
$ mysql -u root
ERROR 2002 (HY000): Can’t connect to local MySQL server through socket ‘/var/run/mysqld/mysqld.sock’ (2)
is that normal and i need to do seomthing to avoid this error or i done wrong something?

Could you please clarify your question?

Sorry! :sweat_smile:. I meant the glitch.json file - it has things like \\.extension which I don’t understand…

The mysql credentials for Glitch are:

Username: gomix
Password:

(there isn’t a password)

1 Like

I tried ti login with “mysql -u gomix” and he answer me always with the same error(ERROR 2002 (HY000): Can’t connect to local MySQL server through socket ‘/var/run/mysqld/mysqld.sock’ (2)) without asking password and if i do “mysql -u gomix -p” he ask for a password(i enter without doing nothing) and just after that he said me the same error
i don’t understand what does mean

The project you are using probaly doesn’t start a mysql server. You could take the time to see how lamp-poc starts mysql though