30 lines
918 B
Rust
30 lines
918 B
Rust
use poise::serenity_prelude as serenity;
|
|
|
|
struct Data {}
|
|
type Error = Box<dyn std::error::Error + Send + Sync>;
|
|
type Context<'a> = poise::Context<'a, Data, Error>;
|
|
|
|
#[poise::command(prefix_command)]
|
|
async fn ping(ctx: Context<'_>) -> Result<(), Error> {
|
|
ctx.say("pang").await?;
|
|
Ok(())
|
|
}
|
|
|
|
#[tokio::main]
|
|
async fn main() {
|
|
let framework = poise::Framework::builder()
|
|
.options(poise::FrameworkOptions {
|
|
commands: vec![ping()],
|
|
..Default::default()
|
|
})
|
|
.token(std::env::var("DISCORD_TOKEN").expect("failed to find DISCORD_TOKEN in env"))
|
|
.intents(serenity::GatewayIntents::non_privileged())
|
|
.setup(|ctx, _ready, framework| {
|
|
Box::pin(async move {
|
|
poise::builtins::register_globally(ctx, &framework.options().commands).await?;
|
|
Ok(Data {})
|
|
})
|
|
});
|
|
framework.run().await.unwrap();
|
|
}
|