mirror of
https://github.com/natsukagami/youmubot.git
synced 2025-05-24 17:20:49 +00:00
Move to SQLite (#13)
This commit is contained in:
parent
750ddb7762
commit
1799b70bc1
50 changed files with 2122 additions and 394 deletions
|
@ -68,7 +68,7 @@ pub async fn choose(ctx: &Context, m: &Message, mut args: Args) -> CommandResult
|
|||
})
|
||||
.unwrap_or(false)
|
||||
})
|
||||
.map(|mem| future::ready(mem))
|
||||
.map(future::ready)
|
||||
.collect::<stream::FuturesUnordered<_>>()
|
||||
.filter_map(|member| async move {
|
||||
// Filter by role if provided
|
||||
|
@ -110,7 +110,7 @@ pub async fn choose(ctx: &Context, m: &Message, mut args: Args) -> CommandResult
|
|||
.push(" ")
|
||||
.push(
|
||||
role.map(|r| format!("{}s", r.mention()))
|
||||
.unwrap_or("potential prayers".to_owned()),
|
||||
.unwrap_or_else(|| "potential prayers".to_owned()),
|
||||
)
|
||||
.push(", ")
|
||||
.push(winner.mention())
|
||||
|
|
|
@ -388,7 +388,7 @@ mod reaction_watcher {
|
|||
.flat_map(|(&guild, rs)| {
|
||||
rs.reaction_messages
|
||||
.iter()
|
||||
.map(move |(m, r)| (guild, m.clone(), r.clone()))
|
||||
.map(move |(m, r)| (guild, *m, r.clone()))
|
||||
})
|
||||
.collect();
|
||||
Ok(Self {
|
||||
|
@ -554,11 +554,11 @@ mod reaction_watcher {
|
|||
let role = Roles::open(&*data)
|
||||
.borrow()?
|
||||
.get(&guild)
|
||||
.ok_or(Error::msg("guild no longer has role list"))?
|
||||
.ok_or_else(|| Error::msg("guild no longer has role list"))?
|
||||
.reaction_messages
|
||||
.get(&message)
|
||||
.map(|msg| &msg.roles[..])
|
||||
.ok_or(Error::msg("message is no longer a role list handler"))?
|
||||
.ok_or_else(|| Error::msg("message is no longer a role list handler"))?
|
||||
.iter()
|
||||
.find_map(|(role, role_reaction)| {
|
||||
if &reaction.as_inner_ref().emoji == role_reaction {
|
||||
|
|
|
@ -87,7 +87,7 @@ pub async fn vote(ctx: &Context, msg: &Message, mut args: Args) -> CommandResult
|
|||
let panel = channel.send_message(&ctx, |c| {
|
||||
c.content("@here").embed(|e| {
|
||||
e.author(|au| {
|
||||
au.icon_url(author.avatar_url().unwrap_or("".to_owned()))
|
||||
au.icon_url(author.avatar_url().unwrap_or_else(|| "".to_owned()))
|
||||
.name(&author.name)
|
||||
})
|
||||
.title(format!("You have {} to vote!", _duration))
|
||||
|
@ -97,7 +97,6 @@ pub async fn vote(ctx: &Context, msg: &Message, mut args: Args) -> CommandResult
|
|||
})
|
||||
}).await?;
|
||||
msg.delete(&ctx).await?;
|
||||
drop(msg);
|
||||
|
||||
// React on all the choices
|
||||
choices
|
||||
|
@ -160,7 +159,7 @@ pub async fn vote(ctx: &Context, msg: &Message, mut args: Args) -> CommandResult
|
|||
|
||||
result.sort_unstable_by(|(_, v), (_, w)| w.len().cmp(&v.len()));
|
||||
|
||||
if result.len() == 0 {
|
||||
if result.is_empty() {
|
||||
msg.reply(
|
||||
&ctx,
|
||||
MessageBuilder::new()
|
||||
|
@ -227,7 +226,7 @@ fn pick_n_reactions(n: usize) -> Result<Vec<String>, Error> {
|
|||
const MAX_CHOICES: usize = 15;
|
||||
|
||||
// All the defined reactions.
|
||||
const REACTIONS: [&'static str; 90] = [
|
||||
const REACTIONS: [&str; 90] = [
|
||||
"😀", "😁", "😂", "🤣", "😃", "😄", "😅", "😆", "😉", "😊", "😋", "😎", "😍", "😘", "🥰", "😗",
|
||||
"😙", "😚", "☺️", "🙂", "🤗", "🤩", "🤔", "🤨", "😐", "😑", "😶", "🙄", "😏", "😣", "😥", "😮",
|
||||
"🤐", "😯", "😪", "😫", "😴", "😌", "😛", "😜", "😝", "🤤", "😒", "😓", "😔", "😕", "🙃", "🤑",
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue