init commit

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

1
.env Normal file
View File

@ -0,0 +1 @@
DISCORD_TOKEN="PUT YOUR BOT TOKEN HERE"

1
.gitignore vendored Normal file
View File

@ -0,0 +1 @@
/target

1759
Cargo.lock generated Normal file

File diff suppressed because it is too large Load Diff

16
Cargo.toml Normal file
View File

@ -0,0 +1,16 @@
[package]
name = "discord-word-counter"
version = "0.1.0"
edition = "2021"
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
[dependencies]
tokio = { version = "1.21.2", features = ["macros", "rt-multi-thread"] }
# songbird = { version = "0.3.2", features = ["yt-dlp"] }
poise = { path = "../poise/", features = ["cache"] }
dotenv = "0.15.0"
anyhow = "1.0.75"
url = "2.4.1"
async-recursion = "1.0.5"

View File

@ -1,3 +1,4 @@
# discord-bot-template
a quick rust-based discord bot template
A quick rust-based discord bot template.

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();
}