Basic changes
This commit is contained in:
parent
7fdac99892
commit
fb2fc4647c
@ -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);
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -11,16 +11,7 @@ import java.util.Optional;
|
|||||||
import java.util.stream.Collectors;
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
public class DiscordUtils {
|
public class DiscordUtils {
|
||||||
|
|
||||||
public static boolean isInt(String s) {
|
|
||||||
try {
|
|
||||||
Integer.parseInt(s);
|
|
||||||
return true;
|
|
||||||
} catch (NumberFormatException ex) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public static List<Member> memberSearch(Guild guild, String string, boolean bots) {
|
public static List<Member> memberSearch(Guild guild, String string, boolean bots) {
|
||||||
List<Member> members = new ArrayList<>();
|
List<Member> members = new ArrayList<>();
|
||||||
String finalString = string.toLowerCase();
|
String finalString = string.toLowerCase();
|
||||||
|
@ -2,6 +2,15 @@ package io.rixa.bot.utils;
|
|||||||
|
|
||||||
public class Utils {
|
public class Utils {
|
||||||
|
|
||||||
|
public static boolean isInt(String s) {
|
||||||
|
try {
|
||||||
|
Integer.parseInt(s);
|
||||||
|
return true;
|
||||||
|
} catch (NumberFormatException ex) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public static boolean isInteger(String s) {
|
public static boolean isInteger(String s) {
|
||||||
return isInteger(s,10);
|
return isInteger(s,10);
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user