usersWithRole = sendingSuccess

Is leaderboard complete??
This commit is contained in:
Venal 2018-01-25 23:25:40 -05:00
parent 9566f38da7
commit f0b36ba466

View File

@ -31,13 +31,13 @@ public class PMCommand extends Command {
return; return;
} }
msg = msg.replaceFirst(role.getAsMention(), "").replaceFirst("@" + role.getName(),""); msg = msg.replaceFirst(role.getAsMention(), "").replaceFirst("@" + role.getName(),"");
int usersWithRole = 0; int sendingSuccess = 0;
int sendingFailed = 0; int sendingFailed = 0;
String finalMsg = msg; String finalMsg = msg;
for (Member memberWithRole : guild.getMembersWithRoles(role)) { for (Member memberWithRole : guild.getMembersWithRoles(role)) {
try { try {
memberWithRole.getUser().openPrivateChannel().queue(privateChannel -> privateChannel.sendMessage(finalMsg).queue()); memberWithRole.getUser().openPrivateChannel().queue(privateChannel -> privateChannel.sendMessage(finalMsg).queue());
usersWithRole++; sendingSuccess++;
} catch (ErrorResponseException ex) { } catch (ErrorResponseException ex) {
if (ex.getErrorResponse() == ErrorResponse.CANNOT_SEND_TO_USER) if (ex.getErrorResponse() == ErrorResponse.CANNOT_SEND_TO_USER)
sendingFailed++; sendingFailed++;
@ -46,6 +46,6 @@ public class PMCommand extends Command {
MessageFactory.create(msg) MessageFactory.create(msg)
.setAuthor("Private Message: " + role.getName(), guild.getIconUrl()) .setAuthor("Private Message: " + role.getName(), guild.getIconUrl())
.setTimestamp() .setTimestamp()
.footer("Successful Deliveries: " + usersWithRole + " | Failed Deliveries: " + sendingFailed, guild.getIconUrl()).queue(channel); .footer("Successful Deliveries: " + sendingSuccess + " | Failed Deliveries: " + sendingFailed, guild.getIconUrl()).queue(channel);
} }
} }