Advertisement
Guest User

infbot

a guest
Jun 19th, 2018
84
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 8.14 KB | None | 0 0
  1. package com.infinitybot;
  2.  
  3. import com.infinitybot.events.Events;
  4. import net.dv8tion.jda.core.AccountType;
  5. import net.dv8tion.jda.core.EmbedBuilder;
  6. import net.dv8tion.jda.core.JDABuilder;
  7. import net.dv8tion.jda.core.entities.Game;
  8. import net.dv8tion.jda.core.entities.MessageType;
  9. import net.dv8tion.jda.core.entities.TextChannel;
  10. import net.dv8tion.jda.core.events.message.guild.GuildMessageReceivedEvent;
  11. import net.dv8tion.jda.core.hooks.ListenerAdapter;
  12.  
  13. import java.awt.*;
  14.  
  15. public class InfinityBot extends ListenerAdapter {
  16.    
  17.     private static final String BOT_TOKEN = "NDI0NjE2Nzk1NTI2Mzk3OTcy.DY7evg.aOZzTovrBADHzwBikUYjtT3it68";
  18.     private static final String COMMAND_PREFIX = "~";
  19.    
  20.     public static void main(String[] args) throws Throwable {
  21.         new JDABuilder(AccountType.BOT)
  22.                 .setToken(BOT_TOKEN)
  23.                 .setGame(Game.playing("~help | infinityosrs.com"))
  24.                 .addEventListener(new InfinityBot())
  25.                 .buildBlocking();
  26.     }
  27.     // Handle commands
  28.    
  29.    
  30.     private void handleCommand(GuildMessageReceivedEvent event,
  31.                                String command,
  32.                                String context) {
  33.         final TextChannel channel = event.getChannel();
  34.        
  35.         switch (command) {
  36.            
  37.             case "help":
  38.                 EmbedBuilder helpBldr = new EmbedBuilder();
  39.                 helpBldr.setColor(Color.BLACK);
  40.                 helpBldr.addField("~help", "Shows this help message.", false);
  41.                 helpBldr.addField("~offsite", "Links our offsite.", false);
  42.                 helpBldr.addField("~rules", "Brings up a list of our rules.", false);
  43.                 helpBldr.addField("~events", "Sends a message with a link to our events schedule.", false);
  44.                 helpBldr.addField("~roster", "Links our clan roster.", false);
  45.                 channel.sendMessage(helpBldr.build()).queue();
  46.                 return;
  47.            
  48.             case "offsite":
  49.                 channel.sendMessage("http://infinityosrs.com").queue();
  50.                 return;
  51.            
  52.             case "events":
  53.                 //channel.sendMessage("Requesting events...").queue();
  54.                 Events.INSTANCE.getLatestEvents(channel);
  55.                 return;
  56.            
  57.             case "roster":
  58.                 channel.sendMessage("https://docs.google.com/spreadsheets/d/e/2PACX-1vR2bVv2SYbCVv31ohGMgkQRMQqsTRUXE6e8uWD8NHJcn2DhUb_iFK-NFrxpo8GRYByjbojcVgLYB1K1/pubhtml?gid=745622319&single=true").queue();
  59.                 return;
  60.            
  61.             case "rules":
  62.                 EmbedBuilder bldr = new EmbedBuilder();
  63.                 bldr.setColor(Color.black);
  64.                 bldr.setTitle("Infinity RS' Rules");
  65.                 bldr.addField("Rules of Chat",
  66.                         "Welcome to your new homechat, Infinity. We are so happy to have you!\n" +
  67.                                 "Our clan-chat is welcome to anyone. We don't want to be abrupt in your game-play so, we only ask that you please follow these general, basic, moral rules of respect. \n", false);
  68.                 bldr.addField("Specific Rules",
  69.                         "1. It is NOT okay to ask other clan members to report other players.\n" +
  70.                                 "2. It is NOT okay to advert forother clan-chats in our chat.\n" +
  71.                                 "3. We don't tolerate political discussion within the chat, to keep the air clean.\n" +
  72.                                 "4. CRASHING IS BANNABLE\n" +
  73.                                 "5. It is NOT okay to scam or lure anyone in or out of our clan(even if just for fun)!\n" +
  74.                                 "6. It is NOT okay to say the following banned words(and any variations); Cunt, Nigger, Nigga.\n", false);
  75.                 bldr.addField("Staking Rules",
  76.                         "Encouragement of staking, posting wins and loses or a self-made decision to stake should be left OUT of clanchat. If you are consistently caught encouraging staking, you will be removed and terminated from clan. However, we don’t care if you stake. :)", false);
  77.                 bldr.addField("General Rules",
  78.                         "1. Follow all of Jagex's placed rules of Runescape.\n" +
  79.                                 "2. Respect one another, both IN AND OUT of the clan.\n" +
  80.                                 "3. No stake talk or encouragement / No Spamming, Luring or Begging / No Impersonations\n" +
  81.                                 "4. Crashing is BANNABLE.\n" +
  82.                                 "5. Do not ask members to report other players.\n" +
  83.                                 "6. Do not retaliate with hostile attitude. IN AND OUT OF CHAT.\n" +
  84.                                 "7. Do not multi-clan. Joining FFA cc's for leisure can be considered acceptable.\n" +
  85.                                 "8. Do not advertise other clans in our chat & do not advertise our clan in other chats.\n" +
  86.                                 "9. Do not intentionally PK members.\n" +
  87.                                 "10. No vile behavior/discussions. Light banter can be acceptable but, do not offend others or act out immaturely.\n" + "\n" + "\n", false);
  88.                 bldr.addField("Detailed Clan Rules",
  89.                         "A list of detailed clan rules to follow.", false);
  90.                 bldr.addField("Rule #1: No personal attacks or harassment",
  91.                         "No attacks against someone's race, religion, politics, sex, sexual orientation, ect. No acts of harassment of a violent or sexual nature.", false);
  92.                 bldr.addField("Rule #2: No Begging",
  93.                         "As a community clan we like to help the best we can but, asking gets persistent. This persistence is what we want to avoid. Do not consistently beg in our chat for items/coins. We all started with bronze items.", false);
  94.                 bldr.addField("Rule #3: Don't monopolize the conversation",
  95.                         "Encourage players with their success & within a conversation. The chat is for everybody, it's not just about you. So please, don't embrace your delusion of being better than anyone else. We are EQUAL.", false);
  96.                 bldr.addField("Rule #4: Be community-minded",
  97.                         "Express yourself in ways that are constructive && will help foster the good of the community. Our ranks have absolutely NO toleration of Runescape's reportable rule #14. Disruptive Behavior", false);
  98.                 bldr.addField("Rule #5: No impersonations",
  99.                         "Creating fake accounts to impersonate a member of the clan, ESPECIALLY A HIGH RANKED MEMBER, will result in a permanent ban and IP ban from forums.", false);
  100.                 bldr.addField("Rules #6: No spamming",
  101.                         "No randomized, continuous characters/SONG LYRICS, No continuously spamming, if no one is talking then we are all busy. Do not flood our chat. *This includes aqps and symbol spamming.", false);
  102.                 bldr.addField("Rule #7: No retaliations",
  103.                         "If you are taken offence verbally from anyone in our chat please, ADD THEM TO YOUR IGNORE. As, retaliation is not tolerated. This particular rule includes; Name calling, responding with hostility, spamming, causing an uproar in chat & provoking negative conversations. This rule is applied to both, In and out of chat.", false);
  104.                 bldr.addField("Rule #8: General Respect, have it!",
  105.                         "NEVER call another player a hurtful or disrespectful name. Do not discourage players in their achievements; in game & IRL. Respect our rules, our wonderful members and the work our ranks put in for helping us shape a better community. This includes ANY rank or member.", false);
  106.                 bldr.addField("Everything else;",
  107.                         "Anything not mentioned in one of the rules above but, is still generally considered violent behavior, is not allowed. Our ranks are a pretty tolerant bunch but, if something catches their eye, you know you're in trouble.\n" + "\n" +
  108.                                 "We would also like to remind you, if anyone is breaking these rules of the chat, please add them to your ignore list. As, retaliation is not tolerated. :)", false);
  109.                 channel.sendMessage(bldr.build()).queue();
  110.                 return;
  111.            
  112.             case "rosterinfo": {
  113.                 //new rosterLookup();
  114.                 return;
  115.             }
  116.            
  117.             default:
  118.                 System.out.println("Unknown command " + command + " with context: " + context + ".");
  119.         }
  120.     }
  121.    
  122.    
  123.     // Receive command events from JDA
  124.    
  125.     @Override
  126.     public void onGuildMessageReceived(GuildMessageReceivedEvent event) {
  127.         // Wouldn't want a bot-to-bot war, this is how the matrix started
  128.         if (event.getAuthor().isBot()) return;
  129.        
  130.         if (event.getMessage().getType() == MessageType.DEFAULT) {
  131.             String content = event.getMessage().getContentDisplay();
  132.            
  133.             if (content.length() > COMMAND_PREFIX.length() &&
  134.                         content.startsWith(COMMAND_PREFIX)) {
  135.                 // We know the command starts with "~" AND has more than that
  136.                 content = content.substring(COMMAND_PREFIX.length());
  137.                 String[] args = content.split(" ", 2);
  138.                 String command = args[0].toLowerCase();
  139.                 String context = args.length == 2 ? args[1] : "";
  140.                
  141.                 try {
  142.                     handleCommand(event, command, context);
  143.                 } catch (Exception ex) {
  144.                     System.err.println("Command failed: " + content);
  145.                     ex.printStackTrace();
  146.                 }
  147.             }
  148.         }
  149.     }
  150.    
  151. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement