mirror of
https://github.com/natsukagami/youmubot.git
synced 2025-04-16 07:18:54 +00:00
Fix formatting
This commit is contained in:
parent
3e42c74c78
commit
5fc818b55e
1 changed files with 31 additions and 29 deletions
|
@ -95,37 +95,39 @@ pub fn vote(ctx: &mut Context, msg: &Message, mut args: Args) -> CommandResult {
|
||||||
let reaction_to_choice: Map<_, _> = choices.iter().map(|r| (r.0, &r.1)).collect();
|
let reaction_to_choice: Map<_, _> = choices.iter().map(|r| (r.0, &r.1)).collect();
|
||||||
let mut user_reactions: Map<UserId, Vec<&str>> = Map::new();
|
let mut user_reactions: Map<UserId, Vec<&str>> = Map::new();
|
||||||
|
|
||||||
ctx.data.get_cloned::<ReactionWatcher>().handle_reactions_timed(
|
ctx.data
|
||||||
|reaction: &Reaction, is_add| {
|
.get_cloned::<ReactionWatcher>()
|
||||||
if reaction.message_id != panel.id {
|
.handle_reactions_timed(
|
||||||
return Ok(());
|
|reaction: &Reaction, is_add| {
|
||||||
}
|
if reaction.message_id != panel.id {
|
||||||
if reaction.user(&ctx)?.bot {
|
|
||||||
return Ok(());
|
|
||||||
}
|
|
||||||
let choice = if let ReactionType::Unicode(ref s) = reaction.emoji {
|
|
||||||
if let Some(choice) = reaction_to_choice.get(s.as_str()) {
|
|
||||||
choice
|
|
||||||
} else {
|
|
||||||
return Ok(());
|
return Ok(());
|
||||||
}
|
}
|
||||||
} else {
|
if reaction.user(&ctx)?.bot {
|
||||||
return Ok(());
|
return Ok(());
|
||||||
};
|
}
|
||||||
if is_add {
|
let choice = if let ReactionType::Unicode(ref s) = reaction.emoji {
|
||||||
user_reactions
|
if let Some(choice) = reaction_to_choice.get(s.as_str()) {
|
||||||
.entry(reaction.user_id)
|
choice
|
||||||
.or_default()
|
} else {
|
||||||
.push(choice);
|
return Ok(());
|
||||||
} else {
|
}
|
||||||
user_reactions.entry(reaction.user_id).and_modify(|v| {
|
} else {
|
||||||
v.retain(|f| &f != choice);
|
return Ok(());
|
||||||
});
|
};
|
||||||
}
|
if is_add {
|
||||||
Ok(())
|
user_reactions
|
||||||
},
|
.entry(reaction.user_id)
|
||||||
*duration,
|
.or_default()
|
||||||
)?;
|
.push(choice);
|
||||||
|
} else {
|
||||||
|
user_reactions.entry(reaction.user_id).and_modify(|v| {
|
||||||
|
v.retain(|f| &f != choice);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
Ok(())
|
||||||
|
},
|
||||||
|
*duration,
|
||||||
|
)?;
|
||||||
let result: Vec<(&str, Vec<UserId>)> = {
|
let result: Vec<(&str, Vec<UserId>)> = {
|
||||||
let mut res: Map<&str, Vec<UserId>> = Map::new();
|
let mut res: Map<&str, Vec<UserId>> = Map::new();
|
||||||
for (u, r) in user_reactions {
|
for (u, r) in user_reactions {
|
||||||
|
|
Loading…
Add table
Reference in a new issue