Implemented COmmandType and ReactionManager
This commit is contained in:
@@ -1,42 +1,59 @@
|
||||
package io.rixa.bot.commands;
|
||||
|
||||
import io.rixa.bot.commands.handler.CommandType;
|
||||
import io.rixa.bot.commands.perms.RixaPermission;
|
||||
import java.io.IOException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
import net.dv8tion.jda.core.entities.Guild;
|
||||
import net.dv8tion.jda.core.entities.Member;
|
||||
import net.dv8tion.jda.core.entities.TextChannel;
|
||||
import net.dv8tion.jda.core.events.message.guild.GuildMessageReceivedEvent;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
public abstract class Command {
|
||||
|
||||
@Getter @Setter private String command, description;
|
||||
@Getter @Setter private RixaPermission permission;
|
||||
@Getter @Setter private List<String> aliases;
|
||||
public Command(String command) {
|
||||
this(command, RixaPermission.NONE, "Undefined", Collections.emptyList());
|
||||
}
|
||||
@Getter
|
||||
@Setter
|
||||
private String command, description;
|
||||
@Getter
|
||||
@Setter
|
||||
private RixaPermission permission;
|
||||
@Getter
|
||||
@Setter
|
||||
private List<String> aliases;
|
||||
@Getter
|
||||
@Setter
|
||||
private CommandType commandType;
|
||||
|
||||
public Command(String command, RixaPermission rixaPermission) {
|
||||
this(command, rixaPermission, "Undefined", Collections.emptyList());
|
||||
}
|
||||
public Command(String command) {
|
||||
this(command, RixaPermission.NONE, "Undefined", CommandType.USER, Collections.emptyList());
|
||||
}
|
||||
|
||||
public Command(String command, RixaPermission rixaPermission, String description) {
|
||||
this(command, rixaPermission, description, Collections.emptyList());
|
||||
}
|
||||
public Command(String command, RixaPermission rixaPermission) {
|
||||
this(command, rixaPermission, "Undefined", CommandType.USER, Collections.emptyList());
|
||||
}
|
||||
|
||||
public Command(String command, RixaPermission rixaPermission, String description, List<String> aliases) {
|
||||
setCommand(command);
|
||||
setPermission(rixaPermission);
|
||||
setDescription(description);
|
||||
setAliases(aliases);
|
||||
}
|
||||
public Command(String command, RixaPermission rixaPermission, String description) {
|
||||
this(command, rixaPermission, description, CommandType.USER, Collections.emptyList());
|
||||
}
|
||||
|
||||
// public abstract void execute(GuildMessageReceivedEvent event);
|
||||
public Command(String command, RixaPermission rixaPermission, String description, CommandType commandType) {
|
||||
this(command, rixaPermission, description, commandType, Collections.emptyList());
|
||||
}
|
||||
|
||||
public abstract void execute(String commandLabel, Guild guild, Member member, TextChannel channel, String[] args) throws IOException;
|
||||
public Command(String command, RixaPermission rixaPermission, String description,
|
||||
CommandType commandType, List<String> aliases) {
|
||||
setCommand(command);
|
||||
setPermission(rixaPermission);
|
||||
setDescription(description);
|
||||
setAliases(aliases);
|
||||
this.commandType = commandType;
|
||||
}
|
||||
|
||||
// public abstract void execute(GuildMessageReceivedEvent event);
|
||||
|
||||
public abstract void execute(String commandLabel, Guild guild, Member member, TextChannel channel,
|
||||
String[] args) throws IOException;
|
||||
}
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
package io.rixa.bot.commands.cmds.admin;
|
||||
|
||||
import io.rixa.bot.commands.Command;
|
||||
import io.rixa.bot.commands.handler.CommandType;
|
||||
import io.rixa.bot.commands.perms.RixaPermission;
|
||||
import io.rixa.bot.guild.RixaGuild;
|
||||
import io.rixa.bot.guild.manager.GuildManager;
|
||||
@@ -22,8 +23,8 @@ public class ConfigCommand extends Command {
|
||||
|
||||
private Pagination pagination;
|
||||
|
||||
public ConfigCommand(String command, RixaPermission rixaPermission, String description) {
|
||||
super(command, rixaPermission, description);
|
||||
public ConfigCommand(String command, RixaPermission rixaPermission, String description, CommandType commandType) {
|
||||
super(command, rixaPermission, description, commandType);
|
||||
|
||||
pagination = new Pagination(Arrays.asList(
|
||||
"%pconfig set greetings ; Set channel where greeting messages are announced!",
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
package io.rixa.bot.commands.cmds.admin;
|
||||
|
||||
import io.rixa.bot.commands.Command;
|
||||
import io.rixa.bot.commands.handler.CommandType;
|
||||
import io.rixa.bot.commands.perms.RixaPermission;
|
||||
import io.rixa.bot.utils.DiscordUtils;
|
||||
import io.rixa.bot.utils.MessageFactory;
|
||||
@@ -14,10 +15,8 @@ import net.dv8tion.jda.core.requests.ErrorResponse;
|
||||
|
||||
public class PMCommand extends Command {
|
||||
|
||||
@Getter private RixaPermission rixaPermission;
|
||||
public PMCommand(String command, RixaPermission rixaPermission, String description) {
|
||||
super(command, rixaPermission, description);
|
||||
this.rixaPermission = rixaPermission;
|
||||
public PMCommand(String command, RixaPermission rixaPermission, String description, CommandType commandType) {
|
||||
super(command, rixaPermission, description, commandType);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
package io.rixa.bot.commands.cmds.general;
|
||||
|
||||
import io.rixa.bot.commands.Command;
|
||||
import io.rixa.bot.commands.handler.CommandType;
|
||||
import io.rixa.bot.commands.perms.RixaPermission;
|
||||
import io.rixa.bot.utils.MessageFactory;
|
||||
import io.rixa.bot.utils.WebUtil;
|
||||
@@ -14,8 +15,8 @@ import java.io.IOException;
|
||||
|
||||
public class AdviceCommand extends Command {
|
||||
|
||||
public AdviceCommand(String command, RixaPermission rixaPermission, String description) {
|
||||
super(command, rixaPermission, description);
|
||||
public AdviceCommand(String command, RixaPermission rixaPermission, String description, CommandType commandType) {
|
||||
super(command, rixaPermission, description, commandType);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
package io.rixa.bot.commands.cmds.general;
|
||||
|
||||
import io.rixa.bot.commands.Command;
|
||||
import io.rixa.bot.commands.handler.CommandType;
|
||||
import io.rixa.bot.commands.perms.RixaPermission;
|
||||
import io.rixa.bot.guild.RixaGuild;
|
||||
import io.rixa.bot.guild.manager.GuildManager;
|
||||
@@ -16,8 +17,8 @@ public class FeaturesCommand extends Command {
|
||||
"Role Management", "Fun Commands", "Custom Commands", "Games", "& more."
|
||||
};
|
||||
|
||||
public FeaturesCommand(String command, RixaPermission rixaPermission, String description) {
|
||||
super(command, rixaPermission, description);
|
||||
public FeaturesCommand(String command, RixaPermission rixaPermission, String description, CommandType commandType) {
|
||||
super(command, rixaPermission, description, commandType);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
package io.rixa.bot.commands.cmds.general;
|
||||
|
||||
import io.rixa.bot.commands.Command;
|
||||
import io.rixa.bot.commands.handler.CommandType;
|
||||
import io.rixa.bot.commands.perms.RixaPermission;
|
||||
import io.rixa.bot.utils.MessageFactory;
|
||||
import net.dv8tion.jda.core.EmbedBuilder;
|
||||
@@ -14,8 +15,8 @@ import net.dv8tion.jda.core.exceptions.PermissionException;
|
||||
|
||||
public class HelpCommand extends Command {
|
||||
|
||||
public HelpCommand(String command, RixaPermission rixaPermission, String description) {
|
||||
super(command, rixaPermission, description);
|
||||
public HelpCommand(String command, RixaPermission rixaPermission, String description, CommandType commandType) {
|
||||
super(command, rixaPermission, description, commandType);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -2,6 +2,7 @@ package io.rixa.bot.commands.cmds.general;
|
||||
|
||||
import io.rixa.bot.Rixa;
|
||||
import io.rixa.bot.commands.Command;
|
||||
import io.rixa.bot.commands.handler.CommandType;
|
||||
import io.rixa.bot.commands.perms.RixaPermission;
|
||||
import io.rixa.bot.utils.DiscordUtils;
|
||||
import io.rixa.bot.utils.MessageFactory;
|
||||
@@ -20,8 +21,8 @@ import java.util.concurrent.TimeUnit;
|
||||
|
||||
public class InfoCommand extends Command {
|
||||
|
||||
public InfoCommand(String command, RixaPermission rixaPermission, String description) {
|
||||
super(command, rixaPermission, description);
|
||||
public InfoCommand(String command, RixaPermission rixaPermission, String description, CommandType commandType) {
|
||||
super(command, rixaPermission, description, commandType);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
package io.rixa.bot.commands.cmds.general;
|
||||
|
||||
import io.rixa.bot.commands.Command;
|
||||
import io.rixa.bot.commands.handler.CommandType;
|
||||
import io.rixa.bot.commands.perms.RixaPermission;
|
||||
import io.rixa.bot.guild.RixaGuild;
|
||||
import io.rixa.bot.guild.manager.GuildManager;
|
||||
@@ -20,8 +21,8 @@ import java.util.List;
|
||||
|
||||
public class LeaderboardsCommand extends Command {
|
||||
|
||||
public LeaderboardsCommand(String command, RixaPermission rixaPermission, String description) {
|
||||
super(command, rixaPermission, description);
|
||||
public LeaderboardsCommand(String command, RixaPermission rixaPermission, String description, CommandType commandType {
|
||||
super(command, rixaPermission, description, commandType);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
package io.rixa.bot.commands.cmds.general;
|
||||
|
||||
import io.rixa.bot.commands.Command;
|
||||
import io.rixa.bot.commands.handler.CommandType;
|
||||
import io.rixa.bot.commands.perms.RixaPermission;
|
||||
import io.rixa.bot.utils.MessageFactory;
|
||||
import io.rixa.bot.utils.WebUtil;
|
||||
@@ -16,8 +17,8 @@ import java.util.List;
|
||||
|
||||
public class MinecraftCommand extends Command {
|
||||
|
||||
public MinecraftCommand(String command, RixaPermission rixaPermission, String description, List<String>aliases) {
|
||||
super(command, rixaPermission, description, aliases);
|
||||
public MinecraftCommand(String command, RixaPermission rixaPermission, String description, CommandType commandType, List<String>aliases) {
|
||||
super(command, rixaPermission, description, commandType, aliases);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
package io.rixa.bot.commands.cmds.general;
|
||||
|
||||
import io.rixa.bot.commands.Command;
|
||||
import io.rixa.bot.commands.handler.CommandType;
|
||||
import io.rixa.bot.commands.perms.RixaPermission;
|
||||
import io.rixa.bot.guild.RixaGuild;
|
||||
import io.rixa.bot.guild.manager.GuildManager;
|
||||
@@ -15,8 +16,8 @@ import java.util.List;
|
||||
|
||||
public class ModulesCommand extends Command {
|
||||
|
||||
public ModulesCommand(String command, RixaPermission rixaPermission, String description) {
|
||||
super(command, rixaPermission, description);
|
||||
public ModulesCommand(String command, RixaPermission rixaPermission, String description, CommandType commandType) {
|
||||
super(command, rixaPermission, description, commandType);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -17,6 +17,7 @@ import com.sedmelluq.discord.lavaplayer.track.AudioPlaylist;
|
||||
import com.sedmelluq.discord.lavaplayer.track.AudioTrack;
|
||||
import io.rixa.bot.apis.YoutubeSearch;
|
||||
import io.rixa.bot.commands.Command;
|
||||
import io.rixa.bot.commands.handler.CommandType;
|
||||
import io.rixa.bot.commands.perms.RixaPermission;
|
||||
import io.rixa.bot.guild.RixaGuild;
|
||||
import io.rixa.bot.guild.manager.GuildManager;
|
||||
@@ -43,8 +44,8 @@ public class MusicCommand extends Command {
|
||||
private final int DEFAULT_VOLUME = 35;
|
||||
private final AudioPlayerManager playerManager;
|
||||
|
||||
public MusicCommand(String command, RixaPermission rixaPermission, String description) {
|
||||
super(command, rixaPermission, description);
|
||||
public MusicCommand(String command, RixaPermission rixaPermission, String description, CommandType commandType) {
|
||||
super(command, rixaPermission, description, commandType);
|
||||
this.playerManager = new DefaultAudioPlayerManager();
|
||||
this.playerManager.registerSourceManager(new YoutubeAudioSourceManager());
|
||||
this.playerManager.registerSourceManager(new SoundCloudAudioSourceManager());
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
package io.rixa.bot.commands.cmds.general;
|
||||
|
||||
import io.rixa.bot.commands.Command;
|
||||
import io.rixa.bot.commands.handler.CommandType;
|
||||
import io.rixa.bot.commands.perms.RixaPermission;
|
||||
import io.rixa.bot.utils.MessageFactory;
|
||||
import net.dv8tion.jda.core.entities.Guild;
|
||||
@@ -10,8 +11,8 @@ import net.dv8tion.jda.core.events.message.guild.GuildMessageReceivedEvent;
|
||||
|
||||
public class PingCommand extends Command {
|
||||
|
||||
public PingCommand(String command, RixaPermission rixaPermission, String description) {
|
||||
super(command, rixaPermission, description);
|
||||
public PingCommand(String command, RixaPermission rixaPermission, String description, CommandType commandType) {
|
||||
super(command, rixaPermission, description, commandType);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
package io.rixa.bot.commands.cmds.general;
|
||||
|
||||
import io.rixa.bot.commands.Command;
|
||||
import io.rixa.bot.commands.handler.CommandType;
|
||||
import io.rixa.bot.commands.perms.RixaPermission;
|
||||
import io.rixa.bot.utils.MessageFactory;
|
||||
import io.rixa.bot.utils.WebUtil;
|
||||
@@ -14,8 +15,8 @@ import java.io.IOException;
|
||||
|
||||
public class QuoteCommand extends Command {
|
||||
|
||||
public QuoteCommand(String command, RixaPermission rixaPermission, String description) {
|
||||
super(command, rixaPermission, description);
|
||||
public QuoteCommand(String command, RixaPermission rixaPermission, String description, CommandType commandType) {
|
||||
super(command, rixaPermission, description, commandType);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -1,32 +1,25 @@
|
||||
package io.rixa.bot.commands.cmds.general;
|
||||
|
||||
import io.rixa.bot.Rixa;
|
||||
import io.rixa.bot.commands.Command;
|
||||
import io.rixa.bot.commands.handler.CommandType;
|
||||
import io.rixa.bot.commands.perms.RixaPermission;
|
||||
import io.rixa.bot.data.storage.DatabaseAdapter;
|
||||
import io.rixa.bot.guild.RixaGuild;
|
||||
import io.rixa.bot.guild.manager.GuildManager;
|
||||
import io.rixa.bot.guild.modules.module.LevelsModule;
|
||||
import io.rixa.bot.pagination.ObjectPagination;
|
||||
import io.rixa.bot.user.RixaUser;
|
||||
import io.rixa.bot.user.manager.UserManager;
|
||||
import io.rixa.bot.utils.DiscordUtils;
|
||||
import io.rixa.bot.utils.MessageFactory;
|
||||
import net.dv8tion.jda.core.MessageBuilder;
|
||||
import java.util.List;
|
||||
import net.dv8tion.jda.core.entities.Guild;
|
||||
import net.dv8tion.jda.core.entities.Member;
|
||||
import net.dv8tion.jda.core.entities.TextChannel;
|
||||
import net.dv8tion.jda.core.entities.User;
|
||||
|
||||
import java.sql.ResultSet;
|
||||
import java.sql.SQLException;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
public class RankCommand extends Command {
|
||||
|
||||
public RankCommand(String command, RixaPermission rixaPermission, String description) {
|
||||
super(command, rixaPermission, description);
|
||||
public RankCommand(String command, RixaPermission rixaPermission, String description, CommandType commandType) {
|
||||
super(command, rixaPermission, description, commandType);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
package io.rixa.bot.commands.cmds.general;
|
||||
|
||||
import io.rixa.bot.commands.Command;
|
||||
import io.rixa.bot.commands.handler.CommandType;
|
||||
import io.rixa.bot.commands.perms.RixaPermission;
|
||||
import io.rixa.bot.utils.DiscordUtils;
|
||||
import io.rixa.bot.utils.MessageFactory;
|
||||
@@ -14,8 +15,8 @@ import java.util.List;
|
||||
|
||||
public class RoleMemberList extends Command {
|
||||
|
||||
public RoleMemberList(String command, RixaPermission rixaPermission, String description) {
|
||||
super(command, rixaPermission, description);
|
||||
public RoleMemberList(String command, RixaPermission rixaPermission, String description, CommandType commandType) {
|
||||
super(command, rixaPermission, description, commandType);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
package io.rixa.bot.commands.cmds.general;
|
||||
|
||||
import io.rixa.bot.commands.Command;
|
||||
import io.rixa.bot.commands.handler.CommandType;
|
||||
import io.rixa.bot.commands.perms.RixaPermission;
|
||||
import io.rixa.bot.guild.RixaGuild;
|
||||
import io.rixa.bot.guild.manager.GuildManager;
|
||||
@@ -15,8 +16,8 @@ import java.time.format.DateTimeFormatter;
|
||||
|
||||
public class ServerInfoCommand extends Command {
|
||||
|
||||
public ServerInfoCommand(String command, RixaPermission rixaPermission, String description) {
|
||||
super(command, rixaPermission, description);
|
||||
public ServerInfoCommand(String command, RixaPermission rixaPermission, String description, CommandType commandType) {
|
||||
super(command, rixaPermission, description, commandType);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -2,6 +2,7 @@ package io.rixa.bot.commands.cmds.general;
|
||||
|
||||
import io.rixa.bot.apis.UrbanDictionary;
|
||||
import io.rixa.bot.commands.Command;
|
||||
import io.rixa.bot.commands.handler.CommandType;
|
||||
import io.rixa.bot.commands.perms.RixaPermission;
|
||||
import io.rixa.bot.utils.MessageFactory;
|
||||
import net.dv8tion.jda.core.MessageBuilder;
|
||||
@@ -15,8 +16,8 @@ import java.net.URLEncoder;
|
||||
|
||||
public class UrbanDictionaryCommand extends Command {
|
||||
|
||||
public UrbanDictionaryCommand(String command, RixaPermission rixaPermission, String description) {
|
||||
super(command, rixaPermission, description);
|
||||
public UrbanDictionaryCommand(String command, RixaPermission rixaPermission, String description, CommandType commandType) {
|
||||
super(command, rixaPermission, description, commandType);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -2,6 +2,7 @@ package io.rixa.bot.commands.cmds.general;
|
||||
|
||||
import io.rixa.bot.apis.YoutubeSearch;
|
||||
import io.rixa.bot.commands.Command;
|
||||
import io.rixa.bot.commands.handler.CommandType;
|
||||
import io.rixa.bot.commands.perms.RixaPermission;
|
||||
import io.rixa.bot.utils.MessageFactory;
|
||||
import net.dv8tion.jda.core.entities.Guild;
|
||||
@@ -12,8 +13,8 @@ import java.io.IOException;
|
||||
|
||||
public class YoutubeCommand extends Command {
|
||||
|
||||
public YoutubeCommand(String command, RixaPermission rixaPermission, String description) {
|
||||
super(command, rixaPermission, description);
|
||||
public YoutubeCommand(String command, RixaPermission rixaPermission, String description, CommandType commandType) {
|
||||
super(command, rixaPermission, description, commandType);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -1,24 +1,21 @@
|
||||
package io.rixa.bot.commands.cmds.moderator;
|
||||
|
||||
import io.rixa.bot.Rixa;
|
||||
import io.rixa.bot.commands.Command;
|
||||
import io.rixa.bot.commands.handler.CommandType;
|
||||
import io.rixa.bot.commands.perms.RixaPermission;
|
||||
import io.rixa.bot.guild.RixaGuild;
|
||||
import io.rixa.bot.guild.manager.GuildManager;
|
||||
import io.rixa.bot.utils.MessageFactory;
|
||||
import jdk.nashorn.internal.objects.annotations.Getter;
|
||||
import net.dv8tion.jda.core.entities.Guild;
|
||||
import net.dv8tion.jda.core.entities.Member;
|
||||
import net.dv8tion.jda.core.entities.TextChannel;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public class BanCommand extends Command {
|
||||
|
||||
RixaPermission permission;
|
||||
|
||||
public BanCommand(String command, RixaPermission permission, String descriptopn) {
|
||||
super(command, permission, descriptopn);
|
||||
public BanCommand(String command, RixaPermission permission, String description, CommandType commandType) {
|
||||
super(command, permission, description, commandType);
|
||||
this.permission = permission;
|
||||
}
|
||||
|
||||
@@ -29,7 +26,7 @@ public class BanCommand extends Command {
|
||||
MessageFactory.create(
|
||||
String.format("Incorrect Usage! Example: `%s%s @User`", rixaGuild.getSettings().getPrefix(),
|
||||
command)).setColor(member.getColor()).queue(channel);
|
||||
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -2,6 +2,7 @@ package io.rixa.bot.commands.cmds.moderator;
|
||||
|
||||
import io.rixa.bot.Rixa;
|
||||
import io.rixa.bot.commands.Command;
|
||||
import io.rixa.bot.commands.handler.CommandType;
|
||||
import io.rixa.bot.commands.perms.RixaPermission;
|
||||
import io.rixa.bot.guild.RixaGuild;
|
||||
import io.rixa.bot.guild.manager.GuildManager;
|
||||
@@ -25,9 +26,9 @@ public class ClearCommand extends Command {
|
||||
@Getter
|
||||
private RixaPermission rixaPermission;
|
||||
|
||||
public ClearCommand(String command, RixaPermission rixaPermission, String description,
|
||||
public ClearCommand(String command, RixaPermission rixaPermission, String description, CommandType commandType,
|
||||
List<String> aliases) {
|
||||
super(command, rixaPermission, description, aliases);
|
||||
super(command, rixaPermission, description, commandType, aliases);
|
||||
this.rixaPermission = rixaPermission;
|
||||
}
|
||||
|
||||
|
||||
@@ -3,6 +3,7 @@ package io.rixa.bot.commands.cmds.moderator;
|
||||
import com.dumptruckman.taskmin.Task;
|
||||
import com.dumptruckman.taskmin.TaskManager;
|
||||
import io.rixa.bot.commands.Command;
|
||||
import io.rixa.bot.commands.handler.CommandType;
|
||||
import io.rixa.bot.commands.perms.RixaPermission;
|
||||
import io.rixa.bot.guild.RixaGuild;
|
||||
import io.rixa.bot.guild.manager.GuildManager;
|
||||
@@ -13,17 +14,15 @@ import java.time.LocalDateTime;
|
||||
import java.time.temporal.ChronoUnit;
|
||||
import net.dv8tion.jda.core.entities.Guild;
|
||||
import net.dv8tion.jda.core.entities.Member;
|
||||
import net.dv8tion.jda.core.entities.Role;
|
||||
import net.dv8tion.jda.core.entities.TextChannel;
|
||||
import net.dv8tion.jda.core.entities.User;
|
||||
|
||||
public class MuteCommand extends Command {
|
||||
|
||||
private RixaPermission rixaPermission;
|
||||
private TaskManager taskManager;
|
||||
|
||||
public MuteCommand(String command, RixaPermission rixaPermission, String description) {
|
||||
super(command, rixaPermission, description);
|
||||
this.rixaPermission = rixaPermission;
|
||||
public MuteCommand(String command, RixaPermission rixaPermission, String description, CommandType commandType) {
|
||||
super(command, rixaPermission, description, commandType);
|
||||
this.taskManager = TaskManager.createBasicTaskManager();
|
||||
}
|
||||
|
||||
@@ -31,22 +30,34 @@ public class MuteCommand extends Command {
|
||||
public void execute(String commandLabel, Guild guild, Member member, TextChannel channel,
|
||||
String[] args) {
|
||||
RixaGuild rixaGuild = GuildManager.getInstance().getGuild(guild);
|
||||
if (args.length < 2) {
|
||||
MessageFactory.create(String.format
|
||||
("Incorrect Usage! Example: `%s%s <user> <timeFrame> [reason]`",
|
||||
rixaGuild.getSettings().getPrefix(), commandLabel))
|
||||
.setColor(member.getColor())
|
||||
.queue(channel);
|
||||
return;
|
||||
}
|
||||
String argumentString = String.join(" ", args);
|
||||
Object[] objArray = DiscordUtils.memberSearchArray(guild, argumentString, false);
|
||||
if (objArray.length == 0) {
|
||||
MessageFactory.create("Could not find member!").setColor(member.getColor()).queue(channel);
|
||||
return;
|
||||
}
|
||||
Member targetMember = (Member) objArray[1];
|
||||
String targetMemberName = String.valueOf(objArray[0]);
|
||||
Member targetMember = (Member) objArray[1];
|
||||
if (targetMember == null) {
|
||||
MessageFactory.create("Could not find member!").setColor(member.getColor()).queue(channel);
|
||||
return;
|
||||
}
|
||||
argumentString = argumentString.replaceFirst(targetMemberName, "").trim();
|
||||
args = argumentString.split(" ");
|
||||
if (args[0].length() == 0) {
|
||||
// Incorrect Usage
|
||||
if (args.length == 0) {
|
||||
MessageFactory.create(String.format
|
||||
("Incorrect Usage! Example: `%s%s <user> <timeFrame> [reason]`",
|
||||
rixaGuild.getSettings().getPrefix(), commandLabel))
|
||||
.setColor(member.getColor())
|
||||
.queue(channel);
|
||||
return;
|
||||
}
|
||||
String time = args[0].trim();
|
||||
@@ -61,13 +72,16 @@ public class MuteCommand extends Command {
|
||||
|
||||
long milliseconds = Utils.toMilliSec(time);
|
||||
String reason = argumentString;
|
||||
guild.getController().addRolesToMember(targetMember, rixaGuild.getSettings().getMuteRole())
|
||||
|
||||
Role muteRole = rixaGuild.getSettings().getMuteRole() == null
|
||||
? DiscordUtils.createMuteRole(guild) : rixaGuild.getSettings().getMuteRole();
|
||||
guild.getController().addRolesToMember(targetMember, muteRole)
|
||||
.queue(onSuccess -> MessageFactory.create(String.format(
|
||||
"Temporarily muted %s for %s\n Reason: %s",
|
||||
this.getUser(targetMember.getUser()),
|
||||
this.getTime(milliseconds),
|
||||
reason))
|
||||
.setColor(member.getColor()).setTimestamp().queue(channel),
|
||||
.setColor(member.getColor()).setTimestamp().queue(channel),
|
||||
onFailure -> MessageFactory.create(
|
||||
"Could not successfully mute user `" + targetMember.getUser().getName() + "#"
|
||||
+ targetMember.getUser()
|
||||
@@ -89,7 +103,8 @@ public class MuteCommand extends Command {
|
||||
days = hours / 24;
|
||||
minutes = minutes % 60;
|
||||
|
||||
return(String.format("%s days, %s hours, %s minutes, %s seconds", days, hours, minutes, seconds));
|
||||
return (String
|
||||
.format("%s days, %s hours, %s minutes, %s seconds", days, hours, minutes, seconds));
|
||||
}
|
||||
|
||||
private String getUser(User member) {
|
||||
|
||||
@@ -2,6 +2,7 @@ package io.rixa.bot.commands.cmds.other;
|
||||
|
||||
import io.rixa.bot.Rixa;
|
||||
import io.rixa.bot.commands.Command;
|
||||
import io.rixa.bot.commands.handler.CommandType;
|
||||
import io.rixa.bot.commands.perms.RixaPermission;
|
||||
import io.rixa.bot.guild.RixaGuild;
|
||||
import io.rixa.bot.guild.manager.GuildManager;
|
||||
@@ -13,8 +14,8 @@ import net.dv8tion.jda.core.events.message.guild.GuildMessageReceivedEvent;
|
||||
|
||||
public class ShutdownCommand extends Command {
|
||||
|
||||
public ShutdownCommand(String command, RixaPermission rixaPermission, String description) {
|
||||
super(command, rixaPermission, description);
|
||||
public ShutdownCommand(String command, RixaPermission rixaPermission, String description, CommandType commandType) {
|
||||
super(command, rixaPermission, description, commandType);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -0,0 +1,8 @@
|
||||
package io.rixa.bot.commands.exceptions;
|
||||
|
||||
public class ReactNotFoundException extends Exception {
|
||||
|
||||
public ReactNotFoundException(String message) {
|
||||
super(message);
|
||||
}
|
||||
}
|
||||
@@ -31,4 +31,8 @@ public class CommandHandler {
|
||||
}
|
||||
throw new CommandNotFoundException("Could not find command");
|
||||
}
|
||||
|
||||
public Map<String, Command> getAllCommands() {
|
||||
return this.commandMap;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,8 @@
|
||||
package io.rixa.bot.commands.handler;
|
||||
|
||||
public enum CommandType {
|
||||
|
||||
STAFF,
|
||||
USER,
|
||||
OWNER;
|
||||
}
|
||||
Reference in New Issue
Block a user