Discord Bot not working - Command not found
Anonymous
TRIALOP

2 years ago

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!

0 Replies

Anonymous
TRIALOP

2 years ago

Project ID: 8c1db389-9532-4ead-9ee9-2f4b19a5334c


brody
EMPLOYEE

2 years ago

if you deployed the template then you arent running your code, you would be running the template's code


Anonymous
TRIALOP

2 years ago

Hmm, but I had to connect my repo for it. How can I get this solved to let it run my code?


brody
EMPLOYEE

2 years ago

show me a screenshot of the source in your service settings please


Anonymous
TRIALOP

2 years ago

Ah, it is connected to the cloned repo:

1219773095724847400


Anonymous
TRIALOP

2 years ago

Is it enough to just change the Repo here?


brody
EMPLOYEE

2 years ago

is that source repo correct?


Anonymous
TRIALOP

2 years ago

Yep, it is the cloned one railway created where it uploaded the template code.


Anonymous
TRIALOP

2 years ago

it is a private repo though (ATM)


brody
EMPLOYEE

2 years ago

right but if its the template code, then its not your code


brody
EMPLOYEE

2 years ago

so disconnect both the source and upsteam then connect the correct repo that contains your code


Anonymous
TRIALOP

2 years ago

And in order to get it started do I have to create a requirements.txt as well as a Procfile too?


brody
EMPLOYEE

2 years ago

yes otherwise railway isnt going to know what to install or run


Anonymous
TRIALOP

2 years ago

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")?


brody
EMPLOYEE

2 years ago

yes thats correct, you likely would not need to touch that


Anonymous
TRIALOP

2 years ago

Can I also create the requirements.txt out of railway? Did not yet use one when being on replit.


brody
EMPLOYEE

2 years ago

the requirements.txt would need to exist within your github repo


Anonymous
TRIALOP

2 years ago

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.


Anonymous
TRIALOP

2 years ago

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. 🙂


brody
EMPLOYEE

2 years ago

saw that


Anonymous
TRIALOP

2 years ago

sry


Anonymous
TRIALOP

2 years ago

will repost:


Anonymous
TRIALOP

2 years ago

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. 🙂


brody
EMPLOYEE

2 years ago

heres a high level overview -
but if you have any specfic questions i can do my best to answer them


Anonymous
TRIALOP

2 years ago

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?


brody
EMPLOYEE

2 years ago

dont use dotenv, its not needed on railway since the service variables are injected directly into the container


brody
EMPLOYEE

2 years ago

and the os package is stdlib so that shouldn't be in the requirements.txt file anyway


Anonymous
TRIALOP

2 years ago

oh IC. So accessing the variables via os.getenv("TOKEN") would be sufficient without importing anything?


brody
EMPLOYEE

2 years ago

you would still need to import os, but you would not need dotenv


Anonymous
TRIALOP

2 years ago

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?

1219781891134197800
1219781891431862300


Anonymous
TRIALOP

2 years ago

In the root since in Procfile it says: web: python src/cardBot.py?


brody
EMPLOYEE

2 years ago

you have not touched the root directory in the service settings right?


brody
EMPLOYEE

2 years ago

can you share your repo so i can take a closer look?


Anonymous
TRIALOP

2 years ago

sure - I can make it public maybe…. So here you are: https://github.com/RrTe/RedemptionCardBot


brody
EMPLOYEE

2 years ago

well you see, there is no json file in the data folder


Anonymous
TRIALOP

2 years ago

Huh? I uploaded it. Just a sec ….


Anonymous
TRIALOP

2 years ago

Ouf! I forgot to commit the upload! Douh!


Anonymous
TRIALOP

2 years ago

Ok, so at least ../data/carddata.json can still be not found. Will try now with: data/carddata.json


Anonymous
TRIALOP

2 years ago

That seems to work - but now I am getting an error I never got before:

File "src/cardBot.py", line 51, in ) -> list[app_commands.Choice[str]]: TypeError: 'type' object is not subscriptable


Anonymous
TRIALOP

2 years ago

No clue whats wrong here. That code ran fine so far..


brody
EMPLOYEE

2 years ago

what version of python is replit running your code with?


Anonymous
TRIALOP

2 years ago

3.10.13


Anonymous
TRIALOP

2 years ago

So do I have to omit the -> part?


brody
EMPLOYEE

2 years ago

no, let's try getting railway to run your code with python 3.10 since 3.8 is the default


Anonymous
TRIALOP

2 years ago

IC


brody
EMPLOYEE

2 years ago

add a runtime.txt file with 3.10 in it


Anonymous
TRIALOP

2 years ago

in root directory?


Anonymous
TRIALOP

2 years ago

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?


brody
EMPLOYEE

2 years ago

24/7 until you run out of credits, then you will need to upgrade to the hobby plan


Anonymous
TRIALOP

2 years ago

what happens if I run out of credits? Will it be shut down or slowed down?


brody
EMPLOYEE

2 years ago

shut down


Anonymous
TRIALOP

2 years ago

😦 too bad. But thank you again for your great help! Awesome!


brody
EMPLOYEE

2 years ago

why too bad?


brody
EMPLOYEE

2 years ago

is the hobby plan not something you would be upgrading to when the time comes?


Anonymous
TRIALOP

2 years ago

Need to check it out.


Loading...