mirror of
https://github.com/ethanrusz/echbot.git
synced 2024-11-21 19:57:46 -05:00
Add basic bot with ping command
This commit is contained in:
parent
025413b4b9
commit
165a77f510
4 changed files with 1631 additions and 0 deletions
6
.gitignore
vendored
6
.gitignore
vendored
|
@ -8,3 +8,9 @@ Cargo.lock
|
|||
|
||||
# These are backup files generated by rustfmt
|
||||
**/*.rs.bk
|
||||
|
||||
|
||||
# Added by cargo
|
||||
|
||||
/target
|
||||
/.idea/
|
||||
|
|
1580
Cargo.lock
generated
Normal file
1580
Cargo.lock
generated
Normal file
File diff suppressed because it is too large
Load diff
10
Cargo.toml
Normal file
10
Cargo.toml
Normal file
|
@ -0,0 +1,10 @@
|
|||
[package]
|
||||
name = "echbot"
|
||||
version = "0.1.0"
|
||||
edition = "2021"
|
||||
|
||||
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
|
||||
|
||||
[dependencies]
|
||||
poise = "0.5.2"
|
||||
tokio = { version = "1.21.2", features = ["macros", "rt-multi-thread"] }
|
35
src/main.rs
Normal file
35
src/main.rs
Normal file
|
@ -0,0 +1,35 @@
|
|||
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>;
|
||||
|
||||
// Basically a ping command
|
||||
#[poise::command(slash_command, prefix_command)]
|
||||
async fn slur(
|
||||
ctx: Context<'_>,
|
||||
) -> Result<(), Error> {
|
||||
let response = "If you don't like my content or the way I act, don't watch me.";
|
||||
ctx.say(response).await?;
|
||||
Ok(())
|
||||
}
|
||||
|
||||
#[tokio::main]
|
||||
async fn main() {
|
||||
let framework = poise::Framework::builder()
|
||||
.options(poise::FrameworkOptions {
|
||||
commands: vec![slur()],
|
||||
..Default::default()
|
||||
})
|
||||
.token(std::env::var("DISCORD_TOKEN").expect("missing 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 {})
|
||||
})
|
||||
});
|
||||
|
||||
framework.run().await.unwrap();
|
||||
}
|
Loading…
Reference in a new issue