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]
|
#[group]
|
||||||
#[commands(name, message, question, inbox)]
|
#[commands(name, message, question, inbox)]
|
||||||
struct Fluff;
|
struct Fluff;
|
||||||
|
@ -53,15 +67,7 @@ impl EventHandler for Handler {
|
||||||
if reaction.message_id == 911630315376738384
|
if reaction.message_id == 911630315376738384
|
||||||
&& reaction.emoji == ReactionType::Unicode(String::from("🧪"))
|
&& reaction.emoji == ReactionType::Unicode(String::from("🧪"))
|
||||||
{
|
{
|
||||||
reaction
|
role_action!(reaction, ctx, add_role)
|
||||||
.guild_id
|
|
||||||
.unwrap()
|
|
||||||
.member(&ctx, reaction.user_id.unwrap())
|
|
||||||
.await
|
|
||||||
.unwrap()
|
|
||||||
.add_role(&ctx, 356421827708321795)
|
|
||||||
.await
|
|
||||||
.unwrap()
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -69,15 +75,7 @@ impl EventHandler for Handler {
|
||||||
if reaction.message_id == 911630315376738384
|
if reaction.message_id == 911630315376738384
|
||||||
&& reaction.emoji == ReactionType::Unicode(String::from("🧪"))
|
&& reaction.emoji == ReactionType::Unicode(String::from("🧪"))
|
||||||
{
|
{
|
||||||
reaction
|
role_action!(reaction, ctx, remove_role)
|
||||||
.guild_id
|
|
||||||
.unwrap()
|
|
||||||
.member(&ctx, reaction.user_id.unwrap())
|
|
||||||
.await
|
|
||||||
.unwrap()
|
|
||||||
.remove_role(&ctx, 356421827708321795)
|
|
||||||
.await
|
|
||||||
.unwrap()
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue
Block a user