Crate sparkle_convenience

Crate sparkle_convenience 

Source
Expand description

§✨😌 Sparkle Convenience

A wrapper over Twilight that’s designed to be convenient to use, without relying on callbacks and mostly following Twilight patterns while making your life easier

§✨ FEATURES

  • Get your bot started with one method
  • Defer, respond to or update responses of interactions without having to track anything yourself
  • Extract interaction data easily
  • Handle user errors with little boilerplate and with edge cases caught
  • Log internal errors with webhooks
  • Much more you can find out in the docs!

§😋 A TASTE OF CONVENIENCE

let bot = Bot::new(
    "forgot to leak my token".to_owned(),
    Intents::empty(),
    EventTypeFlags::INTERACTION_CREATE,
)
.await?;

let handle = bot.interaction_handle(&interaction);
if interaction.name().ok()? == "pay_respects" {
    handle.defer(DeferVisibility::Ephemeral).await?;
    handle.check_permissions(Permissions::MANAGE_GUILD)?;
    let very_respected_user = interaction.data.ok()?.command().ok()?.target_id.ok()?;

    handle
        .reply(
            Reply::new()
                .ephemeral()
                .content("Paying respects".to_owned()),
        )
        .await?;

    handle
        .reply(
            Reply::new()
                .ephemeral()
                .update_last()
                .content(format!("<@{very_respected_user}> has +1 respect now")),
        )
        .await?;
}

§✉️ CONTACT

Feature Requests? Bugs? Support? Contributions? You name it, I’m always looking for community feedback from anyone who uses my work!

If you have a question, join Twilight’s Discord server please

Modules§

error
User error types and converting options to results
interaction
Convenient interaction handling
log
Logging methods on Bot
message
Convenient message handling
prettify
Formatting types into user-readable pretty strings
reply
The reply::Reply struct
webhookDeprecated
Convenient webhook handling

Structs§

Bot
All data required to make a bot run