Keyboard shortcuts

Press or to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

ytb post

Post a video/stream in an announcement channel

Usage

/ytb post type=... url=...


ArgumentDescriptionExemple
typeType of message to sendVideo or Stream
urlURL of any YouTube videohttps://youtu.be/S37C2SQb6qQ

Source code

#[poise::command(
    slash_command,
    rename = "ytb",
    subcommands("post", "join", "leave"),
    subcommand_required
)]
pub async fn cmd(_: Context<'_>) -> Result<(), Error> {
    Ok(())
}

#[derive(poise::ChoiceParameter)]
pub enum Kind {
    Video,
    Stream,
}
#[poise::command(slash_command)]
pub async fn post(
    ctx: Context<'_>,
    #[description = "Message preset"] kind: Kind,
    #[description = "Youtube video URL"] url: String,
) -> Result<(), Error> {
    let msg = match kind {
        Kind::Video => "Hey @everyone, **Skoh** à posté une nouvelle vidéo !!",
        Kind::Stream => "Hey @here, **Skoh** est en live !",
    };

    let _ = serenity::ChannelId::from(ids::VIDEO_CHANNEL)
        .say(ctx, format!("{msg}\n\n▷ {url}"))
        .await?;

    ctx.say(format!("✔ Message sent in <#{}>", ids::VIDEO_CHANNEL))
        .await?;

    Ok(())
}