mirror of
https://forge.gzod01.fr/werobot/discoWeRo-Bot.git
synced 2024-11-17 10:28:03 +00:00
v0.1:the 'accept rules' feature is now live!!!
This commit is contained in:
parent
b0dad06887
commit
cb4ab8b8a3
1 changed files with 11 additions and 4 deletions
15
src/main.rs
15
src/main.rs
|
@ -70,10 +70,17 @@ impl EventHandler for Handler {
|
|||
println!("Received component interaction {comp:?}");
|
||||
if matches!(comp.data.kind, ComponentInteractionDataKind::Button){
|
||||
let interaction_output:String = match (button_interaction_role(comp.clone(), ctx.clone()).await) {
|
||||
Ok(role) => format!("Le rôle <@#{role:?}>",role=role.to_owned()),
|
||||
Err(err) => format!("```\n{err:?}\n```",err=err)
|
||||
Ok(role) => "You received the <@&".to_owned()+&role+"> role.\n\nFR: Vous avez reçu le rôle <@&"+&role+">.",
|
||||
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));
|
||||
println!("{interaction_response:?}");
|
||||
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{
|
||||
role = jsonobj[&compid].as_str().expect("OHOH").to_string();
|
||||
}
|
||||
if role=="nulled"{
|
||||
panic!("{compid:?} does not exist");
|
||||
if role=="nulled".to_string(){
|
||||
return Err("nulled".to_owned());
|
||||
}
|
||||
println!("{compid:?} role is : {role:?}");
|
||||
println!("{}",role.to_owned());
|
||||
|
|
Loading…
Reference in a new issue