Obliterated legacy command support
This commit is contained in:
parent
68aadceb40
commit
76e0ef0988
|
@ -44,8 +44,6 @@ public class Kiafumi {
|
|||
|
||||
public Logger logger = LoggerFactory.getLogger("Kiafumi");
|
||||
|
||||
public static String PREFIX;
|
||||
|
||||
public static Kiafumi instance;
|
||||
|
||||
public static JDA JDA;
|
||||
|
@ -129,7 +127,6 @@ public class Kiafumi {
|
|||
Runtime.getRuntime().addShutdownHook(new Thread(this::stop));
|
||||
|
||||
//We have the prefix as a static thing that can be referenced anywhere, this is for simplicity.
|
||||
PREFIX = config.getPrefix();
|
||||
|
||||
//Initializes database and loads credentials.
|
||||
database = config.createDb();
|
||||
|
|
|
@ -26,7 +26,6 @@ public class KiafumiConfig {
|
|||
private String ownerId;
|
||||
private String mainGuild;
|
||||
private String clientId;
|
||||
private String prefix;
|
||||
private int defaultInvitePermissionLevel;
|
||||
|
||||
/*
|
||||
|
@ -81,8 +80,6 @@ public class KiafumiConfig {
|
|||
clientId = discord.getString("clientId");
|
||||
defaultInvitePermissionLevel = discord.getInt("invitePermissionLevel");
|
||||
info("Invite link - " + assembleDefaultInvite());
|
||||
prefix = discord.getString("prefix");
|
||||
info("Prefix - " + prefix);
|
||||
//Kia loaders
|
||||
ConfigurationSection main = configuration.getConfigurationSection("main");
|
||||
sharded = main.getBoolean("sharded");
|
||||
|
@ -117,10 +114,6 @@ public class KiafumiConfig {
|
|||
return "https://discord.com/oauth2/authorize?client_id=" + clientId + "&scope=bot+applications.commands&permissions=" + defaultInvitePermissionLevel;
|
||||
}
|
||||
|
||||
public String getPrefix() {
|
||||
return prefix;
|
||||
}
|
||||
|
||||
public String getToken() { return token; }
|
||||
|
||||
public String getActivityType() { return activityType; }
|
||||
|
|
|
@ -3,7 +3,6 @@ package moe.oko.Kiafumi.command;
|
|||
import moe.oko.Kiafumi.Kiafumi;
|
||||
import moe.oko.Kiafumi.util.CommandInfo;
|
||||
import net.dv8tion.jda.api.events.interaction.command.SlashCommandInteractionEvent;
|
||||
import net.dv8tion.jda.api.events.message.MessageReceivedEvent;
|
||||
import net.dv8tion.jda.api.hooks.ListenerAdapter;
|
||||
|
||||
import java.util.List;
|
||||
|
@ -16,15 +15,6 @@ public abstract class CommandClass extends ListenerAdapter {
|
|||
//Whats the name of the Command Package (Specify if multiple, like "Utility" or "Moderation")
|
||||
public abstract String getName();
|
||||
|
||||
/**
|
||||
* Your execution function. What the CommandPlugin will include.
|
||||
* Use a CASE statement to help it out. (Soon to be deprecated in favour of slash cmds)
|
||||
* @param args - basic arguments send with the command for QOL.
|
||||
* @param e - MessageRecievedEvent for the sake of getting author or whatever.
|
||||
*/
|
||||
@Deprecated
|
||||
public abstract void legacyCommand(String[] args, MessageReceivedEvent e, boolean prefix);
|
||||
|
||||
/**
|
||||
* For new slash commands
|
||||
* @param name - name of the command executed
|
||||
|
@ -32,23 +22,6 @@ public abstract class CommandClass extends ListenerAdapter {
|
|||
*/
|
||||
public abstract void newCommand(String name, SlashCommandInteractionEvent e);
|
||||
|
||||
/**
|
||||
* Overriding our GuildMessageReceivedEvent that way we can execute a cmd...
|
||||
* @param event - Message received event
|
||||
*/
|
||||
@Override
|
||||
public void onMessageReceived(MessageReceivedEvent event) {
|
||||
if(event.getAuthor().isBot() || event.getAuthor().isSystem()) return;
|
||||
if(event.getAuthor().getId().equals(Kiafumi.JDA.getSelfUser().getId())) return;
|
||||
if(!event.getChannel().canTalk()) return;
|
||||
|
||||
String[] args = event.getMessage().getContentDisplay().replace(Kiafumi.PREFIX, "").split(" ");
|
||||
//Removes prefix from args and also splits the arguments into proper args.
|
||||
|
||||
boolean prefixed = event.getMessage().getContentDisplay().startsWith(Kiafumi.PREFIX);
|
||||
legacyCommand(args, event, prefixed);
|
||||
}
|
||||
|
||||
/**
|
||||
* Overriding our SlashCommandInteractionEvent that way it can execute a cmd.
|
||||
* @param event
|
||||
|
@ -58,15 +31,6 @@ public abstract class CommandClass extends ListenerAdapter {
|
|||
newCommand(event.getName(), event);
|
||||
}
|
||||
|
||||
/**
|
||||
* @deprecated - soon to be removed in favour of getSlashCommandInfo()
|
||||
* For the sake of organization. Format the strings like so:
|
||||
* command - description.
|
||||
* @return
|
||||
*/
|
||||
@Deprecated
|
||||
public abstract List<String> getCommandsAsList();
|
||||
|
||||
/**
|
||||
* Also for the sake of organization. To upsert slash commands.
|
||||
* Follow as name, description. (for upsertCommand(name, description);
|
||||
|
|
|
@ -6,7 +6,6 @@ import moe.oko.Kiafumi.util.EmbedUI;
|
|||
import net.dv8tion.jda.api.EmbedBuilder;
|
||||
import net.dv8tion.jda.api.entities.User;
|
||||
import net.dv8tion.jda.api.events.interaction.command.SlashCommandInteractionEvent;
|
||||
import net.dv8tion.jda.api.events.message.MessageReceivedEvent;
|
||||
import net.dv8tion.jda.api.interactions.commands.OptionMapping;
|
||||
import net.dv8tion.jda.api.interactions.commands.OptionType;
|
||||
|
||||
|
@ -29,18 +28,15 @@ public class DreidelCommand extends CommandClass {
|
|||
return "Dreidel";
|
||||
}
|
||||
|
||||
@Override
|
||||
public void legacyCommand(String[] args, MessageReceivedEvent e, boolean prefix) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void newCommand(String name, SlashCommandInteractionEvent e) {
|
||||
if ("dreidel".equals(name)) {
|
||||
e.deferReply().queue();
|
||||
List<User> usersForRng = new ArrayList<>();
|
||||
List<String> userNames = new ArrayList<>();
|
||||
for (OptionMapping option : e.getOptions()) {
|
||||
usersForRng.add(option.getAsUser());
|
||||
userNames.add(option.getAsUser().getName());
|
||||
}
|
||||
//Done, now roll
|
||||
EmbedBuilder eb = new EmbedBuilder()
|
||||
|
@ -63,11 +59,6 @@ public class DreidelCommand extends CommandClass {
|
|||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> getCommandsAsList() {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<CommandInfo> getSlashCommandInfo() {
|
||||
List<CommandInfo> cil = new ArrayList<>();
|
||||
|
|
|
@ -5,7 +5,6 @@ import moe.oko.Kiafumi.util.CommandType;
|
|||
import moe.oko.Kiafumi.util.EmbedUI;
|
||||
import net.dv8tion.jda.api.EmbedBuilder;
|
||||
import net.dv8tion.jda.api.events.interaction.command.SlashCommandInteractionEvent;
|
||||
import net.dv8tion.jda.api.events.message.MessageReceivedEvent;
|
||||
import net.dv8tion.jda.api.interactions.commands.OptionType;
|
||||
import org.bitnick.net.duckduckgo.WebSearch;
|
||||
import org.bitnick.net.duckduckgo.entity.SearchResult;
|
||||
|
@ -27,11 +26,6 @@ public class DuckCommand extends CommandClass{
|
|||
return "Duck";
|
||||
}
|
||||
|
||||
@Override
|
||||
public void legacyCommand(String[] args, MessageReceivedEvent e, boolean prefix) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void newCommand(String name, SlashCommandInteractionEvent e) {
|
||||
if ("search".equals(name)) {
|
||||
|
@ -61,11 +55,6 @@ public class DuckCommand extends CommandClass{
|
|||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> getCommandsAsList() {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<CommandInfo> getSlashCommandInfo() {
|
||||
List<CommandInfo> cil = new ArrayList<>();
|
||||
|
|
|
@ -5,7 +5,6 @@ import moe.oko.Kiafumi.util.CommandInfo;
|
|||
import moe.oko.Kiafumi.util.CommandType;
|
||||
import net.dv8tion.jda.api.EmbedBuilder;
|
||||
import net.dv8tion.jda.api.events.interaction.command.SlashCommandInteractionEvent;
|
||||
import net.dv8tion.jda.api.events.message.MessageReceivedEvent;
|
||||
|
||||
import moe.oko.Kiafumi.util.EmbedUI;
|
||||
import java.time.ZonedDateTime;
|
||||
|
@ -23,11 +22,6 @@ public class InviteCommand extends CommandClass{
|
|||
return "Invite";
|
||||
}
|
||||
|
||||
@Override
|
||||
public void legacyCommand(String[] args, MessageReceivedEvent e, boolean prefix) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void newCommand(String name, SlashCommandInteractionEvent e) {
|
||||
if(e.getGuild() == null) { return; }
|
||||
|
@ -45,11 +39,6 @@ public class InviteCommand extends CommandClass{
|
|||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> getCommandsAsList() {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<CommandInfo> getSlashCommandInfo() {
|
||||
List<CommandInfo> cil = new ArrayList<>();
|
||||
|
|
|
@ -26,23 +26,6 @@ public class PingCommand extends CommandClass{
|
|||
return "Ping";
|
||||
}
|
||||
|
||||
@Override
|
||||
public void legacyCommand(String[] args, MessageReceivedEvent e, boolean prefix) {
|
||||
if(!prefix) { return; }
|
||||
if ("ping".equals(args[0].toLowerCase())) {
|
||||
long sentMs = e.getMessage().getTimeCreated().toInstant().toEpochMilli();
|
||||
long recMs = System.currentTimeMillis();
|
||||
long ping = recMs - sentMs;
|
||||
EmbedBuilder eb = new EmbedBuilder()
|
||||
.setColor(EmbedUI.INFO)
|
||||
.setTitle(getComedy())
|
||||
.setDescription("Pong! " + ping + "ms")
|
||||
.setFooter(EmbedUI.BRAND)
|
||||
.setTimestamp(ZonedDateTime.now());
|
||||
e.getChannel().sendMessageEmbeds(eb.build()).queue();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void newCommand(String name, SlashCommandInteractionEvent e) {
|
||||
if ("ping".equals(name.toLowerCase(Locale.ROOT))) {
|
||||
|
@ -65,10 +48,6 @@ public class PingCommand extends CommandClass{
|
|||
return Kiafumi.instance.config.getPingResponses().get(r.nextInt(Kiafumi.instance.config.getPingResponses().size()));
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> getCommandsAsList() {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<CommandInfo> getSlashCommandInfo() {
|
||||
|
|
|
@ -7,7 +7,6 @@ import moe.oko.Kiafumi.util.CommandType;
|
|||
import moe.oko.Kiafumi.util.EmbedUI;
|
||||
import net.dv8tion.jda.api.EmbedBuilder;
|
||||
import net.dv8tion.jda.api.events.interaction.command.SlashCommandInteractionEvent;
|
||||
import net.dv8tion.jda.api.events.message.MessageReceivedEvent;
|
||||
import net.dv8tion.jda.api.interactions.commands.OptionType;
|
||||
|
||||
import java.time.ZonedDateTime;
|
||||
|
@ -25,11 +24,6 @@ public class SettingCommand extends CommandClass {
|
|||
return "Settings";
|
||||
}
|
||||
|
||||
@Override
|
||||
public void legacyCommand(String[] args, MessageReceivedEvent e, boolean prefix) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void newCommand(String name, SlashCommandInteractionEvent e) {
|
||||
if(e.getGuild() != null) {
|
||||
|
@ -89,16 +83,6 @@ public class SettingCommand extends CommandClass {
|
|||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> getCommandsAsList() {
|
||||
List<String> cmds = new ArrayList<>();
|
||||
cmds.add("settings - displays all available settings for the current guild.");
|
||||
cmds.add("setting - views the current value for the setting.");
|
||||
cmds.add("setting set - sets a setting for the guild you are in.");
|
||||
cmds.add("setting clear - reverts a setting back to its default value.");
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<CommandInfo> getSlashCommandInfo() {
|
||||
List<CommandInfo> si = new ArrayList<>();
|
||||
|
|
|
@ -22,8 +22,6 @@ discord:
|
|||
clientId: ""
|
||||
#Level of permissions for the invite (If you don't know this, use https://discordapi.com/permissions.html) (ADMINISTRATOR is default)
|
||||
invitePermissionLevel: 8
|
||||
#Prefix before bot commands (default is +)
|
||||
prefix: "+"
|
||||
#SHIKINAMI MAIN CONFIG STACK
|
||||
main:
|
||||
#Currently, unimplemented, maybe in the future if performance becomes and issue.
|
||||
|
|
Loading…
Reference in New Issue