Rename project to serenity-additions

Signed-off-by: trivernis <trivernis@protonmail.com>
main
trivernis 3 years ago
parent 530b9b16e4
commit 24ad0f54e4
Signed by: Trivernis
GPG Key ID: DFFFCC2C7A02DB45

2
Cargo.lock generated

@ -1090,7 +1090,7 @@ dependencies = [
]
[[package]]
name = "serenity-rich-interaction"
name = "serenity-additions"
version = "0.3.0"
dependencies = [
"dashmap",

@ -1,5 +1,5 @@
[package]
name = "serenity-rich-interaction"
name = "serenity-additions"
version = "0.3.0"
authors = ["trivernis <trivernis@protonmail.com>"]
edition = "2018"

@ -1,4 +1,4 @@
# Serenity Rich Interaction
# Serenity Additions
This crate provides some types for rich interactions with serenity such as Menus and Ephemeral (self deleting) Messages.
@ -7,12 +7,12 @@ This crate provides some types for rich interactions with serenity such as Menus
You have to register the module in the serenity client builder.
```rust
use serenity::client::Client;
use serenity_rich_interaction::RegisterRichInteractions;
use serenity_additions::RegisterRichInteractions;
#[tokio::main]
async fn get_client {
// stuff
let client = Client::builder("TOKEN").register_rich_interactions().await?;
let client = Client::builder("TOKEN").register_serenity_additions().await?;
// stuff
}
```
@ -25,7 +25,7 @@ use serenity::client::Context;
use serenity::model::id::ChannelId;
use serenity_rich_interaction::menu::{MenuBuilder, Page};
use std::time::Duration;
use serenity_rich_interaction::Result;
use serenity_additions::Result;
pub async fn create_menu(
ctx: &Context,
@ -51,9 +51,9 @@ pub async fn create_menu(
## Ephemeral Message
```rust
use serenity_rich_interaction::core::SHORT_TIMEOUT;
use serenity_rich_interaction::ephemeral_message::EphemeralMessage;
use serenity_rich_interaction::Result;
use serenity_additions::core::SHORT_TIMEOUT;
use serenity_additions::ephemeral_message::EphemeralMessage;
use serenity_additions::Result;
use serenity::client::Context;
use serenity::model::id::ChannelId;

@ -70,19 +70,19 @@ impl MessageHandle {
}
}
pub trait RegisterRichInteractions {
fn register_rich_interactions(self) -> Self;
fn register_rich_interactions_with(self, rich_handler: RichEventHandler) -> Self;
pub trait RegisterAdditions {
fn register_serenity_additions(self) -> Self;
fn register_serenity_additions_with(self, rich_handler: RichEventHandler) -> Self;
}
impl<'a> RegisterRichInteractions for ClientBuilder<'a> {
impl<'a> RegisterAdditions for ClientBuilder<'a> {
/// Registers the rich interactions configuration on the client
fn register_rich_interactions(self) -> Self {
self.register_rich_interactions_with(RichEventHandler::default())
fn register_serenity_additions(self) -> Self {
self.register_serenity_additions_with(RichEventHandler::default())
}
/// Registers the rich interactions with a custom rich event handler
fn register_rich_interactions_with(self, rich_handler: RichEventHandler) -> Self {
fn register_serenity_additions_with(self, rich_handler: RichEventHandler) -> Self {
self.type_map_insert::<EventDrivenMessageContainer>(Arc::new(DashMap::new()))
.raw_event_handler(rich_handler)
}

@ -31,18 +31,21 @@ impl<T> EventCallback<T> {
/// A handler for raw serenity events
/// ```
/// use serenity_rich_interaction::events::RichEventHandler;
/// use serenity_additions::events::RichEventHandler;
/// use serenity::model::event;
/// use serenity::client::Client;
/// use serenity_rich_interaction::RegisterRichInteractions;
/// use serenity_additions::RegisterAdditions;
/// # async fn a() -> serenity_additions::Result<()> {
///
/// let mut handler = RichEventHandler::default();
/// handler.add_event(|ctx, e: &event::ReadyEvent| Box::pin(async move {
/// println!("Ready event received");
/// Ok(())
/// }));
/// let client = Client::builder("TOKEN").register_rich_interactions_with(handler).await?;
/// let client = Client::builder("TOKEN").register_serenity_additions_with(handler).await?;
/// // ...
/// # unimplemented!()
/// # }
/// ```
pub struct RichEventHandler {
callbacks: HashMap<TypeId, Vec<Arc<dyn Any + Send + Sync>>>,

@ -5,5 +5,5 @@ pub mod events;
pub mod menu;
pub static VERSION: &str = env!("CARGO_PKG_VERSION");
pub use crate::core::RegisterRichInteractions;
pub use crate::core::RegisterAdditions;
pub use error::*;

Loading…
Cancel
Save