v0.1:the 'accept rules' feature is now live!!!

This commit is contained in:
Gzod01 2024-05-04 20:40:00 +02:00
parent b0dad06887
commit cb4ab8b8a3

View file

@ -70,10 +70,17 @@ impl EventHandler for Handler {
println!("Received component interaction {comp:?}"); println!("Received component interaction {comp:?}");
if matches!(comp.data.kind, ComponentInteractionDataKind::Button){ if matches!(comp.data.kind, ComponentInteractionDataKind::Button){
let interaction_output:String = match (button_interaction_role(comp.clone(), ctx.clone()).await) { let interaction_output:String = match (button_interaction_role(comp.clone(), ctx.clone()).await) {
Ok(role) => format!("Le rôle <@#{role:?}>",role=role.to_owned()), Ok(role) => "You received the <@&".to_owned()+&role+"> role.\n\nFR: Vous avez reçu le rôle <@&"+&role+">.",
Err(err) => format!("```\n{err:?}\n```",err=err) Err(err) => {
if err=="nulled"{
return;
}
format!("```\n{err:?}\n```",err=err)
}
}; };
let interaction_response:CreateInteractionResponse = CreateInteractionResponse::Message(CreateInteractionResponseMessage::new().ephemeral(true).content(interaction_output)); let interaction_response:CreateInteractionResponse = CreateInteractionResponse::Message(CreateInteractionResponseMessage::new().ephemeral(true).content(interaction_output));
println!("{interaction_response:?}");
let _ = comp.create_response(ctx, interaction_response).await; let _ = comp.create_response(ctx, interaction_response).await;
} }
} }
@ -102,8 +109,8 @@ async fn button_interaction_role (comp:ComponentInteraction, ctx:Context)->Resul
if jsonobj[&compid] != serde_json::Value::Null{ if jsonobj[&compid] != serde_json::Value::Null{
role = jsonobj[&compid].as_str().expect("OHOH").to_string(); role = jsonobj[&compid].as_str().expect("OHOH").to_string();
} }
if role=="nulled"{ if role=="nulled".to_string(){
panic!("{compid:?} does not exist"); return Err("nulled".to_owned());
} }
println!("{compid:?} role is : {role:?}"); println!("{compid:?} role is : {role:?}");
println!("{}",role.to_owned()); println!("{}",role.to_owned());