Discord Bot not working - Command not found
Hi there, I am new to discord coding, as well as python and all the modern stuff regarding deploying of such kind of things. So I also do not yet have a real clue how these things are working out in railway.
I just created an account and moved my python dicsord bot from replit to github. Then I connected my repo and deployed it. For this I used the discord python bot template.
The bot is running and connects to discord - but it is not working at all unfortunately. The command is not found and hence the autocompletion not working.
Any idea what I can do about this? I can also post source, error messages etc. - just let me know what is needed.
(A quick search for the term "bot" at the search here top right resulted in 0 entries for me unfortunately).
Project ID: 8c1db389-9532-4ead-9ee9-2f4b19a5334c
Thank you in advance!
42 Replies
Project ID:
8c1db389-9532-4ead-9ee9-2f4b19a5334c
Project ID: 8c1db389-9532-4ead-9ee9-2f4b19a5334c
if you deployed the template then you arent running your code, you would be running the template's code
Hmm, but I had to connect my repo for it. How can I get this solved to let it run my code?
show me a screenshot of the source in your service settings please
Ah, it is connected to the cloned repo:
Is it enough to just change the Repo here?
is that source repo correct?
Yep, it is the cloned one railway created where it uploaded the template code.
it is a private repo though (ATM)
right but if its the template code, then its not your code
so disconnect both the source and upsteam then connect the correct repo that contains your code
And in order to get it started do I have to create a requirements.txt as well as a Procfile too?
yes otherwise railway isnt going to know what to install or run
and is the root directory the root of the repo or where the .py files are in (Since it says "where we should look for your code")?
yes thats correct, you likely would not need to touch that
Can I also create the requirements.txt out of railway? Did not yet use one when being on replit.
the requirements.txt would need to exist within your github repo
I know. Just trying to get it created since so far was developing in the cloud. I will check back with replit to get it created there and then upload it into the repo.
saw that
sry
will repost:
Sry for asking all that nearly OT stuff: How are railway deployments working in general and in particular? Is there any documentation or good readup for this by chance? Would like to know a little bit about what is going on behind the curtain of all that magic. 🙂
heres a high level overview - https://docs.railway.app/maturity/philosophy#high-level-architecture
but if you have any specfic questions i can do my best to answer them
Thank you very much. Maybe I will get back to this.
Unfortunately the freeze on replit did not work entirely. The dotenv package is not listed in my requirements.txt nor is the os package. Now my bot fails with ModuleNotFoundError: No module named 'dotenv'
Is there any default I can use or any other way to get this one solved?
dont use dotenv, its not needed on railway since the service variables are injected directly into the container
and the os package is stdlib so that shouldn't be in the requirements.txt file anyway
oh IC. So accessing the variables via os.getenv("TOKEN") would be sufficient without importing anything?
you would still need to import os, but you would not need dotenv
sry next question already: I have a JSON data file in my data directory which is in parallel hierarchy to my .py file inside the src directory. But it cannot be found during loading.
So this is how the directory structure looks like (screenshot). And this is how I try to access the JSON file within my .py file (2nd screenshot).
But it can't be found. So in which directory is the running program looking for it? I.e. in which directory are we in when the application is started?
In the root since in Procfile it says: web: python src/cardBot.py?
you have not touched the root directory in the service settings right?
can you share your repo so i can take a closer look?
sure - I can make it public maybe.... So here you are: https://github.com/RrTe/RedemptionCardBot
GitHub
GitHub - RrTe/RedemptionCardBot: Discord bot for the Redemption Car...
Discord bot for the Redemption Card Game. Contribute to RrTe/RedemptionCardBot development by creating an account on GitHub.
well you see, there is no json file in the data folder
Huh? I uploaded it. Just a sec ....
Ouf! I forgot to commit the upload! Douh!
Ok, so at least ../data/carddata.json can still be not found. Will try now with: data/carddata.json
That seems to work - but now I am getting an error I never got before:
No clue whats wrong here. That code ran fine so far..
what version of python is replit running your code with?
3.10.13
So do I have to omit the -> part?
no, let's try getting railway to run your code with python 3.10 since 3.8 is the default
IC
add a runtime.txt file with
3.10
in itin root directory?
Finally I got it done! Great! Thank you so much! The bot is up and running now.
So if I understand correctly it will be up and running there 24/7 now?
24/7 until you run out of credits, then you will need to upgrade to the hobby plan
what happens if I run out of credits? Will it be shut down or slowed down?
shut down
😦 too bad. But thank you again for your great help! Awesome!
why too bad?
is the hobby plan not something you would be upgrading to when the time comes?
Need to check it out.