Skip to content

Commit

Permalink
feat: log the guild ID in a couple of places
Browse files Browse the repository at this point in the history
  • Loading branch information
maddiemort committed Oct 6, 2024
1 parent 0d57520 commit a816650
Showing 1 changed file with 11 additions and 11 deletions.
22 changes: 11 additions & 11 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -62,13 +62,13 @@ impl EventHandler for Bot {
async fn message(&self, ctx: Context, msg: Message) {
match msg.content.parse::<Score>() {
Ok(score) => {
info!(?score, "parsed score");

let Some(guild_id) = msg.guild_id else {
warn!("cannot continue without guild ID");
warn!("cannot continue processing message without guild ID");
return;
};

info!(?score, %guild_id, "parsed score");

match persist::insert_score(&self.db_pool, score, guild_id, &msg.author).await {
Ok(inserted_score) => {
match msg.react(&ctx.http, '✅').await {
Expand Down Expand Up @@ -130,6 +130,14 @@ impl EventHandler for Bot {
command: &CommandInteraction,
db_pool: &PgPool,
) -> CreateInteractionResponseMessage {
let Some(guild_id) = command.guild_id else {
warn!("cannot continue processing interaction without guild ID");
return CreateInteractionResponseMessage::new()
.content("This command can only be run in a server!");
};

info!(%guild_id, "received command interaction");

let options = command.data.options();
let Some(ResolvedOption {
name: "range",
Expand All @@ -141,12 +149,6 @@ impl EventHandler for Bot {
.content("An unexpected error occurred");
};

let Some(guild_id) = command.guild_id else {
warn!("cannot continue without guild ID");
return CreateInteractionResponseMessage::new()
.content("This command can only be run in a server!");
};

if *range == "leaderboard_today" {
let board = geogrid::board_now();
let today = Daily::calculate_for(db_pool, guild_id, board).await;
Expand Down Expand Up @@ -239,8 +241,6 @@ impl EventHandler for Bot {
}

if let Interaction::Command(command) = interaction {
info!("received command interaction");

let response = process_command(&command, &self.db_pool)
.await
.pipe(CreateInteractionResponse::Message);
Expand Down

0 comments on commit a816650

Please sign in to comment.