Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(shuttle-serenity): make serenity 0.12 default, support poise 0.6, deprecate shuttle-poise #1521

Merged
merged 10 commits into from
Jan 23, 2024
2 changes: 1 addition & 1 deletion .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -759,7 +759,7 @@ workflows:
- services/shuttle-serenity
features:
- "-F serenity"
- "-F serenity-0-12-rustls_backend --no-default-features"
- "-F serenity-0-11-rustls_backend --no-default-features"
- test-workspace-member:
name: << matrix.crate >>
matrix:
Expand Down
2 changes: 1 addition & 1 deletion examples
Submodule examples updated 51 files
+2 −2 actix-web/cookie-authentication/Cargo.toml
+2 −2 actix-web/hello-world/Cargo.toml
+4 −4 actix-web/postgres/Cargo.toml
+2 −2 actix-web/static-files/Cargo.toml
+2 −2 actix-web/websocket-actorless/Cargo.toml
+2 −2 axum/hello-world/Cargo.toml
+2 −2 axum/jwt-authentication/Cargo.toml
+3 −3 axum/metadata/Cargo.toml
+4 −4 axum/postgres/Cargo.toml
+3 −3 axum/qdrant/Cargo.toml
+2 −2 axum/static-files/Cargo.toml
+2 −2 axum/static-next-server/Cargo.toml
+3 −3 axum/turso/Cargo.toml
+2 −2 axum/websocket/Cargo.toml
+2 −2 axum/with-state/Cargo.toml
+3 −3 custom-resource/pdo/Cargo.toml
+10 −22 custom-resource/pdo/src/lib.rs
+1 −1 custom-service/none/Cargo.toml
+2 −2 custom-service/request-scheduler/Cargo.toml
+1 −0 fullstack-templates/saas/Cargo.toml
+5 −5 fullstack-templates/saas/backend/Cargo.toml
+1 −1 next/hello-world/Cargo.toml
+3 −3 other/standalone-binary/Cargo.toml
+1 −1 poem/hello-world/Cargo.toml
+2 −2 poem/mongodb/Cargo.toml
+3 −3 poem/postgres/Cargo.toml
+6 −5 poise/hello-world/Cargo.toml
+0 −1 poise/hello-world/Shuttle.toml
+8 −7 poise/hello-world/src/main.rs
+2 −2 rocket/dyn-templates/Cargo.toml
+2 −2 rocket/hello-world/Cargo.toml
+2 −2 rocket/jwt-authentication/Cargo.toml
+3 −3 rocket/persist/Cargo.toml
+4 −4 rocket/postgres/Cargo.toml
+3 −3 rocket/secrets/Cargo.toml
+2 −2 rocket/static-files/Cargo.toml
+4 −4 rocket/url-shortener/Cargo.toml
+2 −2 rocket/workspace/hello-world/Cargo.toml
+2 −2 salvo/hello-world/Cargo.toml
+5 −5 serenity/hello-world/Cargo.toml
+0 −1 serenity/hello-world/Shuttle.toml
+7 −7 serenity/postgres/Cargo.toml
+0 −1 serenity/postgres/Shuttle.toml
+74 −73 serenity/postgres/src/main.rs
+2 −2 thruster/hello-world/Cargo.toml
+4 −4 thruster/postgres/Cargo.toml
+2 −2 tide/hello-world/Cargo.toml
+4 −4 tide/postgres/Cargo.toml
+2 −2 tower/hello-world/Cargo.toml
+2 −2 tracing/custom-tracing-subscriber/Cargo.toml
+2 −2 warp/hello-world/Cargo.toml
8 changes: 2 additions & 6 deletions services/shuttle-poise/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,5 @@ keywords = ["shuttle-service", "poise", "discord-bot", "serenity"]
[workspace]

[dependencies]
poise = { version = "0.5.2" }
shuttle-runtime = { path = "../../runtime", version = "0.36.0", default-features = false }

[dev-dependencies]
shuttle-secrets = { path = "../../resources/secrets" }
tokio = { version = "1.26.0", features = ["macros", "rt-multi-thread"] }
poise = "0.5.2"
shuttle-runtime = { path = "../../runtime", version = "<=0.40.0", default-features = false }
48 changes: 3 additions & 45 deletions services/shuttle-poise/README.md
Original file line number Diff line number Diff line change
@@ -1,47 +1,5 @@
## Shuttle service integration for the Poise discord bot framework.
## Shuttle service integration for the Poise Discord bot framework

### Example
**This plugin is deprecated.**

