first commit
This commit is contained in:
commit
b73cb21a94
8 changed files with 2838 additions and 0 deletions
2
.gitignore
vendored
Normal file
2
.gitignore
vendored
Normal file
|
|
@ -0,0 +1,2 @@
|
||||||
|
/target
|
||||||
|
.env
|
||||||
2737
Cargo.lock
generated
Normal file
2737
Cargo.lock
generated
Normal file
File diff suppressed because it is too large
Load diff
13
Cargo.toml
Normal file
13
Cargo.toml
Normal file
|
|
@ -0,0 +1,13 @@
|
||||||
|
[package]
|
||||||
|
name = "portfolio-roast-bot"
|
||||||
|
version = "0.1.0"
|
||||||
|
edition = "2024"
|
||||||
|
|
||||||
|
[dependencies]
|
||||||
|
dotenv = "0.15.0"
|
||||||
|
poise = "0.6.1"
|
||||||
|
reqwest = "0.12.24"
|
||||||
|
serde_json = "1.0.145"
|
||||||
|
serenity = "0.12.5"
|
||||||
|
tokio = { version = "1.21.2", features = ["macros", "rt-multi-thread"] }
|
||||||
|
serde = "1.0.228"
|
||||||
1
src/commands.rs
Normal file
1
src/commands.rs
Normal file
|
|
@ -0,0 +1 @@
|
||||||
|
pub mod info;
|
||||||
21
src/commands/info.rs
Normal file
21
src/commands/info.rs
Normal file
|
|
@ -0,0 +1,21 @@
|
||||||
|
use crate::{Context, Error};
|
||||||
|
|
||||||
|
/// Show this help menu
|
||||||
|
#[poise::command(track_edits, slash_command)]
|
||||||
|
pub async fn help(
|
||||||
|
ctx: Context<'_>,
|
||||||
|
#[description = "Specific command to show help about"]
|
||||||
|
#[autocomplete = "poise::builtins::autocomplete_command"]
|
||||||
|
command: Option<String>,
|
||||||
|
) -> Result<(), Error> {
|
||||||
|
poise::builtins::help(
|
||||||
|
ctx,
|
||||||
|
command.as_deref(),
|
||||||
|
poise::builtins::HelpConfiguration {
|
||||||
|
// extra_text_at_bottom: "made with ❤️",
|
||||||
|
..Default::default()
|
||||||
|
},
|
||||||
|
)
|
||||||
|
.await?;
|
||||||
|
Ok(())
|
||||||
|
}
|
||||||
1
src/events.rs
Normal file
1
src/events.rs
Normal file
|
|
@ -0,0 +1 @@
|
||||||
|
pub mod ready;
|
||||||
10
src/events/ready.rs
Normal file
10
src/events/ready.rs
Normal file
|
|
@ -0,0 +1,10 @@
|
||||||
|
use crate::Error;
|
||||||
|
use poise::serenity_prelude as serenity;
|
||||||
|
|
||||||
|
pub async fn on_ready(
|
||||||
|
_ctx: &serenity::Context,
|
||||||
|
data_about_bot: &serenity::Ready,
|
||||||
|
) -> Result<(), Error> {
|
||||||
|
println!("Logged in as {}", data_about_bot.user.name);
|
||||||
|
Ok(())
|
||||||
|
}
|
||||||
53
src/main.rs
Normal file
53
src/main.rs
Normal file
|
|
@ -0,0 +1,53 @@
|
||||||
|
use dotenv;
|
||||||
|
use poise::serenity_prelude as serenity;
|
||||||
|
mod commands;
|
||||||
|
mod events;
|
||||||
|
|
||||||
|
struct Data {}
|
||||||
|
|
||||||
|
// Types used by all command functions
|
||||||
|
type Error = Box<dyn std::error::Error + Send + Sync>;
|
||||||
|
type Context<'a> = poise::Context<'a, Data, Error>;
|
||||||
|
|
||||||
|
async fn event_handler(
|
||||||
|
ctx: &serenity::Context,
|
||||||
|
event: &serenity::FullEvent,
|
||||||
|
_framework: poise::FrameworkContext<'_, Data, Error>,
|
||||||
|
_data: &Data,
|
||||||
|
) -> Result<(), Error> {
|
||||||
|
match event {
|
||||||
|
serenity::FullEvent::Ready { data_about_bot, .. } => {
|
||||||
|
events::ready::on_ready(ctx, data_about_bot).await?;
|
||||||
|
}
|
||||||
|
_ => {}
|
||||||
|
}
|
||||||
|
Ok(())
|
||||||
|
}
|
||||||
|
|
||||||
|
#[tokio::main]
|
||||||
|
async fn main() {
|
||||||
|
dotenv::dotenv().ok();
|
||||||
|
let token = std::env::var("DISCORD_TOKEN").expect("missing DISCORD_TOKEN");
|
||||||
|
let intents = serenity::GatewayIntents::non_privileged();
|
||||||
|
|
||||||
|
let framework = poise::Framework::builder()
|
||||||
|
.options(poise::FrameworkOptions {
|
||||||
|
commands: vec![commands::info::help()],
|
||||||
|
event_handler: |ctx, event, framework, data| {
|
||||||
|
Box::pin(event_handler(ctx, event, framework, data))
|
||||||
|
},
|
||||||
|
..Default::default()
|
||||||
|
})
|
||||||
|
.setup(|ctx, _ready, framework| {
|
||||||
|
Box::pin(async move {
|
||||||
|
poise::builtins::register_globally(ctx, &framework.options().commands).await?;
|
||||||
|
Ok(Data {})
|
||||||
|
})
|
||||||
|
})
|
||||||
|
.build();
|
||||||
|
|
||||||
|
let client = serenity::ClientBuilder::new(token, intents)
|
||||||
|
.framework(framework)
|
||||||
|
.await;
|
||||||
|
client.unwrap().start().await.unwrap();
|
||||||
|
}
|
||||||
Loading…
Reference in a new issue