Ignore case for role command
This commit is contained in:
parent
a9d4d5e9e1
commit
8e2538e553
1 changed files with 11 additions and 5 deletions
|
@ -7,6 +7,7 @@ import buttondevteam.discordplugin.commands.ICommand2DC;
|
||||||
import buttondevteam.lib.TBMCCoreAPI;
|
import buttondevteam.lib.TBMCCoreAPI;
|
||||||
import buttondevteam.lib.chat.Command2;
|
import buttondevteam.lib.chat.Command2;
|
||||||
import buttondevteam.lib.chat.CommandClass;
|
import buttondevteam.lib.chat.CommandClass;
|
||||||
|
import lombok.val;
|
||||||
import sx.blah.discord.handle.obj.IRole;
|
import sx.blah.discord.handle.obj.IRole;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
@ -63,12 +64,17 @@ public class RoleCommand extends ICommand2DC {
|
||||||
}
|
}
|
||||||
|
|
||||||
private IRole checkAndGetRole(Command2DCSender sender, String rolename) {
|
private IRole checkAndGetRole(Command2DCSender sender, String rolename) {
|
||||||
if (!grm.GameRoles.contains(rolename)) {
|
String rname = rolename;
|
||||||
|
if (!grm.GameRoles.contains(rolename)) { //If not found as-is, correct case
|
||||||
|
val orn = grm.GameRoles.stream().filter(r -> r.equalsIgnoreCase(rolename)).findAny();
|
||||||
|
if (!orn.isPresent()) {
|
||||||
sender.sendMessage("that role cannot be found.");
|
sender.sendMessage("that role cannot be found.");
|
||||||
list(sender);
|
list(sender);
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
final List<IRole> roles = DiscordPlugin.mainServer.getRolesByName(rolename);
|
rname = orn.get();
|
||||||
|
}
|
||||||
|
final List<IRole> roles = DiscordPlugin.mainServer.getRolesByName(rname);
|
||||||
if (roles.size() == 0) {
|
if (roles.size() == 0) {
|
||||||
sender.sendMessage("the specified role cannot be found on Discord! Removing from the list.");
|
sender.sendMessage("the specified role cannot be found on Discord! Removing from the list.");
|
||||||
grm.GameRoles.remove(rolename);
|
grm.GameRoles.remove(rolename);
|
||||||
|
|
Loading…
Reference in a new issue