#discord #discord-api #twilight

sparkle-convenience

A wrapper over Twilight designed to make it more convenient to use

40 releases

0.16.0-rc.3 Aug 15, 2023
0.16.0-rc.2 Jun 29, 2023
0.16.0-rc.1 May 27, 2023
0.15.7 Mar 7, 2023
0.14.11 Nov 23, 2022

#244 in Asynchronous

Download history 14/week @ 2023-08-04 29/week @ 2023-08-11 68/week @ 2023-08-18 46/week @ 2023-08-25 12/week @ 2023-09-01 58/week @ 2023-09-08 58/week @ 2023-09-15 6/week @ 2023-09-22 7/week @ 2023-09-29 11/week @ 2023-10-06 13/week @ 2023-10-13 19/week @ 2023-10-20 54/week @ 2023-10-27 14/week @ 2023-11-03 53/week @ 2023-11-10 17/week @ 2023-11-17

141 downloads per month

ISC license

71KB
1.5K SLoC

❓ RC INFO

This version isn't unstable, but it includes breaking changes. It will be published as non-RC when Twilight publishes its next version so that the version of this crate follows Twilight's version

✨😌 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
  • Send timed messages that are deleted after a timeout
  • 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?;
}

🚚 CARGO FEATURES

  • anyhow: Pulls the anyhow crate to provide convenience features around it in the error module

✉️ 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

Dependencies

~13–24MB
~360K SLoC