mirror of
https://github.com/natsukagami/youmubot.git
synced 2025-05-24 17:20:49 +00:00
Update youmubot-core
This commit is contained in:
parent
3f115eaab0
commit
08d639944e
10 changed files with 167 additions and 354 deletions
|
@ -1,4 +1,5 @@
|
|||
use serde::Deserialize;
|
||||
use serenity::builder::EditMessage;
|
||||
use serenity::framework::standard::CommandError as Error;
|
||||
use serenity::{
|
||||
framework::standard::{
|
||||
|
@ -72,14 +73,15 @@ async fn message_command(
|
|||
if page >= images.len() {
|
||||
Ok(false)
|
||||
} else {
|
||||
msg.edit(ctx, |f| {
|
||||
f.content(format!(
|
||||
msg.edit(
|
||||
ctx,
|
||||
EditMessage::new().content(format!(
|
||||
"[🖼️ **{}/{}**] Here's the image you requested!\n\n{}",
|
||||
page + 1,
|
||||
images.len(),
|
||||
images[page]
|
||||
))
|
||||
})
|
||||
)),
|
||||
)
|
||||
.await
|
||||
.map(|_| true)
|
||||
.map_err(|e| e.into())
|
||||
|
@ -110,7 +112,6 @@ async fn get_image(
|
|||
))
|
||||
.query(&[("limit", "50"), ("random", "true")])
|
||||
.build()?;
|
||||
println!("{:?}", req.url());
|
||||
let response: Vec<PostResponse> = client.execute(req).await?.json().await?;
|
||||
Ok(response
|
||||
.into_iter()
|
||||
|
|
|
@ -3,7 +3,7 @@ use serenity::model::id::UserId;
|
|||
const ALL_NAMES: usize = FIRST_NAMES.len() * LAST_NAMES.len();
|
||||
// Get a name from the user's id.
|
||||
pub fn name_from_userid(u: UserId) -> (&'static str, &'static str) {
|
||||
let u = u.0 as usize % ALL_NAMES;
|
||||
let u = u.get() as usize % ALL_NAMES;
|
||||
(
|
||||
FIRST_NAMES[u / LAST_NAMES.len()], // Not your standard mod
|
||||
LAST_NAMES[u % LAST_NAMES.len()],
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue