SHARE
TWEET

Untitled

a guest May 19th, 2019 81 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. use serenity::client::Client;
  2. use serenity::framework::standard::{
  3.     macros::{command, group},
  4.     CommandResult, StandardFramework,
  5. };
  6. use serenity::model::channel::Message;
  7. use serenity::prelude::{Context, EventHandler};
  8. use std::env;
  9.  
  10. group!({
  11.     name: "general",
  12.     options: {},
  13.     commands: [ping, bump_now],
  14. });
  15.  
  16. struct Handler;
  17.  
  18. impl EventHandler for Handler {}
  19.  
  20. fn main() {
  21.     println!("starting...");
  22.     // Login with a bot token from the environment
  23.     let mut client = Client::new(&env::var("DISCORD_TOKEN").expect("token"), Handler)
  24.         .expect("error creating client");
  25.     client.with_framework(
  26.         StandardFramework::new()
  27.             .configure(|c| c.prefix("!"))
  28.             .group(&GENERAL_GROUP),
  29.     );
  30.  
  31.     // start listening for events by starting a single shard
  32.     if let Err(why) = client.start() {
  33.         println!("an error occurred while running the client: {:?}", why);
  34.     }
  35. }
  36.  
  37. #[command]
  38. fn ping(ctx: &mut Context, msg: &Message) -> CommandResult {
  39.     msg.reply(ctx, "Pong!")?;
  40.     Ok(())
  41. }
  42.  
  43. #[command]
  44. fn bump_now(ctx: &mut Context, msg: &Message) -> CommandResult {
  45.     let channel = msg.channel_id;
  46.     channel.say(ctx, "!d bump")?;
  47.     Ok(())
  48. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top