You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
37 lines
1.2 KiB
Rust
37 lines
1.2 KiB
Rust
use serenity::client::Context;
|
|
use serenity::framework::standard::macros::command;
|
|
use serenity::framework::standard::CommandResult;
|
|
use serenity::model::channel::Message;
|
|
|
|
use crate::commands::common::handle_autodelete;
|
|
use crate::utils::context_data::get_database_from_context;
|
|
|
|
#[command]
|
|
#[only_in(guilds)]
|
|
#[description("Displays a list of all saved playlists")]
|
|
#[usage("")]
|
|
#[bucket("general")]
|
|
async fn playlists(ctx: &Context, msg: &Message) -> CommandResult {
|
|
let guild = msg.guild(&ctx.cache).await.unwrap();
|
|
log::debug!("Displaying playlists for guild {}", guild.id);
|
|
let database = get_database_from_context(ctx).await;
|
|
|
|
let playlists = database.get_guild_playlists(guild.id.0).await?;
|
|
msg.channel_id
|
|
.send_message(ctx, |m| {
|
|
m.embed(|e| {
|
|
e.title("Saved Playlists").description(
|
|
playlists
|
|
.into_iter()
|
|
.map(|p| format!("[{}]({})", p.name, p.url))
|
|
.collect::<Vec<String>>()
|
|
.join("\n"),
|
|
)
|
|
})
|
|
})
|
|
.await?;
|
|
handle_autodelete(ctx, msg).await?;
|
|
|
|
Ok(())
|
|
}
|