diff --git a/LICENSE b/LICENSE
index 8dada3ed..d2540424 100644
--- a/LICENSE
+++ b/LICENSE
@@ -186,7 +186,7 @@
same "printed page" as the copyright notice for easier
identification within third-party archives.
- Copyright {yyyy} {name of copyright owner}
+ Copyright 2018 John Grosh
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
diff --git a/pom.xml b/pom.xml
index 417de275..ecd5365d 100644
--- a/pom.xml
+++ b/pom.xml
@@ -3,7 +3,7 @@
4.0.0
com.jagrosh
GiveawayBot
- 2.1
+ 2.2
jar
@@ -30,7 +30,7 @@
net.dv8tion
JDA
- 3.6.0_373
+ 3.7.0_382
compile
diff --git a/src/main/java/com/jagrosh/giveawaybot/Bot.java b/src/main/java/com/jagrosh/giveawaybot/Bot.java
index 6b5917e3..d229386f 100644
--- a/src/main/java/com/jagrosh/giveawaybot/Bot.java
+++ b/src/main/java/com/jagrosh/giveawaybot/Bot.java
@@ -45,8 +45,6 @@
import net.dv8tion.jda.core.events.guild.member.GuildMemberRoleRemoveEvent;
import net.dv8tion.jda.core.events.role.update.RoleUpdateColorEvent;
import net.dv8tion.jda.core.hooks.ListenerAdapter;
-import net.dv8tion.jda.core.utils.SessionController;
-import net.dv8tion.jda.core.utils.SessionControllerAdapter;
import net.dv8tion.jda.webhook.WebhookClient;
import net.dv8tion.jda.webhook.WebhookClientBuilder;
import org.slf4j.Logger;
@@ -89,6 +87,11 @@ public ScheduledExecutorService getThreadpool()
return threadpool;
}
+ public WebhookClient getWebhook()
+ {
+ return webhook;
+ }
+
public Database getDatabase()
{
return database;
@@ -232,6 +235,8 @@ public static void main(int shardTotal, int shardSetId, int shardSetSize) throws
new ShutdownCommand(bot)
).build();
+ bot.getWebhook().send("\uD83C\uDF89 Starting shards `"+(shardSetId*shardSetSize + 1) + " - " + ((shardSetId+1)*shardSetSize) + "` of `"+shardTotal+"`...");
+
// start logging in
bot.setShardManager(new DefaultShardManagerBuilder()
.setShardsTotal(shardTotal)
diff --git a/src/main/java/com/jagrosh/giveawaybot/Constants.java b/src/main/java/com/jagrosh/giveawaybot/Constants.java
index df6f0216..dbca2020 100644
--- a/src/main/java/com/jagrosh/giveawaybot/Constants.java
+++ b/src/main/java/com/jagrosh/giveawaybot/Constants.java
@@ -32,8 +32,8 @@ public class Constants {
public static final OffsetDateTime STARTUP = OffsetDateTime.now();
public static final int PRIZE_MAX = 250;
public static final String TADA = "\uD83C\uDF89";
- public static final String YAY = "<:yay:294906617378504704>";
- public static final String REACTION = "yay:294906617378504704";
+ public static final String YAY = "<:yay:440620097543864320>";
+ public static final String REACTION = "yay:440620097543864320";
public static final Color BLURPLE = Color.decode("#7289DA");
public static final String INVITE = "https://giveawaybot.party/invite";
public static final int MIN_TIME = 10;
diff --git a/src/main/java/com/jagrosh/giveawaybot/commands/CreateCommand.java b/src/main/java/com/jagrosh/giveawaybot/commands/CreateCommand.java
index ed9457cf..7333d676 100644
--- a/src/main/java/com/jagrosh/giveawaybot/commands/CreateCommand.java
+++ b/src/main/java/com/jagrosh/giveawaybot/commands/CreateCommand.java
@@ -37,7 +37,7 @@ public class CreateCommand extends Command {
private final static String CANCEL = "\n\n`Giveaway creation has been cancelled.`";
private final static String CHANNEL = "\n\n`Please type the name of a channel in this server.`";
- private final static String TIME = "\n\n`Please enter the duration of the giveaway in seconds.`\n`Alternatively, enter a duration in minutes and include an M at the end.`";
+ private final static String TIME = "\n\n`Please enter the duration of the giveaway in seconds.`\n`Alternatively, enter a duration in minutes and include an M at the end, or days and include a D.`";
private final static String WINNERS = "\n\n`Please enter a number of winners between 1 and 15.`";
private final static String PRIZE = "\n\n`Please enter the giveaway prize. This will also begin the giveaway.`";
private final Bot bot;
diff --git a/src/main/java/com/jagrosh/giveawaybot/commands/EndCommand.java b/src/main/java/com/jagrosh/giveawaybot/commands/EndCommand.java
index 009e6b5b..b21c9006 100644
--- a/src/main/java/com/jagrosh/giveawaybot/commands/EndCommand.java
+++ b/src/main/java/com/jagrosh/giveawaybot/commands/EndCommand.java
@@ -68,7 +68,7 @@ protected void execute(CommandEvent event)
event.replyWarning("I couldn't find any recent giveaways in this channel.");
else
{
- Giveaway.getWinners(m, wins -> event.replySuccess("The new winner is "+wins.get(0).getAsMention()+"! Congratulations!"),
+ Giveaway.getWinner(m, wins -> event.replySuccess("The new winner is "+wins.getAsMention()+"! Congratulations!"),
() -> event.replyWarning("I couldn't determine a winner for that giveaway."), bot.getThreadpool());
}
}, v -> event.replyError("I failed to retrieve message history"));
@@ -79,7 +79,7 @@ else if(event.getArgs().matches("\\d{17,20}"))
if(giveaway==null)
{
event.getChannel().getMessageById(event.getArgs()).queue(m -> {
- Giveaway.getWinners(m, wins -> event.replySuccess("The new winner is "+wins.get(0).getAsMention()+"! Congratulations!"),
+ Giveaway.getWinner(m, wins -> event.replySuccess("The new winner is "+wins.getAsMention()+"! Congratulations!"),
() -> event.replyWarning("I couldn't determine a winner for that giveaway."), bot.getThreadpool());
}, v -> event.replyError("I failed to retrieve that message."));
}
diff --git a/src/main/java/com/jagrosh/giveawaybot/commands/RerollCommand.java b/src/main/java/com/jagrosh/giveawaybot/commands/RerollCommand.java
index e2bdcece..d9ba2727 100644
--- a/src/main/java/com/jagrosh/giveawaybot/commands/RerollCommand.java
+++ b/src/main/java/com/jagrosh/giveawaybot/commands/RerollCommand.java
@@ -61,7 +61,7 @@ else if(event.getArgs().matches("\\d{17,20}")) {
}
private void determineWinner(Message m, CommandEvent event) {
- Giveaway.getWinners(m, wins -> event.replySuccess("The new winner is "+wins.get(0).getAsMention()+"! Congratulations!"),
+ Giveaway.getWinner(m, wins -> event.replySuccess("The new winner is "+wins.getAsMention()+"! Congratulations!"),
() -> event.replyWarning("I couldn't determine a winner for that giveaway."), bot.getThreadpool());
}
}
diff --git a/src/main/java/com/jagrosh/giveawaybot/entities/Giveaway.java b/src/main/java/com/jagrosh/giveawaybot/entities/Giveaway.java
index 45e39c95..efed71c6 100644
--- a/src/main/java/com/jagrosh/giveawaybot/entities/Giveaway.java
+++ b/src/main/java/com/jagrosh/giveawaybot/entities/Giveaway.java
@@ -128,7 +128,7 @@ public void end(RestJDA restJDA)
eb.setAuthor(prize, null, null);
try {
List ids = restJDA.getReactionUsers(Long.toString(channelId), Long.toString(messageId), MiscUtil.encodeUTF8(Constants.TADA))
- .cache(true).stream().collect(Collectors.toList());
+ .cache(true).stream().distinct().collect(Collectors.toList());
List wins = selectWinners(ids, winners);
String toSend;
if(wins.isEmpty())
@@ -172,32 +172,17 @@ public static List selectWinners(List list, int winners)
return winlist;
}
- public static void getWinners(Message message, Consumer> success, Runnable failure, ExecutorService threadpool)
+ public static void getWinner(Message message, Consumer success, Runnable failure, ExecutorService threadpool)
{
threadpool.submit(() -> {
try {
MessageReaction mr = message.getReactions().stream().filter(r -> r.getReactionEmote().getName().equals(Constants.TADA)).findAny().orElse(null);
List users = new LinkedList<>();
- mr.getUsers().stream().forEach(u -> users.add(u));
- users.remove(mr.getJDA().getSelfUser());
+ mr.getUsers().stream().distinct().filter(u -> !u.isBot()).forEach(u -> users.add(u));
if(users.isEmpty())
failure.run();
else
- {
- int wincount;
- String[] split = message.getEmbeds().get(0).getFooter().getText().split(" ");
- try {
- wincount = Integer.parseInt(split[0]);
- }catch(NumberFormatException e){
- wincount = 1;
- }
- List wins = new LinkedList<>();
- for(int i=0; i