```rust,no_run
use poise::serenity_prelude as serenity;
use shuttle_secrets::SecretStore;
use shuttle_poise::ShuttlePoise;

struct Data {} // User data, which is stored and accessible in all command invocations
type Error = Box<dyn std::error::Error + Send + Sync>;
type Context<'a> = poise::Context<'a, Data, Error>;

/// Responds with "world!"
#[poise::command(slash_command)]
async fn hello(ctx: Context<'_>) -> Result<(), Error> {
ctx.say("world!").await?;
Ok(())
}

#[shuttle_runtime::main]
async fn poise(#[shuttle_secrets::Secrets] secret_store: SecretStore) -> ShuttlePoise<Data, Error> {
// Get the discord token set in `Secrets.toml`
let discord_token = secret_store
.get("DISCORD_TOKEN")
.expect("'DISCORD_TOKEN' was not found");

let framework = poise::Framework::builder()
.options(poise::FrameworkOptions {
commands: vec![hello()],
..Default::default()
})
.token(discord_token)
.intents(serenity::GatewayIntents::non_privileged())
.setup(|ctx, _ready, framework| {
Box::pin(async move {
poise::builtins::register_globally(ctx, &framework.options().commands).await?;
Ok(Data {})
})
})
.build()
.await
.map_err(shuttle_runtime::CustomError::new)?;

Ok(framework.into())
}
```
Poise >=0.6 can now be used together with [shuttle-serenity](https://docs.rs/shuttle-serenity/latest/shuttle_serenity/).
1 change: 1 addition & 0 deletions services/shuttle-poise/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ use std::net::SocketAddr;
use std::sync::Arc;

/// A wrapper type for [poise::Framework] so we can implement [shuttle_runtime::Service] for it.
#[deprecated = "shuttle-poise for poise 0.5 is deprecated. To use poise 0.6 and Shuttle, check https://docs.rs/shuttle-serenity/latest/shuttle_serenity/"]
pub struct PoiseService<T, E>(pub Arc<poise::Framework<T, E>>);

#[shuttle_runtime::async_trait]
Expand Down
8 changes: 4 additions & 4 deletions services/shuttle-serenity/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@ keywords = ["shuttle-service", "serenity"]
[workspace]

[dependencies]
serenity = { version = "0.11.5", default-features = false, features = ["client", "gateway", "model"], optional = true }
serenity-0-12 = { package = "serenity", version = "0.12", default-features = false, features = ["client", "gateway", "model"], optional = true }
serenity = { version = "0.12", default-features = false, features = ["client", "gateway", "model"], optional = true }
serenity-0-11 = { package = "serenity", version = "0.11.7", default-features = false, features = ["client", "gateway", "model"], optional = true }
shuttle-runtime = { path = "../../runtime", version = "0.36.0", default-features = false }

[dev-dependencies]
Expand All @@ -24,5 +24,5 @@ default = ["rustls_backend"]

rustls_backend = ["serenity/rustls_backend"]
native_tls_backend = ["serenity/native_tls_backend"]
serenity-0-12-rustls_backend = ["serenity-0-12/rustls_backend"]
serenity-0-12-native_tls_backend = ["serenity-0-12/native_tls_backend"]
serenity-0-11-rustls_backend = ["serenity-0-11/rustls_backend"]
serenity-0-11-native_tls_backend = ["serenity-0-11/native_tls_backend"]
11 changes: 7 additions & 4 deletions services/shuttle-serenity/README.md
Original file line number Diff line number Diff line change
@@ -1,9 +1,12 @@
## Shuttle service integration for the Serenity discord bot framework.
## Shuttle service integration for the Serenity Discord bot framework

Serenity 0.12 is used by default. Poise 0.6 is also supported.

Serenity 0.11 is supported by using these feature flags (native TLS also available):

Serenity 0.12 is now supported by using these feature flags (native TLS also available):
```toml,ignore
serenity = { version = "0.12.0", features = ["..."] }
shuttle-serenity = { version = "0.36.0", default-features = false, features = ["serenity-0-12-rustls_backend"] }
serenity = { version = "0.11.7", features = ["..."] }
shuttle-serenity = { version = "0.36.0", default-features = false, features = ["serenity-0-11-rustls_backend"] }
```

### Example
Expand Down
4 changes: 2 additions & 2 deletions services/shuttle-serenity/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ use std::net::SocketAddr;

#[cfg(feature = "serenity")]
use serenity::Client;
#[cfg(feature = "serenity-0-12")]
use serenity_0_12::Client;
#[cfg(feature = "serenity-0-11")]
use serenity_0_11::Client;

/// A wrapper type for [serenity::Client] so we can implement [shuttle_runtime::Service] for it.
pub struct SerenityService(pub Client);
Expand Down