Advertisement
Guest User

MainRunner

a guest
Dec 18th, 2017
67
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.36 KB | None | 0 0
  1. import com.sun.deploy.util.SessionState;
  2. import sx.blah.discord.api.ClientBuilder;
  3. import sx.blah.discord.api.IDiscordClient;
  4.  
  5. public class MainRunner {
  6.  
  7. public static void main(String[] args) {
  8.  
  9. if (args.length != 1) {
  10. System.out.println("Please enter the bots token as the first argument e.g java -jar thisjar.jar tokenhere");
  11. return;
  12. }
  13.  
  14. IDiscordClient cli = BotUtils.getBuiltDiscordClient("client");
  15.  
  16. /*
  17. // Commented out as you don't really want duplicate listeners unless you're intentionally writing your code
  18. // like that.
  19. // Register a listener via the IListener interface
  20. cli.getDispatcher().registerListener(new IListener<MessageReceivedEvent>() {
  21. public void handle(MessageReceivedEvent event) {
  22. if(event.getMessage().getContent().startsWith(BotUtils.BOT_PREFIX + "test"))
  23. BotUtils.sendMessage(event.getChannel(), "I am sending a message from an IListener listener");
  24. }
  25. });
  26. */
  27.  
  28. // Register a listener via the EventSubscriber annotation which allows for organisation and delegation of events
  29. cli.getDispatcher().registerListener(new MyEvents());
  30.  
  31. // Only login after all events are registered otherwise some may be missed.
  32. cli.login();
  33.  
  34. }
  35. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement