main.rs 931 B

123456789101112131415161718192021222324252627282930313233343536373839404142
  1. use std::env;
  2. use serenity::{async_trait, client::{Client, Context, EventHandler}, framework::{
  3. StandardFramework,
  4. }, model::gateway::Ready};
  5. use songbird::{
  6. SerenityInit,
  7. };
  8. mod audio;
  9. mod util;
  10. struct Handler;
  11. #[async_trait]
  12. impl EventHandler for Handler{
  13. async fn ready(&self, _: Context, _: Ready){
  14. println!("bot connected");
  15. }
  16. }
  17. #[tokio::main]
  18. async fn main() {
  19. let token = env::var("OCTAVE_BOT_TOKEN").expect("Error: token not found");
  20. let framework = StandardFramework::new()
  21. .configure(|c|{
  22. c.prefix("a.")
  23. })
  24. .group(&audio::AUDIO_GROUP);
  25. let mut client = Client::builder(token)
  26. .event_handler(Handler)
  27. .framework(framework)
  28. .register_songbird()
  29. .await
  30. .expect("Error creating client");
  31. if let Err(why) = client.start().await{
  32. println!("Error starting client: {:?}", why);
  33. }
  34. }