Commands no longer require mentioning of users
This commit is contained in:
parent
def00258d4
commit
a21ca45a7c
@ -7,9 +7,10 @@ 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;
|
||||
import net.dv8tion.jda.core.entities.User;
|
||||
import net.dv8tion.jda.core.events.message.guild.GuildMessageReceivedEvent;
|
||||
import net.dv8tion.jda.core.exceptions.PermissionException;
|
||||
|
||||
@ -41,7 +42,8 @@ public class AddRoleCommand implements CommandExec {
|
||||
try {
|
||||
List<Role> roles = event.getMessage().getMentionedRoles();
|
||||
int users = event.getMessage().getMentionedUsers().size();
|
||||
event.getMessage().getMentionedUsers().forEach(user -> event.getGuild().getController().addRolesToMember(event.getGuild().getMember(user), roles).queue());
|
||||
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());
|
||||
} catch (PermissionException ex) {
|
||||
new MessageBuilder(event.getMember().getAsMention() + ", sorry I do not have permission for this!").setColor(event.getMember().getColor()).queue(event.getChannel());
|
||||
|
@ -7,9 +7,10 @@ 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;
|
||||
import net.dv8tion.jda.core.entities.User;
|
||||
import net.dv8tion.jda.core.events.message.guild.GuildMessageReceivedEvent;
|
||||
import net.dv8tion.jda.core.exceptions.PermissionException;
|
||||
|
||||
@ -41,7 +42,8 @@ public class RemoveRoleCommand implements CommandExec {
|
||||
try {
|
||||
List<Role> roles = event.getMessage().getMentionedRoles();
|
||||
int users = event.getMessage().getMentionedUsers().size();
|
||||
event.getMessage().getMentionedUsers().forEach(user -> event.getGuild().getController().removeRolesFromMember(event.getGuild().getMember(user), roles).queue());
|
||||
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());
|
||||
} catch (PermissionException ex) {
|
||||
new MessageBuilder(event.getMember().getAsMention() + ", sorry I do not have permission for this!").setColor(event.getMember().getColor()).queue(event.getChannel());
|
||||
|
@ -8,6 +8,7 @@ import me.savvy.rixa.guild.management.Guilds;
|
||||
import me.savvy.rixa.guild.user.UserData;
|
||||
import me.savvy.rixa.modules.levels.LevelsModule;
|
||||
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.User;
|
||||
@ -15,6 +16,7 @@ import net.dv8tion.jda.core.events.message.guild.GuildMessageReceivedEvent;
|
||||
|
||||
import java.sql.ResultSet;
|
||||
import java.sql.SQLException;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* Created by savit on 7/11/2017.
|
||||
@ -27,7 +29,7 @@ public class LevelsCommand implements CommandExec {
|
||||
channelType = ChannelType.TEXT)
|
||||
public void execute(GuildMessageReceivedEvent event) {
|
||||
RixaGuild rixaGuild = Guilds.getGuild(event.getGuild());
|
||||
if (!((LevelsModule) rixaGuild.getModule("Levels")).isEnabled()) {
|
||||
if (!rixaGuild.getModule("Levels").isEnabled()) {
|
||||
new MessageBuilder("Levels are not enabled on this server!").setColor(event.getMember().getColor()).queue(event.getChannel());
|
||||
return;
|
||||
}
|
||||
@ -37,11 +39,12 @@ public class LevelsCommand implements CommandExec {
|
||||
new MessageBuilder(event.getMember().getAsMention() + ", incorrect usage try [" + rixaGuild.getGuildSettings().getPrefix() + "rank <user>].").setColor(event.getMember().getColor()).queue(event.getChannel());
|
||||
return;
|
||||
}
|
||||
if (event.getGuild().getMember(event.getMessage().getMentionedUsers().get(0)) == null) {
|
||||
List<Member> memberList = Utils.memberSearch(event.getGuild(), event.getMessage().getContent(), false);
|
||||
if (memberList.get(0) == null) {
|
||||
new MessageBuilder(event.getMember().getAsMention() + ", couldn't find user.").setColor(event.getMember().getColor()).queue(event.getChannel());
|
||||
return;
|
||||
}
|
||||
getInfo(rixaGuild, event.getGuild().getMember(event.getMessage().getMentionedUsers().get(0))).queue(event.getChannel());
|
||||
getInfo(rixaGuild, memberList.get(0)).queue(event.getChannel());
|
||||
return;
|
||||
}
|
||||
getInfo(rixaGuild, event.getMember()).queue(event.getChannel());
|
||||
|
@ -238,6 +238,12 @@ public class MusicCommand implements CommandExec {
|
||||
if (chan == null) {
|
||||
new MessageBuilder("Sorry I was unable to find the VoiceChannel: `" + channelName + "`.").setColor(event.getMember().getColor()).queue(event.getChannel());
|
||||
} else {
|
||||
synchronized (musicManagers) {
|
||||
player.destroy();
|
||||
guild.getAudioManager().setSendingHandler(null);
|
||||
musicManagers.remove(guild.getId());
|
||||
}
|
||||
mng = getMusicManager(guild);
|
||||
guild.getAudioManager().setSendingHandler(mng.sendHandler);
|
||||
try {
|
||||
new MessageBuilder("Entering Voice Channel: " + chan.getName()).setColor(event.getMember().getColor()).queue(event.getChannel());
|
||||
@ -294,6 +300,12 @@ public class MusicCommand implements CommandExec {
|
||||
if (chan == null) {
|
||||
new MessageBuilder("Sorry I was unable to find the VoiceChannel: `" + message[2] + "`.").setColor(event.getMember().getColor()).queue(event.getChannel());
|
||||
} else {
|
||||
synchronized (musicManagers) {
|
||||
player.destroy();
|
||||
guild.getAudioManager().setSendingHandler(null);
|
||||
musicManagers.remove(guild.getId());
|
||||
}
|
||||
mng = getMusicManager(guild);
|
||||
guild.getAudioManager().setSendingHandler(mng.sendHandler);
|
||||
try {
|
||||
new MessageBuilder("Entering Voice Channel: " + chan.getName()).setColor(event.getMember().getColor()).queue(event.getChannel());
|
||||
|
@ -2,7 +2,6 @@ package me.savvy.rixa.commands.general;
|
||||
|
||||
import me.savvy.rixa.commands.handlers.Command;
|
||||
import me.savvy.rixa.commands.handlers.CommandExec;
|
||||
import me.savvy.rixa.utils.MessageBuilder;
|
||||
import me.savvy.rixa.utils.YoutubeSearch;
|
||||
import net.dv8tion.jda.core.entities.ChannelType;
|
||||
import net.dv8tion.jda.core.events.message.guild.GuildMessageReceivedEvent;
|
||||
@ -24,8 +23,9 @@ public class YoutubeCommand implements CommandExec {
|
||||
String search = getMessage(message);
|
||||
try {
|
||||
YoutubeSearch ytSearch = new YoutubeSearch(search);
|
||||
event.getChannel().sendMessage(ytSearch.getUrl(0)).queue();/*
|
||||
new MessageBuilder(ytSearch.getUrl(0))
|
||||
.setColor(event.getMember().getColor()).queue(event.getChannel());
|
||||
.setColor(event.getMember().getColor()).queue(event.getChannel());*/
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
@ -7,10 +7,10 @@ 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;
|
||||
import net.dv8tion.jda.core.entities.User;
|
||||
import net.dv8tion.jda.core.events.message.guild.GuildMessageReceivedEvent;
|
||||
import net.dv8tion.jda.core.exceptions.PermissionException;
|
||||
|
||||
@ -48,16 +48,15 @@ public class MuteCommand implements CommandExec {
|
||||
return;
|
||||
}
|
||||
try {
|
||||
for(User user: event.getMessage().getMentionedUsers()) {
|
||||
Member muted = rixaGuild.getGuild().getMember(user);
|
||||
if (rixaGuild.isUserMuted(muted.getUser())) {
|
||||
rixaGuild.getGuild().getController().removeRolesFromMember(muted, Collections.singleton(muteRole)).queue();
|
||||
rixaGuild.unmuteMember(muted.getUser());
|
||||
new MessageBuilder("Successfully unmuted `" + muted.getEffectiveName() + "`.").setColor(event.getMember().getColor()).queue(event.getChannel());
|
||||
for(Member member: Utils.memberSearch(event.getGuild(), event.getMessage().getContent(), false)) {
|
||||
if (rixaGuild.isUserMuted(member.getUser())) {
|
||||
rixaGuild.getGuild().getController().removeRolesFromMember(member, Collections.singleton(muteRole)).queue();
|
||||
rixaGuild.unmuteMember(member.getUser());
|
||||
new MessageBuilder("Successfully unmuted `" + member.getEffectiveName() + "`.").setColor(event.getMember().getColor()).queue(event.getChannel());
|
||||
} else {
|
||||
rixaGuild.getGuild().getController().addRolesToMember(muted, Collections.singleton(muteRole)).queue();
|
||||
rixaGuild.muteMember(muted.getUser());
|
||||
new MessageBuilder("Successfully muted `" + muted.getEffectiveName() + "`.").setColor(event.getMember().getColor()).queue(event.getChannel());
|
||||
rixaGuild.getGuild().getController().addRolesToMember(member, Collections.singleton(muteRole)).queue();
|
||||
rixaGuild.muteMember(member.getUser());
|
||||
new MessageBuilder("Successfully muted `" + member.getEffectiveName() + "`.").setColor(event.getMember().getColor()).queue(event.getChannel());
|
||||
}
|
||||
}
|
||||
} catch (PermissionException ex) {
|
||||
|
@ -27,7 +27,7 @@ public class PurgeMessagesCommand implements CommandExec {
|
||||
@Override
|
||||
@Command(mainCommand = "purge",
|
||||
aliases = { "pmessages", "purgemessages", "purgeuser" },
|
||||
description = "Remove a users messages!",
|
||||
description = "Remove a users messages within selected amount!",
|
||||
channelType = ChannelType.TEXT,
|
||||
type = CommandType.MOD,
|
||||
usage = "%ppurge")
|
||||
@ -53,8 +53,9 @@ public class PurgeMessagesCommand implements CommandExec {
|
||||
break;
|
||||
}
|
||||
}
|
||||
Member memberToDel = event.getGuild().getMember(event.getMessage().getMentionedUsers().get(0));
|
||||
deleteMessage(event.getChannel(), event.getMember(), memberToDel, amount);
|
||||
List<Member> members = Utils.memberSearch(event.getGuild(), event.getMessage().getContent(), true);
|
||||
int finalAmount = amount;
|
||||
members.forEach(memberToDel -> deleteMessage(event.getChannel(), event.getMember(), memberToDel, finalAmount));
|
||||
}
|
||||
|
||||
private void deleteMessage(TextChannel channel, Member user, Member userToDel, int amount) {
|
||||
|
@ -7,10 +7,10 @@ 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;
|
||||
import net.dv8tion.jda.core.entities.User;
|
||||
import net.dv8tion.jda.core.events.message.guild.GuildMessageReceivedEvent;
|
||||
import net.dv8tion.jda.core.exceptions.PermissionException;
|
||||
|
||||
@ -43,17 +43,16 @@ public class UnmuteCommand implements CommandExec {
|
||||
return;
|
||||
}
|
||||
try {
|
||||
for(User user: event.getMessage().getMentionedUsers()) {
|
||||
Member muted = rixaGuild.getGuild().getMember(user);
|
||||
if (rixaGuild.isUserMuted(muted.getUser())) {
|
||||
for(Member member: Utils.memberSearch(event.getGuild(), event.getMessage().getContent(), false)) {
|
||||
if (rixaGuild.isUserMuted(member.getUser())) {
|
||||
Role muteRole = event.getGuild().getRoleById(rixaGuild.getGuildSettings().getMuteRole());
|
||||
if(muteRole != null) {
|
||||
rixaGuild.getGuild().getController().removeRolesFromMember(muted, Collections.singleton(muteRole)).queue();
|
||||
rixaGuild.getGuild().getController().removeRolesFromMember(member, Collections.singleton(muteRole)).queue();
|
||||
}
|
||||
rixaGuild.unmuteMember(muted.getUser());
|
||||
new MessageBuilder("Successfully unmuted `" + muted.getEffectiveName() + "`.").setColor(event.getMember().getColor()).queue(event.getChannel());
|
||||
rixaGuild.unmuteMember(member.getUser());
|
||||
new MessageBuilder("Successfully unmuted `" + member.getEffectiveName() + "`.").setColor(event.getMember().getColor()).queue(event.getChannel());
|
||||
} else {
|
||||
new MessageBuilder( muted.getEffectiveName() + ", is not muted.").setColor(event.getMember().getColor()).queue(event.getChannel());
|
||||
new MessageBuilder( member.getEffectiveName() + ", is not muted.").setColor(event.getMember().getColor()).queue(event.getChannel());
|
||||
}
|
||||
}
|
||||
} catch (PermissionException ex) {
|
||||
|
@ -27,7 +27,10 @@ public class Utils {
|
||||
for (Member member : guild.getMembers()) {
|
||||
if ((member.getUser().getName().toLowerCase() + "#" + member.getUser().getDiscriminator()).contains(finalString)
|
||||
|| (member.getEffectiveName().toLowerCase().contains(finalString))
|
||||
|| finalString.contains(member.getUser().getId())) {
|
||||
|| finalString.contains(member.getUser().getId())
|
||||
|| finalString.contains(member.getUser().getName().toLowerCase() + "#" + member.getUser().getDiscriminator())
|
||||
|| finalString.contains(member.getEffectiveName())
|
||||
) {
|
||||
|
||||
if (!bots && member.getUser().isBot()) continue;
|
||||
members.add(member);
|
||||
|
Loading…
Reference in New Issue
Block a user