How can I update railwayapp deploy from local
Basically I'm hosting a Discord bot on Railway - I'm wondering how I can continue developing and working on the discord bot from my local PC without having thousands of commits (timeconsuming and annoying).
Am I missing something? Is there a way I can pause my deployment, work on local and then redeploy on Railway?
Send help
35 Replies
Project ID:
N/A
N/A
why are you pushing every little change? For local development you should have a test bot, that way during local development you can run the code locally and nothing will interfere with your bot running on railway
It isn't really that easy from what I can see. I'd then need a completely different folder/file with different client ids, tokens etc. Doesn't seem like the best way of doing this.
it is, you are overthinking it
Ok - glad to hear it
same code, same project folder, two bot tokens, one token for production, one token for testing.
have your code check if a
RAILWAY_ENVIRONMENT
variable exists, if it exists use the production token, if it doesn't exist use the testing token.
with that logic in place, locally you wont have that variable so the bot would be started with the testing token.
its one if/else statement.Ok if I'm not wrong, I'd have to do this for the token and application id
But both easily doable with what you've mentioned above
Sounds perfect - will give it a try, thanking you
no problem!
I assume replies etc will come from both bots at once
if testing existing commands on the production build
no, youd only be using one token, so one bot at a time
you would have to create a new bot for testing purposes
but railway production build will still be running no?
so lets just say I have /ping
both bots will reply with Pong!
you will be using a completely separate bot and server for just testing
this way its completely isolated
Gotcha, but I'm using channel ids etc in the bot which will cause problems
different servers will have different channel ids
this is one of the core problems
i know someone who does this exact thing and he says it was easy to setup
@Fragly sorry for the ping, but do you think you could give some tips here?
Yeah I really want to learn how to do it properly, but i'm dynamically changing channel names with my bot regularly so am using channel ids
But those ids are different between servers which is causing errors
I don't know the intricacies of discord bot development, ive never done it, but fragly has
all good, I appreciate the help thus far anyway. Hopefully fragly can provide some insight!
he prob sleeping lol
really enjoying railway so far, very simple to use and beautiful ui.
but biggest prob is I can't pause the deployment which would make my life much easier lol
5 sec of downtime to move over to local wouldn't be a big deal in this use case
pausing is coming, but at this point we both know pausing to develop on your bot is not the correct way to go about this
yeah 100% haha
once I actually get a decent user base I wouldn't want to be doing this
exactly
so would be cool to know the appropriate way of achieving this
I haven't really done any googling, was looking at this from the perspective it was a railway issue but it's not at all
will try figure it out myself, otherwise fragly might come in clutch
oh yeah def not a railway specific issue, but i have no problems helping where i can, i have just reached a point where my knowledge on the subject has ran out lol
Just woke up, I'll read in a sec
Yea I do what Brody suggested, I have a separate test bot that I can test things on, the test bot is in a server that doesn't have the actual bot in it ( because I don't want both bots to reply and I refuse to use slash commands )
What I do is I have a json file called
dev.json
, inside of it I can store anything I need to store for the local bot to work, I gitignored that file and so if I push to github, i won't push the dev.json
file, meaning that it won't run the test bot when ran on railway
Inside my code, I just check if the dev.json file exists, if it does I use my test-bot token, otherwise i use my actual bot token
As for the channel ids thing, that's just a simple skill issue, you should consider making the bot more flexible than that - even if you're only going to use it in one server, although if that's not possible I would just put all the channel ids and stuff in the dev.json
which will overwrite the actual ones when the test-bot is running
I'm no professional on this though so i don't know if this is standard practice, that's just what I doGotcha, understood and appreciate your input - it means a lot and I'm quite new to this also
I use the ids because the name is constantly changing
I'm updating the channel name frequently, don't know how else I would fetch it
nah what I mean with making it more flexible is making it so you can set the bot up with the correct ids in whatever server it is, like with a
setup
commandOh right I see what you mean - yeah that's an option, good point
It will only ever be in one discord - made specifically for mine. But I need to figure out what i'm going to do
@Fragly how come you refuse to use slash commands?
I think it's good, saves on resources because the bot won't have to look at every single message to determine whether it's a command or not and the bot's commands documents themselves, although I have a personal distaste for them because
tab
- instead of going to the next field - just selects the first recommended thing
for example /ban user: 4859593369369
it'll show recommendations for users and if I press tab it'll select the top-most user, and I won't notice it and I'll accidentally end up banning someone I didn't mean to
the amount of people I've accidentally banned because of slash commands is incredible
specifically in this situation though, my bot is meant to have like a butler identity with personality and stuff, and slash commands i feel just takes away from the personality
for a simple moderation bot or something I probably will still use slash commands with non-slash command support built in
good luck with your bot 🫡gotcha - well thanks for all your input, i'll take it on board and probably implement the dev.json file. seems like the best approach
all the best and good luck with life!
or just setup two envs in railway and push the changes as you need. one is the production that only deploys from
main
one is the test that deploys from your live branch.Yea I've had someone recommend a seperate env too, personally prefer the json file for no reason though
well env is recommended because it's .... a different env.
you know the whole saying "use the right tool for the job"
I eat noodles with a