Update to Tokio 1 and Serenity 0.10 (#9)

This commit is contained in:
Natsu Kagami 2021-01-15 18:50:33 +00:00 committed by GitHub
parent 40f6c6e553
commit 901d55814d
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
19 changed files with 238 additions and 281 deletions

View file

@ -53,7 +53,7 @@ async fn clean(ctx: &Context, msg: &Message, mut args: Args) -> CommandResult {
};
msg.react(&ctx, '🌋').await?;
if let Channel::Guild(_) = &channel {
tokio::time::delay_for(std::time::Duration::from_secs(2)).await;
tokio::time::sleep(std::time::Duration::from_secs(2)).await;
msg.delete(&ctx).await.ok();
}

View file

@ -148,7 +148,7 @@ pub async fn watch_soft_bans(cache_http: Arc<CacheAndHttp>, data: AppData) {
}
}
// Sleep the thread for a minute
tokio::time::delay_for(std::time::Duration::from_secs(60)).await
tokio::time::sleep(std::time::Duration::from_secs(60)).await
}
}

View file

@ -104,7 +104,7 @@ pub async fn choose(ctx: &Context, m: &Message, mut args: Args) -> CommandResult
.push_bold(format!("{}", users.len()))
.push(" ")
.push(
role.map(|r| r.mention() + "s")
role.map(|r| format!("{}s", r.mention()))
.unwrap_or("potential prayers".to_owned()),
)
.push(", ")

View file

@ -195,7 +195,7 @@ pub async fn vote(ctx: &Context, msg: &Message, mut args: Args) -> CommandResult
.push(
votes
.into_iter()
.map(|v| v.mention())
.map(|v| v.mention().to_string())
.collect::<Vec<_>>()
.join(", "),
);

View file

@ -3,7 +3,7 @@ use serenity::framework::standard::CommandError as Error;
use serenity::{
framework::standard::{
macros::{check, command},
Args, CheckResult, CommandOptions, CommandResult, Reason,
Args, CommandOptions, CommandResult, Reason,
},
model::channel::{Channel, Message},
};
@ -29,15 +29,20 @@ pub async fn image(ctx: &Context, msg: &Message, args: Args) -> CommandResult {
#[check]
#[name = "nsfw"]
async fn nsfw_check(ctx: &Context, msg: &Message, _: &mut Args, _: &CommandOptions) -> CheckResult {
async fn nsfw_check(
ctx: &Context,
msg: &Message,
_: &mut Args,
_: &CommandOptions,
) -> Result<(), Reason> {
let channel = msg.channel_id.to_channel(&ctx).await.unwrap();
if !(match channel {
Channel::Guild(guild_channel) => guild_channel.nsfw,
_ => true,
}) {
CheckResult::Failure(Reason::User("😣 YOU FREAKING PERVERT!!!".to_owned()))
Err(Reason::User("😣 YOU FREAKING PERVERT!!!".to_owned()))
} else {
CheckResult::Success
Ok(())
}
}