Skip to content

Commit

Permalink
refactor: extract to run function
Browse files Browse the repository at this point in the history
  • Loading branch information
Mogyuchi committed Dec 3, 2024
1 parent c46bc42 commit a4cc2fd
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,14 @@ async fn main() {
dotenv().expect(".env file not found");
let token = get_env("DISCORD_TOKEN");

run(token).await;
}

fn get_env(key: &str) -> String {
env::var(key).expect("Missing `{key}` env var, see README for more information.")
}

async fn run(token: String) {
// Specify intents requesting events about things like new and updated
let intents = serenity::GatewayIntents::GUILDS
| serenity::GatewayIntents::GUILD_MESSAGES
Expand All @@ -37,10 +45,6 @@ async fn main() {
client.unwrap().start().await.unwrap();
}

fn get_env(key: &str) -> String {
env::var(key).expect("Missing `{key}` env var, see README for more information.")
}

async fn event_handler(
ctx: &serenity::Context,
event: &serenity::FullEvent,
Expand Down

0 comments on commit a4cc2fd

Please sign in to comment.