Skip to content

Commit e49ce86

Browse files
authored
0.7.1
A few more tweaks before going live
2 parents 1fa78fb + bf38b08 commit e49ce86

7 files changed

Lines changed: 23 additions & 20 deletions

File tree

Cargo.lock

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[package]
22
name = "bazooka-bot"
3-
version = "0.7.0"
3+
version = "0.7.1"
44
edition = "2024"
55
publish = false
66

Shuttle.toml

Lines changed: 0 additions & 1 deletion
This file was deleted.

deny.toml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,5 +3,4 @@ ignore = [
33
# "RUSTSEC-0000-0000",
44
# { id = "RUSTSEC-0000-0000", reason = "you can specify a reason the advisory is ignored" },
55
{ id = "RUSTSEC-2024-0388", reason = "Tracking issue https://github.com/serenity-rs/poise/issues/334" },
6-
{ id = "RUSTSEC-2025-0057", reason = "Tracking issue https://github.com/serenity-rs/serenity/issues/3420" },
76
]

src/config.rs

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -26,11 +26,12 @@ impl StartupConfig {
2626
pub fn try_new(clap_config: &ClapConfig) -> anyhow::Result<Self> {
2727
let guild_id = clap_config
2828
.registration_guild_id
29-
.parse::<u64>()
30-
.context("failed to parse guild id")
31-
.map(GuildId::new)?;
29+
.as_ref()
30+
.map(|x| x.parse::<u64>().map(GuildId::new))
31+
.transpose()
32+
.context("failed to parse guild id")?;
3233

33-
// TODO 4 - See if we can split this in clap
34+
// TODO 5 - See if we can split this in clap
3435
let owners: HashSet<UserId> = clap_config
3536
.owners
3637
.split(',')
@@ -41,10 +42,10 @@ impl StartupConfig {
4142
})
4243
.collect::<anyhow::Result<HashSet<UserId>>>()?;
4344

44-
let is_production = std::env::var("SHUTTLE").is_ok();
45+
let is_production = std::env::var("IS_PROD").is_ok();
4546

4647
Ok(Self {
47-
registration_guild_id: Some(guild_id),
48+
registration_guild_id: guild_id,
4849
owners,
4950
is_production,
5051
})

src/lib.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,7 @@ pub struct ClapConfig {
9292

9393
/// Used mostly for testing to register the commands directly for the guild
9494
#[arg(long, env = "REGISTRATION_GUILD_ID")]
95-
pub registration_guild_id: String,
95+
pub registration_guild_id: Option<String>,
9696

9797
/// The RoleId of the role that can run privileged commands
9898
#[arg(long, env = "AUTH_ROLE_ID")]

src/main.rs

Lines changed: 13 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
use anyhow::Context as _;
1+
use anyhow::{Context as _, bail};
22
use bazooka_bot::{ClapConfig, Data, SharedConfig, StartupConfig, commands_list, heartbeat};
33
use poise::serenity_prelude::{ClientBuilder, GatewayIntents};
44
use secrecy::ExposeSecret;
@@ -14,7 +14,7 @@ use version::version;
1414
use clap::Parser;
1515

1616
#[tokio::main]
17-
async fn main() {
17+
async fn main() -> anyhow::Result<()> {
1818
tracing_subscriber::registry()
1919
.with(fmt::layer().with_span_events(FmtSpan::NEW | FmtSpan::CLOSE))
2020
.with(
@@ -27,14 +27,17 @@ async fn main() {
2727

2828
// Load setup values
2929
info!("Loading environment variables");
30-
loadenv::load().expect("failed to load .env file");
30+
match loadenv::load() {
31+
Ok(was_found) => debug!(".env file was found: {was_found}"),
32+
Err(err_msg) => bail!("failed to load .env file: {err_msg:?}"),
33+
}
3134
let clap_config = ClapConfig::parse();
3235
debug!("ClapConfig: {:?}", clap_config);
3336

3437
let startup_config =
35-
StartupConfig::try_new(&clap_config).expect("failed to create setup config");
38+
StartupConfig::try_new(&clap_config).context("failed to create setup config")?;
3639
let shared_config =
37-
SharedConfig::try_new(&clap_config).expect("failed to created shared_config");
40+
SharedConfig::try_new(&clap_config).context("failed to created shared_config")?;
3841
let discord_token = clap_config.discord_token;
3942

4043
let framework = poise::Framework::builder()
@@ -101,9 +104,10 @@ async fn main() {
101104
)
102105
.framework(framework)
103106
.await
104-
.expect("Error creating client");
107+
.context("Error creating client")?;
105108

106-
if let Err(why) = client.start().await {
107-
error!("Client error: {why:?}");
108-
}
109+
client
110+
.start()
111+
.await
112+
.context("failed to start discord client")
109113
}

0 commit comments

Comments
 (0)