Compare commits
No commits in common. "86e836a3ca3c49c733aef365e9802928c6f820c5" and "342bf5ea2d238a58a838876f3dbb910cf8bd4962" have entirely different histories.
86e836a3ca
...
342bf5ea2d
8 changed files with 2 additions and 2621 deletions
1
.gitignore
vendored
1
.gitignore
vendored
|
|
@ -1,2 +1 @@
|
||||||
/target
|
/target
|
||||||
.env
|
|
||||||
|
|
|
||||||
2555
Cargo.lock
generated
2555
Cargo.lock
generated
File diff suppressed because it is too large
Load diff
|
|
@ -4,8 +4,3 @@ version = "0.1.0"
|
||||||
edition = "2024"
|
edition = "2024"
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
dotenv = "0.15.0"
|
|
||||||
poise = "0.6.1"
|
|
||||||
rand = "0.9.2"
|
|
||||||
serenity = "0.12.4"
|
|
||||||
tokio = { version = "1.21.2", features = ["macros", "rt-multi-thread"] }
|
|
||||||
|
|
|
||||||
|
|
@ -1,3 +0,0 @@
|
||||||
pub mod age;
|
|
||||||
pub mod ping;
|
|
||||||
pub mod roll;
|
|
||||||
|
|
@ -1,10 +0,0 @@
|
||||||
use crate::{Context, Error};
|
|
||||||
|
|
||||||
/// Displays your or another user's account creation date
|
|
||||||
#[poise::command(slash_command, prefix_command)]
|
|
||||||
pub async fn ping(ctx: Context<'_>) -> Result<(), Error> {
|
|
||||||
let response = format!("pong {} !", ctx.author().display_name());
|
|
||||||
|
|
||||||
ctx.reply(response).await?;
|
|
||||||
Ok(())
|
|
||||||
}
|
|
||||||
|
|
@ -1,16 +0,0 @@
|
||||||
use crate::{Context, Error};
|
|
||||||
|
|
||||||
use rand::prelude::*;
|
|
||||||
|
|
||||||
/// Displays your or another user's account creation date
|
|
||||||
#[poise::command(slash_command, prefix_command)]
|
|
||||||
pub async fn roll(
|
|
||||||
ctx: Context<'_>,
|
|
||||||
#[description = "Le nombre de faces du dé"] faces: u64,
|
|
||||||
) -> Result<(), Error> {
|
|
||||||
let num = (1..faces).choose(&mut rand::rng()).unwrap_or(1);
|
|
||||||
|
|
||||||
let response = format!("Le dé à {} faces est tombé sur **{}**", faces, num);
|
|
||||||
ctx.say(response).await?;
|
|
||||||
Ok(())
|
|
||||||
}
|
|
||||||
|
|
@ -1 +0,0 @@
|
||||||
pub mod fun;
|
|
||||||
32
src/main.rs
32
src/main.rs
|
|
@ -1,31 +1,3 @@
|
||||||
use poise::serenity_prelude as serenity;
|
fn main() {
|
||||||
|
println!("Hello, world!");
|
||||||
mod commands;
|
|
||||||
|
|
||||||
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>;
|
|
||||||
|
|
||||||
#[tokio::main]
|
|
||||||
async fn main() {
|
|
||||||
let token = dotenv::var("DISCORD_TOKEN").expect("missing DISCORD_TOKEN");
|
|
||||||
let intents = serenity::GatewayIntents::non_privileged();
|
|
||||||
|
|
||||||
let framework = poise::Framework::builder()
|
|
||||||
.options(poise::FrameworkOptions {
|
|
||||||
commands: vec![commands::fun::ping::ping(), commands::fun::roll::roll()],
|
|
||||||
..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…
Add table
Add a link
Reference in a new issue