Skip to content

Commit

Permalink
feat: handle ignored channels in voicetime (#87)
Browse files Browse the repository at this point in the history
  • Loading branch information
crnvl committed Oct 19, 2023
1 parent 90eccd9 commit 75099b1
Showing 1 changed file with 20 additions and 4 deletions.
24 changes: 20 additions & 4 deletions xp-bot/src/commands/misc/voicetime.rs
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ impl XpCommand for VoicetimeCommand {
response
.kind(InteractionResponseType::ChannelMessageWithSource)
.interaction_response_data(|message| {
message.content("This user has never joined a voice channel.");
message.content("This user has not joined a voice channel yet.");
message.ephemeral(true)
})
})
Expand All @@ -82,7 +82,7 @@ impl XpCommand for VoicetimeCommand {
};

// check if the user is currently in a voice channel
match ctx
let state = match ctx
.cache
.guild(command.guild_id.unwrap())
.unwrap()
Expand All @@ -106,10 +106,26 @@ impl XpCommand for VoicetimeCommand {
}
};

let current_timestamp = chrono::Utc::now().timestamp() * 1000;

let guild = Guild::from_id(command.guild_id.unwrap().0).await?;

// check if the user is in a voicechannel that's ignored
if guild.clone().ignored.channels.unwrap().contains(&state.unwrap().channel_id.unwrap().0.to_string()) {
command
.create_interaction_response(&ctx.http, |response| {
response
.kind(InteractionResponseType::ChannelMessageWithSource)
.interaction_response_data(|message| {
message.content("This voice channel is ignored.");
message.ephemeral(true)
})
})
.await
.unwrap();
return Ok(());
}

let current_timestamp = chrono::Utc::now().timestamp() * 1000;

let boost_percentage = utils::calculate_total_boost_percentage(
guild.clone(),
&command.member.as_ref().unwrap().roles,
Expand Down

0 comments on commit 75099b1

Please sign in to comment.