#discord #discord-api #twilight

sparkle-convenience

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

17 releases

Uses new Rust 2021

new 0.14.15 Dec 6, 2022
0.14.14 Dec 6, 2022
0.14.11 Nov 23, 2022
0.13.0 Nov 18, 2022

#248 in Asynchronous

Download history 317/week @ 2022-11-17 41/week @ 2022-11-24 130/week @ 2022-12-01

488 downloads per month

ISC license

34KB
567 lines

Sparkle Convenience

GitHub crates.io docs.rs

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

You should use this if you:

  • Simply want something easy to use
  • Don't like writing boilerplate
  • Don't like thinking too much about the structure of your code

You shouldn't use this if you:

  • Want the maximum performance you can get
  • Want to customize as much as you can
  • Want something more low-level
  • Are willing to give up the pros of this crate for these

Interaction Handling

Provides methods to handle interactions conveniently:

  • Do all interaction handling without rewriting the ID and token using a handle
  • Create a followup response with a reply struct using the builder-pattern, which can be reused easily
  • Defer an interaction with one method
  • Create an autocomplete or modal response with minimal boilerplate

Error Handling

Provides an enum to conveniently handle errors:

  • The error enum combines user and internal errors
  • Easily check that the bot has the permissions required to run a command, and tell the user when it doesn't
  • Handle internal errors by printing them, writing them to a file and executing a webhook, all optionally

Usage

The entrypoint of this library is the Bot struct, which combines common Twilight data and provides abstraction methods on it, the documentation for it also has a full-fledged example of a /ping command

Looking for Ideas

The scope of this project includes anything in Twilight that could be more convenient to use, please make an issue for anything that falls under this category!

Caching

HTTP-fallback is not a good idea for many reasons, and there isn't much this crate could provide besides that, but caching everything possible will give you a peace of mind. If memory usage is a concern, consider using Sparkle Cache

Dependencies

~13–20MB
~416K SLoC