Im trying to deploy a serenity discord bot
# help
b
I didnt start the project with with shuttle, it was just serenity. Can i do something to deploy it on shuttle now?
hey jonaro i made a new shuttle project and brought everything inside it, and im building that right now
...it crashed
g
@bland-horse-72062 Beware that you should keep your discord token secret and not commit it. I advice you to go to the discord developer page and reset it.
b
discord already reset it, dont worry
got a new one
g
It is quite simple. You refactor your main function a bit to return
Ok(client)
. It is best to look at the serenity example code.
g
Copy code
#[shuttle_runtime::main]
async fn serenity(
    #[shuttle_secrets::Secrets] secret_store: SecretStore,
) -> shuttle_serenity::ShuttleSerenity {
    // Get the discord token set in `Secrets.toml`
    let token = if let Some(token) = secret_store.get("DISCORD_TOKEN") {
        token
    } else {
        return Err(anyhow!("'DISCORD_TOKEN' was not found").into());
    };

    let client = Client::builder(&token, GatewayIntents::ALL())
        .event_handler(handler::Handler)
        .framework(framework)
        .await
        .expect("Err creating client");

    Ok(client.into())
}
Just replace your main function with this, setup a Secrets.toml, and add
shuttle-secrets
,
shuttle-runtime
, and
shuttle-serenity
to your Cargo.toml
You can take a look at https://docs.shuttle.rs/examples/serenity for more details
b
deployment has not entered the running state
?
no way it seems to be running
g
Nice seeing the issue i'm working on , , might have some use
b
well the bot is live, maybe its just a minor bug
g
deployment has not entered the running state
in this case probably means that the log stream was broken, not that the deployment didn't actually start running
e
Yeah I've seen it happen both for deployment crashing and also for seemingly minor communication errors/interruption when streaming the logs lol
b
its dead
🙂
g
Check out "Idle Projects" in the docs
b
can i change the idle minutes without creating another project?
e
Yeah, just do
cargo shuttle project restart --idle-minutes 0
and then deploy
b
thank you :)
e
Restarting / "destroying" the project doesn't really do anything other than tear down the docker(?) container it was running in. If you're using resources like databases or whatnot, it'll carry over through that with no issues.
b
i didnt use a database for this bot but thats good to know for future projects
i think ill use shuttle for other projects other than this