init commit
This commit is contained in:
		
							
								
								
									
										1
									
								
								.gitignore
									
									
									
									
										vendored
									
									
										Normal file
									
								
							
							
						
						
									
										1
									
								
								.gitignore
									
									
									
									
										vendored
									
									
										Normal file
									
								
							@@ -0,0 +1 @@
 | 
				
			|||||||
 | 
					/target
 | 
				
			||||||
							
								
								
									
										1759
									
								
								Cargo.lock
									
									
									
										generated
									
									
									
										Normal file
									
								
							
							
						
						
									
										1759
									
								
								Cargo.lock
									
									
									
										generated
									
									
									
										Normal file
									
								
							
										
											
												File diff suppressed because it is too large
												Load Diff
											
										
									
								
							
							
								
								
									
										16
									
								
								Cargo.toml
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										16
									
								
								Cargo.toml
									
									
									
									
									
										Normal 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"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@@ -1,3 +1,4 @@
 | 
				
			|||||||
# discord-bot-template
 | 
					# discord-bot-template
 | 
				
			||||||
 | 
					
 | 
				
			||||||
a quick rust-based discord bot template
 | 
					A quick rust-based discord bot template.
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 
 | 
				
			|||||||
							
								
								
									
										19
									
								
								src/command.rs
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										19
									
								
								src/command.rs
									
									
									
									
									
										Normal 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
									
								
							
							
						
						
									
										58
									
								
								src/main.rs
									
									
									
									
									
										Normal 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();
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
		Reference in New Issue
	
	Block a user