main.rs 1013 B

123456789101112131415161718192021222324252627282930313233343536373839404142
  1. use serenity::{
  2. async_trait,
  3. client::{Client, Context, EventHandler},
  4. framework::StandardFramework,
  5. model::gateway::{GatewayIntents, Ready},
  6. };
  7. use std::env;
  8. use songbird::SerenityInit;
  9. mod audio;
  10. mod util;
  11. struct Handler;
  12. #[async_trait]
  13. impl EventHandler for Handler {
  14. async fn ready(&self, _: Context, _: Ready) {
  15. println!("bot connected");
  16. }
  17. }
  18. #[tokio::main]
  19. async fn main() {
  20. let token = env::var("OCTAVE_BOT_TOKEN").expect("Error: token not found");
  21. let framework = StandardFramework::new()
  22. .configure(|c| c.prefix("!"))
  23. .group(&audio::AUDIO_GROUP);
  24. let intents = GatewayIntents::non_privileged() | GatewayIntents::MESSAGE_CONTENT;
  25. let mut client = Client::builder(token, intents)
  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. }