Generify role actions
This commit is contained in:
parent
1ee9233e05
commit
e6d48ab0a7
34
src/main.rs
34
src/main.rs
|
@ -33,6 +33,20 @@ macro_rules! send_or_log {
|
|||
};
|
||||
}
|
||||
|
||||
macro_rules! role_action {
|
||||
($reaction: expr, $ctx: expr, $action: ident) => {
|
||||
$reaction
|
||||
.guild_id
|
||||
.unwrap()
|
||||
.member(&$ctx, $reaction.user_id.unwrap())
|
||||
.await
|
||||
.unwrap()
|
||||
.$action(&$ctx, 356421827708321795)
|
||||
.await
|
||||
.unwrap()
|
||||
};
|
||||
}
|
||||
|
||||
#[group]
|
||||
#[commands(name, message, question, inbox)]
|
||||
struct Fluff;
|
||||
|
@ -53,15 +67,7 @@ impl EventHandler for Handler {
|
|||
if reaction.message_id == 911630315376738384
|
||||
&& reaction.emoji == ReactionType::Unicode(String::from("🧪"))
|
||||
{
|
||||
reaction
|
||||
.guild_id
|
||||
.unwrap()
|
||||
.member(&ctx, reaction.user_id.unwrap())
|
||||
.await
|
||||
.unwrap()
|
||||
.add_role(&ctx, 356421827708321795)
|
||||
.await
|
||||
.unwrap()
|
||||
role_action!(reaction, ctx, add_role)
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -69,15 +75,7 @@ impl EventHandler for Handler {
|
|||
if reaction.message_id == 911630315376738384
|
||||
&& reaction.emoji == ReactionType::Unicode(String::from("🧪"))
|
||||
{
|
||||
reaction
|
||||
.guild_id
|
||||
.unwrap()
|
||||
.member(&ctx, reaction.user_id.unwrap())
|
||||
.await
|
||||
.unwrap()
|
||||
.remove_role(&ctx, 356421827708321795)
|
||||
.await
|
||||
.unwrap()
|
||||
role_action!(reaction, ctx, remove_role)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue
Block a user