/// The function to handle a vote-addition event for the "ban_button"
/// This function adds the vote then checks whether the goal is reached
/// and then acts accordingly, either by banning the member and then updating
/// the announcement on the moderation channel or just by updating the announcement
//
// NOTE: The ban actually only applies the "silenced" role upon the user
The function to handle a vote-addition event for the "ban_button"
This function adds the vote then checks whether the goal is reached
and then acts accordingly, either by banning the member and then updating
the announcement on the moderation channel or just by updating the announcement

The ban actually only applies the "silenced" role upon the user
The function to handle a vote - addition event for the " ban_button " This function adds the vote then checks whether the goal is reached and then acts accordingly either by banning the member and then updating the announcement on the moderation channel or just by updating the announcement The ban actually only applies the " silenced " role upon the user
async fn add_silence_vote(ctx: &Context, voter: User, message: &mut Message) {
    let db = ctx.get_db().await;
    let event = db.get_voting_event(message.id.0).await.unwrap();
    if event.silence_votes == event.silence_votes_required {
        return;
    }
    if db
        .add_vote(event.vote_message_id, voter.id.0, 1)
        .await
        .unwrap()
        == 0
    {
        return;
    }
    let event = db.get_voting_event(message.id.0).await.unwrap();
    if event.silence_votes == event.silence_votes_required {
        let guild_id: u64 = env::var("GUILD_ID")
            .expect("Expected GUILD_ID in .env")
            .parse()
            .expect("Invalid GUILD_ID provided");
        let silence_role: u64 = env::var("SILENCED_ROLE_ID")
            .expect("Expected SILENCED_ROLE_ID in .env")
            .parse()
            .expect("Invalid SILENCED_ROLE_ID provided");
        let mut member = ctx
            .http
            .get_member(guild_id, event.suspect_id as u64)
            .await
            .unwrap();
        member.add_role(&ctx.http, silence_role).await.unwrap();
    }
    update_voting_message(ctx, event.vote_message_id as u64).await;
}
async fn add_silence_vote ( ctx : & Context , voter : User , message : & mut Message ) { let db = ctx . get_db ( ) . await ; let event = db . get_voting_event ( message . id . 0 ) . await . unwrap ( ) ; if event . silence_votes == event . silence_votes_required { return ; } if db . add_vote ( event . vote_message_id , voter . id . 0 , 1 ) . await . unwrap ( ) == 0 { return ; } let event = db . get_voting_event ( message . id . 0 ) . await . unwrap ( ) ; if event . silence_votes == event . silence_votes_required { let guild_id : u64 = env :: var ( " " ) . expect ( " " ) . parse ( ) . expect ( " " ) ; let silence_role : u64 = env :: var ( " " ) . expect ( " " ) . parse ( ) . expect ( " " ) ; let mut member = ctx . http . get_member ( guild_id , event . suspect_id as u64 ) . await . unwrap ( ) ; member . add_role ( & ctx . http , silence_role ) . await . unwrap ( ) ; } update_voting_message ( ctx , event . vote_message_id as u64 ) . await ; }
The function to handle a vote-addition event for the "ban_button"
This function adds the vote then checks whether the goal is reached
and then acts accordingly, either by banning the member and then updating
the announcement on the moderation channel or just by updating the announcement
The function to handle a vote - addition event for the " ban_button " This function adds the vote then checks whether the goal is reached and then acts accordingly either by banning the member and then updating the announcement on the moderation channel or just by updating the announcement
ctx
&Context
voter
User
message
&mut Message