Skip to content

Commit

Permalink
testing poise success
Browse files Browse the repository at this point in the history
  • Loading branch information
HadziqM committed Dec 12, 2023
1 parent 361678b commit e8b10e0
Show file tree
Hide file tree
Showing 3 changed files with 90 additions and 12 deletions.
76 changes: 69 additions & 7 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions test-bot/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,6 @@ edition = "2021"

[dependencies]
dotenv = "0.15.0"
poise = { version = "0.5.7", features = ["time", "collector"] }
serenity = { version = "0.12.0", features = ["client", "gateway", "rustls_backend", "model", "collector"] }
poise = { git = "https://github.com/serenity-rs/poise", branch = "current", features = [ "collector"] }
serenity = { version = "0.12.0", features = ["client", "gateway", "rustls_backend", "model", "collector", "framework"] }
tokio = { version = "1.35.0", features = ["full"] }
22 changes: 19 additions & 3 deletions test-bot/src/main.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
#![allow(unused)]
use std::collections::HashMap;

use dotenv::{dotenv,var};
use poise::{serenity_prelude as serenity, CreateReply};
use ::serenity::futures::future::ok;
use poise::{serenity_prelude as seren, CreateReply};
use ::serenity::futures::{future::ok, lock::Mutex};

struct Data;

Expand All @@ -24,7 +26,7 @@ async fn on_error(err:poise::FrameworkError<'_,Data,Error>) {
poise::FrameworkError::Setup { error, .. } => {
panic!("failed to setup with err messages {error:?}")
}
poise::FrameworkError::Command { error, ctx } => {
poise::FrameworkError::Command { error, ctx, .. } => {
ctx.say("this can be error").await;
}
error => {
Expand All @@ -40,10 +42,24 @@ async fn main() {
dotenv();
let token = var("TOKEN")
.expect("cant find token in .env");
let intents = seren::GatewayIntents::non_privileged() | seren::GatewayIntents::MESSAGE_CONTENT;

let opt = poise::FrameworkOptions {
commands:vec![ping(),error()],
on_error: |err| Box::pin(on_error(err)),
..Default::default()
};
let framework = poise::Framework::builder()
.setup(move |ctx, _ready, framework| {
Box::pin(async move {
println!("Logged in as {}", _ready.user.name);
poise::builtins::register_globally(ctx, &framework.options().commands).await?;
Ok(Data {})
})
})
.options(opt)
.build();

let client = seren::client::ClientBuilder::new(token, intents).framework(framework).await;
client.unwrap().start().await.unwrap();
}

0 comments on commit e8b10e0

Please sign in to comment.