mirror of
https://github.com/natsukagami/youmubot.git
synced 2025-04-20 09:18:54 +00:00
30 lines
756 B
Rust
30 lines
756 B
Rust
use super::db::OsuLastBeatmap;
|
|
use super::BeatmapWithMode;
|
|
use serenity::model::id::ChannelId;
|
|
use youmubot_prelude::*;
|
|
|
|
/// Save the beatmap into the server data storage.
|
|
pub(crate) async fn save_beatmap(
|
|
data: &TypeMap,
|
|
channel_id: ChannelId,
|
|
bm: &BeatmapWithMode,
|
|
) -> Result<()> {
|
|
data.get::<OsuLastBeatmap>()
|
|
.unwrap()
|
|
.save(channel_id, &bm.0, bm.1)
|
|
.await?;
|
|
|
|
Ok(())
|
|
}
|
|
|
|
/// Get the last beatmap requested from this channel.
|
|
pub(crate) async fn get_beatmap(
|
|
data: &TypeMap,
|
|
channel_id: ChannelId,
|
|
) -> Result<Option<BeatmapWithMode>> {
|
|
data.get::<OsuLastBeatmap>()
|
|
.unwrap()
|
|
.by_channel(channel_id)
|
|
.await
|
|
.map(|v| v.map(|(bm, mode)| BeatmapWithMode(bm, mode)))
|
|
}
|