rusty_interaction

Crates.iorusty_interaction
lib.rsrusty_interaction
version0.2.3
sourcesrc
created_at2021-05-06 00:14:47.313341
updated_at2022-02-13 00:19:39.89559
descriptionHandle Discord Interactions as outgoing webhook
homepage
repositoryhttps://github.com/0x2b00b1e5/rusty-interaction
max_upload_size
id393631
size125,141
Hugo W. (0x2b00b1e5)

documentation

README

ci-img cio-img lic-img doc-img

Rusty Interaction

This library provides types and helper functions for handling Discord's Interactions. It also provides an actix-web backend handler system to handle Interactions through your own API (instead of using the gateway).

Getting started

To install this library, add this dependency entry to your Cargo.toml file:

rusty_interaction = "0"

By default, this only exposes the types and security check function. If you want to use the handler, add the following to your Cargo.toml:

[dependencies.rusty_interaction]
version = "0"
features = ["handler"]

Take a look at the documentation and the examples to get yourself familiar with using the library.

Basic bot/handler

Please take a look at the following examples:

Contributing

More than welcome! :D

What it has right now

  • - Data models exposure

  • - Interaction validation (crate::security::verify_discord_message())

  • - Receive Interactions from Discord

  • - Bind interactions to a function (with the help of a macro)

  • - Properly respond to interactions from Discord

  • - Nice system to make follow-up messages.

  • - Nice system to manage guild-specific commands.

  • - Support for components (buttons, dropdowns, etc)

  • - Not a pile of spaghetti code that just works (oops...👀)

Difference between receiving interactions through the gateway and your own endpoint

The gateway requires you to have a discord client where you receive interactions. Setting up your own endpoint makes Discord send the interactions to your own API endpoint (ex. https://example.com/api/discord/interactions).

If you already have an API that runs your service and you're looking to integrate with Discord, this way of receiving interactions can be really interesting.

One distinct difference is that you do not need a bot or oauth token for most features. Some features (like command management) do require a bot token.

Ok, I want to receive interactions through the gateway. Does your library support that?

No. If you want to receive interactions through the gateway, you want to take a look at Serenity or one of the other libraries.

Commit count: 250

cargo fmt