Implemented COmmandType and ReactionManager
This commit is contained in:
parent
b24462e55c
commit
e0d66b816d
@ -4,12 +4,27 @@ import com.fasterxml.jackson.databind.ObjectMapper;
|
||||
import com.fasterxml.jackson.dataformat.yaml.YAMLFactory;
|
||||
import io.rixa.bot.commands.cmds.admin.ConfigCommand;
|
||||
import io.rixa.bot.commands.cmds.admin.PMCommand;
|
||||
import io.rixa.bot.commands.cmds.general.*;
|
||||
import io.rixa.bot.commands.cmds.general.AdviceCommand;
|
||||
import io.rixa.bot.commands.cmds.general.FeaturesCommand;
|
||||
import io.rixa.bot.commands.cmds.general.HelpCommand;
|
||||
import io.rixa.bot.commands.cmds.general.InfoCommand;
|
||||
import io.rixa.bot.commands.cmds.general.LeaderboardsCommand;
|
||||
import io.rixa.bot.commands.cmds.general.MinecraftCommand;
|
||||
import io.rixa.bot.commands.cmds.general.ModulesCommand;
|
||||
import io.rixa.bot.commands.cmds.general.MusicCommand;
|
||||
import io.rixa.bot.commands.cmds.general.PingCommand;
|
||||
import io.rixa.bot.commands.cmds.general.QuoteCommand;
|
||||
import io.rixa.bot.commands.cmds.general.RankCommand;
|
||||
import io.rixa.bot.commands.cmds.general.RoleMemberList;
|
||||
import io.rixa.bot.commands.cmds.general.ServerInfoCommand;
|
||||
import io.rixa.bot.commands.cmds.general.UrbanDictionaryCommand;
|
||||
import io.rixa.bot.commands.cmds.general.YoutubeCommand;
|
||||
import io.rixa.bot.commands.cmds.moderator.BanCommand;
|
||||
import io.rixa.bot.commands.cmds.moderator.ClearCommand;
|
||||
import io.rixa.bot.commands.cmds.moderator.MuteCommand;
|
||||
import io.rixa.bot.commands.cmds.other.ShutdownCommand;
|
||||
import io.rixa.bot.commands.handler.CommandHandler;
|
||||
import io.rixa.bot.commands.handler.CommandType;
|
||||
import io.rixa.bot.commands.perms.RixaPermission;
|
||||
import io.rixa.bot.data.config.Configuration;
|
||||
import io.rixa.bot.data.storage.DatabaseAdapter;
|
||||
@ -23,6 +38,14 @@ import io.rixa.bot.guild.manager.GuildManager;
|
||||
import io.rixa.bot.user.RixaUser;
|
||||
import io.rixa.bot.user.manager.UserManager;
|
||||
import io.rixa.bot.utils.FileUtils;
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.logging.Logger;
|
||||
import javax.security.auth.login.LoginException;
|
||||
import lombok.Getter;
|
||||
import net.dv8tion.jda.core.AccountType;
|
||||
import net.dv8tion.jda.core.JDA;
|
||||
@ -31,21 +54,12 @@ import net.dv8tion.jda.core.OnlineStatus;
|
||||
import net.dv8tion.jda.core.entities.Game;
|
||||
import net.dv8tion.jda.core.entities.Game.GameType;
|
||||
import net.dv8tion.jda.core.entities.Guild;
|
||||
import net.dv8tion.jda.core.exceptions.RateLimitedException;
|
||||
import net.dv8tion.jda.core.hooks.AnnotatedEventManager;
|
||||
|
||||
import javax.security.auth.login.LoginException;
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.logging.Logger;
|
||||
|
||||
public class Rixa {
|
||||
|
||||
private static Rixa instance;
|
||||
private static long timeUp;
|
||||
@Getter
|
||||
private CommandHandler commandHandler;
|
||||
@Getter
|
||||
@ -58,7 +72,6 @@ public class Rixa {
|
||||
private File defaultPath;
|
||||
@Getter
|
||||
private Logger logger;
|
||||
private static long timeUp;
|
||||
|
||||
private Rixa() {
|
||||
instance = this;
|
||||
@ -73,6 +86,10 @@ public class Rixa {
|
||||
loadJDA();
|
||||
}
|
||||
|
||||
public static Rixa getInstance() {
|
||||
return (instance == null) ? new Rixa() : instance;
|
||||
}
|
||||
|
||||
public long getTimeUp() {
|
||||
return timeUp;
|
||||
}
|
||||
@ -113,27 +130,46 @@ public class Rixa {
|
||||
|
||||
private void registerCommands() {
|
||||
this.commandHandler.registerCommands(
|
||||
new AdviceCommand("advice", RixaPermission.NONE, "Receive advice from the great beyond..."),
|
||||
new BanCommand("ban", RixaPermission.BAN_MEMBER, "Ban a player from your server."),
|
||||
new ClearCommand("clear", RixaPermission.CLEAR_CHAT, "Clear Chat!", Arrays.asList("deleemessages", "cmessages")),
|
||||
new ConfigCommand("config", RixaPermission.ACCESS_CONFIG, "Access the config menu"),
|
||||
new FeaturesCommand("features", RixaPermission.NONE, "List Rixa's official features!"),
|
||||
new HelpCommand("help", RixaPermission.NONE, "Review commands and its usages!"),
|
||||
new InfoCommand("info", RixaPermission.NONE, "Review information about a user or Rixa!"),
|
||||
new MinecraftCommand("minecraft", RixaPermission.NONE, "See minecraft server info", Collections.singletonList("mc")),
|
||||
new ModulesCommand("modules", RixaPermission.NONE, "List both enabled & disabled features of Rixa for this server!"),
|
||||
new MusicCommand("music", RixaPermission.NONE, "Listen to music right from discord!"),
|
||||
new MuteCommand("mute", RixaPermission.MUTE, "Mute those pesky children!"),
|
||||
new PingCommand("ping", RixaPermission.NONE, "Check Rixa's ping!"),
|
||||
new PMCommand("pm", RixaPermission.PM_MESSAGE, "Private Message all users with a specific role!"),
|
||||
new QuoteCommand("quote", RixaPermission.NONE, "Receive a quote from some of the greatest authors!"),
|
||||
new RoleMemberList("listmembers", RixaPermission.NONE, "List all users with a specific role!"),
|
||||
new ServerInfoCommand("serverinfo", RixaPermission.NONE, "Review information about the server!"),
|
||||
new ShutdownCommand("shutdown", RixaPermission.NONE, "Shutdown Rixa!"),
|
||||
new UrbanDictionaryCommand("ud", RixaPermission.NONE, "Look up urban definitions!"),
|
||||
new YoutubeCommand("youtube", RixaPermission.NONE, "Search for music on youtube!"),
|
||||
new LeaderboardsCommand("leaderboards", RixaPermission.NONE, "Look at the levels leaderboards!"),
|
||||
new RankCommand("rank", RixaPermission.NONE, "Check your rank!"));
|
||||
new AdviceCommand("advice", RixaPermission.NONE, "Receive advice from the great beyond...",
|
||||
CommandType.USER),
|
||||
new FeaturesCommand("features", RixaPermission.NONE, "List Rixa's official features!",
|
||||
CommandType.USER),
|
||||
new HelpCommand("help", RixaPermission.NONE, "Review commands and its usages!",
|
||||
CommandType.USER),
|
||||
new InfoCommand("info", RixaPermission.NONE, "Review information about a user or Rixa!",
|
||||
CommandType.USER),
|
||||
new MinecraftCommand("minecraft", RixaPermission.NONE, "See minecraft server info",
|
||||
CommandType.USER, Collections.singletonList("mc")),
|
||||
new ModulesCommand("modules", RixaPermission.NONE,
|
||||
"List both enabled & disabled features of Rixa for this server!", CommandType.USER),
|
||||
new MusicCommand("music", RixaPermission.NONE, "Listen to music right from discord!",
|
||||
CommandType.USER),
|
||||
new PingCommand("ping", RixaPermission.NONE, "Check Rixa's ping!", CommandType.USER),
|
||||
new ServerInfoCommand("serverinfo", RixaPermission.NONE,
|
||||
"Review information about the server!", CommandType.USER),
|
||||
new QuoteCommand("quote", RixaPermission.NONE,
|
||||
"Receive a quote from some of the greatest authors!", CommandType.USER),
|
||||
new RankCommand("rank", RixaPermission.NONE, "Check your rank!", CommandType.USER),
|
||||
new LeaderboardsCommand("leaderboards", RixaPermission.NONE,
|
||||
"Look at the levels leaderboards!", CommandType.USER),
|
||||
new YoutubeCommand("youtube", RixaPermission.NONE, "Search for music on youtube!",
|
||||
CommandType.USER),
|
||||
new UrbanDictionaryCommand("ud", RixaPermission.NONE, "Look up urban definitions!",
|
||||
CommandType.USER),
|
||||
|
||||
new BanCommand("ban", RixaPermission.BAN_MEMBER, "Ban a player from your server.",
|
||||
CommandType.STAFF),
|
||||
new ClearCommand("clear", RixaPermission.CLEAR_CHAT, "Clear Chat!", CommandType.STAFF,
|
||||
Arrays.asList("deleemessages", "cmessages")),
|
||||
new ConfigCommand("config", RixaPermission.ACCESS_CONFIG, "Access the config menu",
|
||||
CommandType.STAFF),
|
||||
new MuteCommand("mute", RixaPermission.MUTE, "Mute those pesky children!",
|
||||
CommandType.STAFF),
|
||||
new PMCommand("pm", RixaPermission.PM_MESSAGE,
|
||||
"Private Message all users with a specific role!", CommandType.STAFF),
|
||||
new RoleMemberList("listmembers", RixaPermission.NONE,
|
||||
"List all users with a specific role!", CommandType.STAFF),
|
||||
new ShutdownCommand("shutdown", RixaPermission.NONE, "Shutdown Rixa!", CommandType.OWNER));
|
||||
}
|
||||
|
||||
private void loadConfiguration() {
|
||||
@ -147,7 +183,8 @@ public class Rixa {
|
||||
logger.info("Configuration successfully loaded.");
|
||||
DatabaseAdapter.getInstance().check();
|
||||
Arrays.stream(DatabaseTables.values()).forEach(databaseTables -> {
|
||||
System.out.println("Checking database table (creating if needed): " + databaseTables.toString());
|
||||
System.out
|
||||
.println("Checking database table (creating if needed): " + databaseTables.toString());
|
||||
DatabaseAdapter.getInstance().get().update(databaseTables.getQuery());
|
||||
System.out.println("Done checking " + databaseTables.toString());
|
||||
});
|
||||
@ -160,16 +197,16 @@ public class Rixa {
|
||||
public Guild getGuildById(String id) {
|
||||
Guild guild = null;
|
||||
for (JDA jda : Rixa.getInstance().getShardList()) {
|
||||
if (jda.getGuilds().size() == 0 || jda.getGuildById(id) == null) continue;
|
||||
if (jda.getGuilds().size() == 0 || jda.getGuildById(id) == null) {
|
||||
continue;
|
||||
}
|
||||
guild = jda.getGuildById(id);
|
||||
break;
|
||||
}
|
||||
if (guild != null) return guild;
|
||||
throw new NullPointerException("Guild not found.");
|
||||
if (guild != null) {
|
||||
return guild;
|
||||
}
|
||||
|
||||
public static Rixa getInstance() {
|
||||
return (instance == null) ? new Rixa() : instance;
|
||||
throw new NullPointerException("Guild not found.");
|
||||
}
|
||||
|
||||
public void close() {
|
||||
|
@ -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;
|
||||
@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) {
|
||||
this(command, RixaPermission.NONE, "Undefined", Collections.emptyList());
|
||||
this(command, RixaPermission.NONE, "Undefined", CommandType.USER, Collections.emptyList());
|
||||
}
|
||||
|
||||
public Command(String command, RixaPermission rixaPermission) {
|
||||
this(command, rixaPermission, "Undefined", Collections.emptyList());
|
||||
this(command, rixaPermission, "Undefined", CommandType.USER, Collections.emptyList());
|
||||
}
|
||||
|
||||
public Command(String command, RixaPermission rixaPermission, String description) {
|
||||
this(command, rixaPermission, description, Collections.emptyList());
|
||||
this(command, rixaPermission, description, CommandType.USER, Collections.emptyList());
|
||||
}
|
||||
|
||||
public Command(String command, RixaPermission rixaPermission, String description, List<String> aliases) {
|
||||
public Command(String command, RixaPermission rixaPermission, String description, CommandType commandType) {
|
||||
this(command, rixaPermission, description, commandType, Collections.emptyList());
|
||||
}
|
||||
|
||||
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;
|
||||
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,7 +72,10 @@ 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()),
|
||||
@ -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;
|
||||
}
|
@ -15,10 +15,16 @@ import java.io.IOException;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
import net.dv8tion.jda.core.entities.TextChannel;
|
||||
import net.dv8tion.jda.core.events.message.guild.GuildMessageReceivedEvent;
|
||||
import net.dv8tion.jda.core.events.message.guild.react.GuildMessageReactionAddEvent;
|
||||
import net.dv8tion.jda.core.hooks.SubscribeEvent;
|
||||
|
||||
public class MessageListener {
|
||||
|
||||
@SubscribeEvent
|
||||
public void onReactionAdded(GuildMessageReactionAddEvent event) {
|
||||
if (event.getUser().isBot()) return;
|
||||
}
|
||||
|
||||
@SubscribeEvent
|
||||
public void onMessage(GuildMessageReceivedEvent event) {
|
||||
if (event.getAuthor().isBot()) {
|
||||
@ -26,7 +32,8 @@ public class MessageListener {
|
||||
}
|
||||
String message = event.getMessage().getContentRaw().trim();
|
||||
RixaGuild rixaGuild = GuildManager.getInstance().getGuild(event.getGuild());
|
||||
if (event.getMessage().getContentDisplay().startsWith("@" + event.getGuild().getSelfMember().getEffectiveName())) {
|
||||
if (event.getMessage().getContentDisplay()
|
||||
.startsWith("@" + event.getGuild().getSelfMember().getEffectiveName())) {
|
||||
String chat = event.getMessage().getContentDisplay();
|
||||
chatter(rixaGuild, event.getChannel(),
|
||||
chat.replace("@" + event.getGuild().getSelfMember().getEffectiveName(), ""));
|
||||
@ -62,7 +69,8 @@ public class MessageListener {
|
||||
//command.execute(event);
|
||||
event.getMessage().delete().queueAfter(3, TimeUnit.SECONDS);
|
||||
RixaGuild rixaGuild = GuildManager.getInstance().getGuild(event.getGuild());
|
||||
if (command.getPermission() != null && command.getPermission() != RixaPermission.NONE &&
|
||||
if (!event.getGuild().getOwner().getUser().getId().equalsIgnoreCase(event.getAuthor().getId())
|
||||
&& command.getPermission() != null && command.getPermission() != RixaPermission.NONE &&
|
||||
(!rixaGuild.hasPermission(event.getMember().getUser(), command.getPermission()))
|
||||
&& (!Rixa.getInstance().getConfiguration().isBotAdmin(event.getAuthor().getId()))) {
|
||||
MessageFactory.create("Sorry! You do not have permission for this command!")
|
||||
|
10
src/main/java/io/rixa/bot/reactions/React.java
Normal file
10
src/main/java/io/rixa/bot/reactions/React.java
Normal file
@ -0,0 +1,10 @@
|
||||
package io.rixa.bot.reactions;
|
||||
|
||||
import net.dv8tion.jda.core.events.message.guild.react.GuildMessageReactionAddEvent;
|
||||
|
||||
public interface React {
|
||||
|
||||
void onReact(GuildMessageReactionAddEvent event);
|
||||
|
||||
String getName();
|
||||
}
|
37
src/main/java/io/rixa/bot/reactions/ReactManager.java
Normal file
37
src/main/java/io/rixa/bot/reactions/ReactManager.java
Normal file
@ -0,0 +1,37 @@
|
||||
package io.rixa.bot.reactions;
|
||||
|
||||
import io.rixa.bot.commands.Command;
|
||||
import io.rixa.bot.commands.exceptions.CommandNotFoundException;
|
||||
import io.rixa.bot.commands.exceptions.ReactNotFoundException;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
public class ReactManager {
|
||||
|
||||
private Map<String, React> reactMap = new HashMap<>();
|
||||
|
||||
|
||||
private void registerReact(React react) {
|
||||
if (this.reactMap.containsKey(react.getName())) {
|
||||
return;
|
||||
}
|
||||
this.reactMap.put(react.getName(), react);
|
||||
}
|
||||
|
||||
public void registerReact(React... reacts) {
|
||||
for (React react : reacts) {
|
||||
registerReact(react);
|
||||
}
|
||||
}
|
||||
|
||||
public React getReaction(String react) throws ReactNotFoundException {
|
||||
if (reactMap.containsKey(react.toLowerCase())) {
|
||||
return reactMap.get(react.toLowerCase());
|
||||
}
|
||||
throw new ReactNotFoundException("Could not find reaction");
|
||||
}
|
||||
|
||||
public Map<String, React> getAllReactions() {
|
||||
return this.reactMap;
|
||||
}
|
||||
}
|
118
src/main/java/io/rixa/bot/reactions/react/HelpReaction.java
Normal file
118
src/main/java/io/rixa/bot/reactions/react/HelpReaction.java
Normal file
@ -0,0 +1,118 @@
|
||||
package io.rixa.bot.reactions.react;
|
||||
|
||||
import io.rixa.bot.Rixa;
|
||||
import io.rixa.bot.commands.handler.CommandHandler;
|
||||
import io.rixa.bot.guild.RixaGuild;
|
||||
import io.rixa.bot.guild.manager.GuildManager;
|
||||
import io.rixa.bot.reactions.React;
|
||||
import net.dv8tion.jda.core.EmbedBuilder;
|
||||
import net.dv8tion.jda.core.entities.Message;
|
||||
import net.dv8tion.jda.core.entities.MessageEmbed;
|
||||
import net.dv8tion.jda.core.events.message.guild.react.GuildMessageReactionAddEvent;
|
||||
import net.dv8tion.jda.core.exceptions.ErrorResponseException;
|
||||
import net.dv8tion.jda.core.hooks.SubscribeEvent;
|
||||
|
||||
public class HelpReaction implements React {
|
||||
|
||||
@Override
|
||||
@SubscribeEvent
|
||||
public void onReact(GuildMessageReactionAddEvent event) {
|
||||
if (event.getUser().getId().equalsIgnoreCase(event.getJDA().getSelfUser().getId())) {
|
||||
return;
|
||||
}
|
||||
Message message = event.getChannel().getMessageById(event.getMessageId()).complete();
|
||||
MessageEmbed messageEmbed = message.getEmbeds().get(0);
|
||||
if (!messageEmbed.getTitle().contains(": ")) {
|
||||
return;
|
||||
}
|
||||
String title = messageEmbed.getTitle().split(": ")[1];
|
||||
RixaGuild rixaGuild = GuildManager.getInstance().getGuild(event.getJDA().getGuildById(title));
|
||||
if (rixaGuild == null) {
|
||||
return;
|
||||
}
|
||||
String prefix = rixaGuild.getSettings().getPrefix();
|
||||
EmbedBuilder embedBuilder;
|
||||
try {
|
||||
switch (event.getReaction().getReactionEmote().getName()) {
|
||||
case "\uD83D\uDDD1":// waste bin
|
||||
if (message.getAuthor().getId().equalsIgnoreCase(event.getJDA().getSelfUser().getId())) {
|
||||
message.delete().complete();
|
||||
}
|
||||
break;
|
||||
case "\u0031\u20E3":// one emoji
|
||||
embedBuilder = new EmbedBuilder();
|
||||
String stringBuilder = "\u2753" +
|
||||
" **General Commands Help**" +
|
||||
"\n" +
|
||||
"Click a number below for information about other commands.";
|
||||
embedBuilder.setTitle(String.format("Help: %s", title));
|
||||
embedBuilder.setDescription(stringBuilder);
|
||||
Rixa.getInstance().getCommandHandler().getAllCommands().values()
|
||||
.forEach(cmd -> embedBuilder.addField(prefix + cmd.getCommand(),
|
||||
cmd.getDescription(), false));
|
||||
message.editMessage(embedBuilder.build()).queue();
|
||||
break;
|
||||
/*case "\u0032\u20E3": // two emoji
|
||||
embedBuilder = new EmbedBuilder();
|
||||
stringBuilder = "\u2753" +
|
||||
" **Staff Commands Help**" +
|
||||
"\n" +
|
||||
"Click a number below for information about other commands.";
|
||||
embedBuilder.setTitle(String.format("Help: %s", title));
|
||||
embedBuilder.setDescription(stringBuilder);
|
||||
Rixa.getInstance().getCommandHandler().getAllCommands().values().stream()
|
||||
.filter(cmd -> cmd.getAnnotation().type() == CommandType.ADMIN
|
||||
|| cmd.getAnnotation().type() == CommandType.MOD)
|
||||
.forEach(cmd -> embedBuilder.addField(prefix + cmd.getAnnotation().mainCommand(),
|
||||
cmd.getAnnotation().description(), false));
|
||||
message.editMessage(embedBuilder.build()).queue();
|
||||
break;*/
|
||||
case "\u0033\u20E3": // three emoji
|
||||
embedBuilder = new EmbedBuilder();
|
||||
stringBuilder = "\u2753" +
|
||||
" **Music Commands Help**" +
|
||||
"\n" +
|
||||
"Click a number below for information about other commands.";
|
||||
embedBuilder.setTitle(String.format("Help: %s", title));
|
||||
embedBuilder.setDescription(stringBuilder);
|
||||
embedBuilder.addField(prefix + "music join [name]",
|
||||
"Joins a voice channel that has the provided name", false)
|
||||
.addField(prefix + "music join [id]",
|
||||
"Joins a voice channel based on the provided id.", false)
|
||||
.addField(prefix + "music leave",
|
||||
"Leaves the voice channel that the bot is currently in.", false)
|
||||
.addField(prefix + "music play",
|
||||
"Plays songs from the current queue. Starts playing again if it was previously paused",
|
||||
false)
|
||||
.addField(prefix + "music play [url]",
|
||||
"Adds a new song to the queue and starts playing if it wasn't playing already",
|
||||
false)
|
||||
.addField(prefix + "music playlist",
|
||||
"Adds a playlist to the queue and starts playing if not already playing", false)
|
||||
.addField(prefix + "music pause", "Pauses audio playback", false)
|
||||
.addField(prefix + "music stop",
|
||||
"Completely stops audio playback, skipping the current song.", false)
|
||||
.addField(prefix + "music skip",
|
||||
"Skips the current song, automatically starting the next", false)
|
||||
.addField(prefix + "music nowplaying",
|
||||
"Prints information about the currently playing song (title, current time)",
|
||||
false)
|
||||
.addField(prefix + "music np", "Alias for nowplaying", false)
|
||||
.addField(prefix + "music list", "Lists the songs in the queue", false)
|
||||
.addField(prefix + "music volume [vol]",
|
||||
"Sets the volume of the MusicPlayer [10 - 100]", false)
|
||||
.addField(prefix + "music restart",
|
||||
"Restarts the current song or restarts the previous song if there is no current song playing.",
|
||||
false)
|
||||
.addField(prefix + "music repeat",
|
||||
"Makes the player repeat the currently playing song", false)
|
||||
.addField(prefix + "music reset",
|
||||
"Completely resets the player, fixing all errors and clearing the queue.", false)
|
||||
.addField(prefix + "music shuffle", "Shuffle current music queue.", false);
|
||||
message.editMessage(embedBuilder.build()).queue();
|
||||
break;
|
||||
}
|
||||
} catch (ErrorResponseException ignored) {
|
||||
}
|
||||
}
|
||||
}
|
@ -1,8 +1,12 @@
|
||||
package io.rixa.bot.utils;
|
||||
|
||||
import java.awt.Color;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.Optional;
|
||||
import net.dv8tion.jda.core.Permission;
|
||||
import net.dv8tion.jda.core.entities.Guild;
|
||||
import net.dv8tion.jda.core.entities.Member;
|
||||
import net.dv8tion.jda.core.entities.Role;
|
||||
@ -127,4 +131,17 @@ public class DiscordUtils {
|
||||
}
|
||||
return xp;
|
||||
}
|
||||
|
||||
public static Role createMuteRole(Guild guild) {
|
||||
Role role =
|
||||
guild.getController().createRole().setName("Mute")
|
||||
.setColor(Color.DARK_GRAY).setMentionable(false)
|
||||
.complete();
|
||||
guild.getTextChannels().forEach(textChannel ->
|
||||
textChannel.createPermissionOverride(role).setPermissions(Arrays.asList(
|
||||
Permission.MESSAGE_READ, Permission.MESSAGE_HISTORY),
|
||||
Collections.singletonList(
|
||||
Permission.MESSAGE_WRITE)).queue());
|
||||
return role;
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user