Commands no longer require mentioning of roles
This commit is contained in:
parent
a21ca45a7c
commit
6f1ddc19a9
@ -33,18 +33,18 @@ public class AddRoleCommand implements CommandExec {
|
||||
return;
|
||||
}
|
||||
String[] messages = event.getMessage().getContent().split(" ");
|
||||
List<Member> memberList = Utils.memberSearch(event.getGuild(), event.getMessage().getContent(), true);
|
||||
List<Role> roleList = Utils.roleSearch(event.getGuild(), event.getMessage().getContent());
|
||||
if (messages.length >= 3) {
|
||||
if(event.getMessage().getMentionedRoles().size() < 1 ||
|
||||
event.getMessage().getMentionedUsers().size() < 1) {
|
||||
if(memberList.size() < 1 ||
|
||||
roleList.size() < 1) {
|
||||
new MessageBuilder(event.getMember().getAsMention() + ", incorrect usage try [" + messages[0] + " <role> <user>].").setColor(event.getMember().getColor()).queue(event.getChannel());
|
||||
return;
|
||||
}
|
||||
try {
|
||||
List<Role> roles = event.getMessage().getMentionedRoles();
|
||||
int users = event.getMessage().getMentionedUsers().size();
|
||||
List<Member> memberList = Utils.memberSearch(event.getGuild(), event.getMessage().getContent(), true);
|
||||
memberList.forEach(user -> event.getGuild().getController().addRolesToMember(user, roles).queue());
|
||||
new MessageBuilder("Successfully given " + users + " `" + roles.size() + "` role(s)").setColor(event.getMember().getColor()).queue(event.getChannel());
|
||||
memberList.forEach(user -> event.getGuild().getController().addRolesToMember(user, roleList).queue());
|
||||
new MessageBuilder("Successfully given " + users + " `" + roleList.size() + "` role(s)").setColor(event.getMember().getColor()).queue(event.getChannel());
|
||||
} catch (PermissionException ex) {
|
||||
new MessageBuilder(event.getMember().getAsMention() + ", sorry I do not have permission for this!").setColor(event.getMember().getColor()).queue(event.getChannel());
|
||||
}
|
||||
|
@ -6,6 +6,7 @@ import me.savvy.rixa.commands.handlers.RixaPermission;
|
||||
import me.savvy.rixa.guild.RixaGuild;
|
||||
import me.savvy.rixa.guild.management.Guilds;
|
||||
import me.savvy.rixa.utils.MessageBuilder;
|
||||
import me.savvy.rixa.utils.Utils;
|
||||
import net.dv8tion.jda.core.entities.ChannelType;
|
||||
import net.dv8tion.jda.core.entities.Member;
|
||||
import net.dv8tion.jda.core.entities.Role;
|
||||
@ -31,12 +32,13 @@ public class BatchMoveCommand implements CommandExec {
|
||||
new MessageBuilder(event.getMember().getAsMention() + ", you do not have permission for this command.").setColor(event.getMember().getColor()).queue(event.getChannel());
|
||||
return;
|
||||
}
|
||||
if(event.getMessage().getMentionedRoles().size() < 2) {
|
||||
List<Role> roleList = Utils.roleSearch(event.getGuild(), event.getMessage().getContent());
|
||||
if(roleList.size() < 2) {
|
||||
new MessageBuilder("You need to include two roles!").setColor(event.getMember().getColor()).queue(event.getChannel());
|
||||
return;
|
||||
}
|
||||
Role old_role = event.getMessage().getMentionedRoles().get(0);
|
||||
Role new_role = event.getMessage().getMentionedRoles().get(1);
|
||||
Role old_role = roleList.get(0);
|
||||
Role new_role = roleList.get(1);
|
||||
List<Member> userWithRole = event.getGuild().getMembersWithRoles(old_role);
|
||||
if(userWithRole.size() == 0) {
|
||||
new MessageBuilder("There are no users with the role " + old_role.getAsMention()).setColor(old_role.getColor()).queue(event.getChannel());
|
||||
|
@ -16,7 +16,7 @@ public class InviteCommand implements CommandExec {
|
||||
|
||||
@Command(
|
||||
description = "Receive an invite from a server",
|
||||
type = CommandType.USER,
|
||||
type = CommandType.BOT_OWNER,
|
||||
channelType = ChannelType.TEXT,
|
||||
usage = "%pinvite", mainCommand = "invite")
|
||||
public void execute(GuildMessageReceivedEvent event) {
|
||||
|
@ -33,18 +33,18 @@ public class RemoveRoleCommand implements CommandExec {
|
||||
return;
|
||||
}
|
||||
String[] messages = event.getMessage().getContent().split(" ");
|
||||
List<Member> memberList = Utils.memberSearch(event.getGuild(), event.getMessage().getContent(), true);
|
||||
List<Role> roleList = Utils.roleSearch(event.getGuild(), event.getMessage().getContent());
|
||||
if (messages.length >= 3) {
|
||||
if(event.getMessage().getMentionedRoles().size() < 1 ||
|
||||
event.getMessage().getMentionedUsers().size() < 1) {
|
||||
if(roleList.size() < 1 ||
|
||||
memberList.size() < 1) {
|
||||
new MessageBuilder(event.getMember().getAsMention() + ", incorrect usage try [" + messages[0] + " <role> <user>].").setColor(event.getMember().getColor()).queue(event.getChannel());
|
||||
return;
|
||||
}
|
||||
try {
|
||||
List<Role> roles = event.getMessage().getMentionedRoles();
|
||||
int users = event.getMessage().getMentionedUsers().size();
|
||||
List<Member> memberList = Utils.memberSearch(event.getGuild(), event.getMessage().getContent(), true);
|
||||
memberList.forEach(user -> event.getGuild().getController().removeRolesFromMember(user, roles).queue());
|
||||
new MessageBuilder("Successfully removed `" + roles.size() + "` role(s) from " + users + " user(s)!").setColor(event.getMember().getColor()).queue(event.getChannel());
|
||||
memberList.forEach(user -> event.getGuild().getController().removeRolesFromMember(user, roleList).queue());
|
||||
new MessageBuilder("Successfully removed `" + roleList.size() + "` role(s) from " + users + " user(s)!").setColor(event.getMember().getColor()).queue(event.getChannel());
|
||||
} catch (PermissionException ex) {
|
||||
new MessageBuilder(event.getMember().getAsMention() + ", sorry I do not have permission for this!").setColor(event.getMember().getColor()).queue(event.getChannel());
|
||||
}
|
||||
|
@ -29,7 +29,7 @@ public class Utils {
|
||||
|| (member.getEffectiveName().toLowerCase().contains(finalString))
|
||||
|| finalString.contains(member.getUser().getId())
|
||||
|| finalString.contains(member.getUser().getName().toLowerCase() + "#" + member.getUser().getDiscriminator())
|
||||
|| finalString.contains(member.getEffectiveName())
|
||||
|| finalString.contains(member.getEffectiveName().toLowerCase())
|
||||
) {
|
||||
|
||||
if (!bots && member.getUser().isBot()) continue;
|
||||
@ -44,7 +44,9 @@ public class Utils {
|
||||
List<Role> roles = new ArrayList<>();
|
||||
guild.getRoles().forEach(role -> {
|
||||
if (role.getName().toLowerCase().contains(string.toLowerCase())
|
||||
|| string.contains(role.getId()))
|
||||
|| string.contains(role.getId())
|
||||
|| string.toLowerCase().contains(role.getName().toLowerCase())
|
||||
)
|
||||
roles.add(role);
|
||||
});
|
||||
return roles;
|
||||
|
Loading…
Reference in New Issue
Block a user