added tyler deterrent

This commit is contained in:
Harrison Deng 2017-08-17 15:18:43 -05:00
parent 0074b27204
commit 5ffce1dc5b

View File

@ -1,16 +1,17 @@
package zer01hd.zer10hdbot.listeners;
import java.util.Calendar;
import java.util.Random;
import net.dv8tion.jda.core.entities.Message;
import net.dv8tion.jda.core.entities.MessageChannel;
import net.dv8tion.jda.core.entities.User;
import net.dv8tion.jda.core.events.message.MessageReceivedEvent;
import net.dv8tion.jda.core.hooks.ListenerAdapter;
import zer01hd.zer10hdbot.Zer10HDBot;
public class MessageListener extends ListenerAdapter {
Zer10HDBot z10b;
Random rand = new Random();
public MessageListener(Zer10HDBot z10b) {
this.z10b = z10b;
@ -18,7 +19,7 @@ public class MessageListener extends ListenerAdapter {
@Override
public void onMessageReceived(MessageReceivedEvent event) {
User user = event.getAuthor();
// User user = event.getAuthor();
Message message = event.getMessage();
MessageChannel channel = event.getChannel();
@ -29,7 +30,6 @@ public class MessageListener extends ListenerAdapter {
channel.sendMessage("pong").queue();
} else if (msg.startsWith(z10b.cmdPrefix)) {
if (msg.substring(z10b.cmdPrefix.length()).equalsIgnoreCase("roll")) {
Random rand = new Random();
int roll = rand.nextInt(6) + 1;
channel.sendMessage("Your roll: " + roll).queue(sentMessage -> {
@ -45,6 +45,38 @@ public class MessageListener extends ListenerAdapter {
}
});
}
} else if (msg.toLowerCase().contains("polyjet")) {
int msgID = rand.nextInt(5);
channel.sendMessage("keyword detected.").queue(sentMessage -> {
String preNotedMsg = null;
switch (msgID) {
case 0:
preNotedMsg = "shutup";
break;
case 1:
preNotedMsg = "Be quiet! we dont speak of that anymore.";
break;
case 2:
Calendar dueCal = Calendar.getInstance();
dueCal.set(2017, 8, 17, 20, 55);
Calendar current = Calendar.getInstance();
float minutes = dueCal.getTimeInMillis() - current.getTimeInMillis();
minutes /= 1000;
minutes /= 60;
preNotedMsg = "ya ya if you stop talking about *that* ill release it in:" + minutes + " minutes";
break;
case 3:
preNotedMsg = "STOP IT.";
break;
case 4:
preNotedMsg = "I dare you to speak of *it* again";
break;
}
channel.sendMessage("Prenoted message from Zer01HD: \"" + preNotedMsg + "\"").queue();
});
}
super.onMessageReceived(event);
}