init commit

This commit is contained in:
2023-11-02 17:35:08 -06:00
parent 6c9730f11e
commit ac8cf3b489
7 changed files with 1856 additions and 1 deletions

19
src/command.rs Normal file
View File

@@ -0,0 +1,19 @@
use std::hint::black_box;
use anyhow::Error;
use crate::Context;
#[poise::command(slash_command, rename = "discord's command name", guild_only)]
pub async fn example(
ctx: Context<'_>,
#[description = "input description shown in discord"]
input: String
) -> Result<(), Error> {
// Do something...
black_box(ctx);
black_box(input);
Ok(())
}

58
src/main.rs Normal file
View File

@@ -0,0 +1,58 @@
use poise::serenity_prelude as serenity;
use dotenv;
mod command;
pub struct Data {} // User data, which is stored and accessible in all command invocations
type Context<'a> = poise::Context<'a, Data, anyhow::Error>;
#[tokio::main]
async fn main() {
dotenv::dotenv().ok();
let token = std::env::var("DISCORD_TOKEN").expect("missing DISCORD_TOKEN");
println!(r#"
/$$$$$$$$ /$$ /$$ /$$$$$$$ /$$
|__ $$__/ | $$ | $$ | $$__ $$ | $$
| $$ /$$$$$$ /$$$$$$/$$$$ /$$$$$$ | $$ /$$$$$$ /$$$$$$ /$$$$$$ | $$ \ $$ /$$$$$$ /$$$$$$
| $$ /$$__ $$| $$_ $$_ $$ /$$__ $$| $$ |____ $$|_ $$_/ /$$__ $$ | $$$$$$$ /$$__ $$|_ $$_/
| $$| $$$$$$$$| $$ \ $$ \ $$| $$ \ $$| $$ /$$$$$$$ | $$ | $$$$$$$$ | $$__ $$| $$ \ $$ | $$
| $$| $$_____/| $$ | $$ | $$| $$ | $$| $$ /$$__ $$ | $$ /$$| $$_____/ | $$ \ $$| $$ | $$ | $$ /$$
| $$| $$$$$$$| $$ | $$ | $$| $$$$$$$/| $$| $$$$$$$ | $$$$/| $$$$$$$ | $$$$$$$/| $$$$$$/ | $$$$/
|__/ \_______/|__/ |__/ |__/| $$____/ |__/ \_______/ \___/ \_______/ |_______/ \______/ \___/
| $$
| $$
|__/
Template Bot.
Invite this bot with:
"#);
let intents =
serenity::GatewayIntents::GUILD_VOICE_STATES |
serenity::GatewayIntents::non_privileged();
let framework = poise::Framework::builder()
.options(poise::FrameworkOptions {
commands: vec![
command::example(),
],
..Default::default()
})
// un-comment songbird from Cargo.toml first.
//.client_settings(songbird::register)
.token(token)
.intents(intents)
.setup(|ctx, _ready, framework| {
Box::pin(async move {
poise::builtins::register_globally(ctx, &framework.options().commands).await?;
Ok(Data {})
})
});
framework.build().await.unwrap().start().await.unwrap();
}