summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorTyler Murphy <tylermurphy534@gmail.com>2022-08-22 14:16:35 -0400
committerTyler Murphy <tylermurphy534@gmail.com>2022-08-22 14:16:35 -0400
commit2081810bfe84a1d4ef8d0c6b4e1eaf76a6b831d8 (patch)
tree40bfcf19c8204a7185b548d79ffc5244db2b2cbf /src
parentv1 (diff)
downloadken-2081810bfe84a1d4ef8d0c6b4e1eaf76a6b831d8.tar.gz
ken-2081810bfe84a1d4ef8d0c6b4e1eaf76a6b831d8.tar.bz2
ken-2081810bfe84a1d4ef8d0c6b4e1eaf76a6b831d8.zip
v2
Diffstat (limited to 'src')
-rw-r--r--src/main/java/net/tylermurphy/ken/Ken.java2
-rw-r--r--src/main/java/net/tylermurphy/ken/api/E621API.java28
-rw-r--r--src/main/java/net/tylermurphy/ken/api/HTTPMethod.java (renamed from src/main/java/net/tylermurphy/ken/api/wrapper/HTTPMethod.java)2
-rw-r--r--src/main/java/net/tylermurphy/ken/api/JsonRequest.java (renamed from src/main/java/net/tylermurphy/ken/api/wrapper/JsonRequest.java)2
-rw-r--r--src/main/java/net/tylermurphy/ken/api/Request.java (renamed from src/main/java/net/tylermurphy/ken/api/wrapper/Request.java)2
-rw-r--r--src/main/java/net/tylermurphy/ken/api/Rule34API.java30
-rw-r--r--src/main/java/net/tylermurphy/ken/api/XmlRequest.java (renamed from src/main/java/net/tylermurphy/ken/api/wrapper/XmlRequest.java)2
-rw-r--r--src/main/java/net/tylermurphy/ken/command/Responder.java15
-rw-r--r--src/main/java/net/tylermurphy/ken/command/fun/Dice.java4
-rw-r--r--src/main/java/net/tylermurphy/ken/command/fun/Eject.java4
-rw-r--r--src/main/java/net/tylermurphy/ken/command/main/Help.java90
-rw-r--r--src/main/java/net/tylermurphy/ken/command/main/Purge.java (renamed from src/main/java/net/tylermurphy/ken/command/util/Purge.java)8
-rw-r--r--src/main/java/net/tylermurphy/ken/command/music/ForceSkip.java2
-rw-r--r--src/main/java/net/tylermurphy/ken/command/music/Join.java2
-rw-r--r--src/main/java/net/tylermurphy/ken/command/music/Leave.java2
-rw-r--r--src/main/java/net/tylermurphy/ken/command/music/Loop.java2
-rw-r--r--src/main/java/net/tylermurphy/ken/command/music/LoopQueue.java2
-rw-r--r--src/main/java/net/tylermurphy/ken/command/music/NowPlaying.java2
-rw-r--r--src/main/java/net/tylermurphy/ken/command/music/Pause.java2
-rw-r--r--src/main/java/net/tylermurphy/ken/command/music/Play.java4
-rw-r--r--src/main/java/net/tylermurphy/ken/command/music/Queue.java7
-rw-r--r--src/main/java/net/tylermurphy/ken/command/music/Remove.java4
-rw-r--r--src/main/java/net/tylermurphy/ken/command/music/Resume.java2
-rw-r--r--src/main/java/net/tylermurphy/ken/command/music/Skip.java2
-rw-r--r--src/main/java/net/tylermurphy/ken/command/music/Stop.java2
-rw-r--r--src/main/java/net/tylermurphy/ken/command/nsfw/Akaneko.java51
-rw-r--r--src/main/java/net/tylermurphy/ken/command/nsfw/E621.java28
-rw-r--r--src/main/java/net/tylermurphy/ken/command/nsfw/Rule34.java33
-rw-r--r--src/main/java/net/tylermurphy/ken/command/util/Help.java52
-rw-r--r--src/main/java/net/tylermurphy/ken/util/ButtonCallback.java (renamed from src/main/java/net/tylermurphy/ken/command/ButtonCallback.java)2
-rw-r--r--src/main/java/net/tylermurphy/ken/util/Command.java (renamed from src/main/java/net/tylermurphy/ken/command/Command.java)2
-rw-r--r--src/main/java/net/tylermurphy/ken/util/Option.java (renamed from src/main/java/net/tylermurphy/ken/command/Option.java)2
-rw-r--r--src/main/java/net/tylermurphy/ken/util/Options.java (renamed from src/main/java/net/tylermurphy/ken/command/Options.java)2
-rw-r--r--src/main/java/net/tylermurphy/ken/util/Requirement.java (renamed from src/main/java/net/tylermurphy/ken/command/Requirement.java)2
-rw-r--r--src/main/java/net/tylermurphy/ken/util/Selection.java16
-rw-r--r--src/main/java/net/tylermurphy/ken/util/Selections.java12
36 files changed, 271 insertions, 155 deletions
diff --git a/src/main/java/net/tylermurphy/ken/Ken.java b/src/main/java/net/tylermurphy/ken/Ken.java
index 0481bb6..dbdca83 100644
--- a/src/main/java/net/tylermurphy/ken/Ken.java
+++ b/src/main/java/net/tylermurphy/ken/Ken.java
@@ -39,7 +39,7 @@ public class Ken {
this.log = LoggerFactory.getLogger(Ken.class);
try {
api = JDABuilder.createDefault(config.getString("botToken"))
- .setActivity(Activity.playing("Use "+config.getString("prefix")+"help"))
+ .setActivity(Activity.playing("@Ken | /help"))
.setMemberCachePolicy(MemberCachePolicy.ALL)
.enableIntents(GatewayIntent.GUILD_MEMBERS)
.build()
diff --git a/src/main/java/net/tylermurphy/ken/api/E621API.java b/src/main/java/net/tylermurphy/ken/api/E621API.java
deleted file mode 100644
index 06aa02e..0000000
--- a/src/main/java/net/tylermurphy/ken/api/E621API.java
+++ /dev/null
@@ -1,28 +0,0 @@
-package net.tylermurphy.ken.api;
-
-import net.tylermurphy.ken.api.wrapper.HTTPMethod;
-import net.tylermurphy.ken.api.wrapper.JsonRequest;
-import org.json.JSONArray;
-import org.json.JSONException;
-import org.json.JSONObject;
-
-public class E621API {
-
- public static String request(String query){
- JSONObject json = (JSONObject) new JsonRequest()
- .setURL("https://e621.net/posts.json?tags="+query)
- .setType(HTTPMethod.GET)
- .request();
- try {
- System.out.println(json.toString());
- JSONArray results = json.getJSONArray("posts");
- int choice = (int) (Math.random()*results.length()-1);
- JSONObject post = (JSONObject) results.get(choice);
- JSONObject file = post.getJSONObject("file");
- return file.getString("url");
- } catch (JSONException e) {
- return null;
- }
- }
-
-}
diff --git a/src/main/java/net/tylermurphy/ken/api/wrapper/HTTPMethod.java b/src/main/java/net/tylermurphy/ken/api/HTTPMethod.java
index 094a8c6..e2f29a1 100644
--- a/src/main/java/net/tylermurphy/ken/api/wrapper/HTTPMethod.java
+++ b/src/main/java/net/tylermurphy/ken/api/HTTPMethod.java
@@ -1,4 +1,4 @@
-package net.tylermurphy.ken.api.wrapper;
+package net.tylermurphy.ken.api;
public enum HTTPMethod {
diff --git a/src/main/java/net/tylermurphy/ken/api/wrapper/JsonRequest.java b/src/main/java/net/tylermurphy/ken/api/JsonRequest.java
index f95d23f..59b9991 100644
--- a/src/main/java/net/tylermurphy/ken/api/wrapper/JsonRequest.java
+++ b/src/main/java/net/tylermurphy/ken/api/JsonRequest.java
@@ -1,4 +1,4 @@
-package net.tylermurphy.ken.api.wrapper;
+package net.tylermurphy.ken.api;
import org.json.JSONException;
import org.json.JSONObject;
diff --git a/src/main/java/net/tylermurphy/ken/api/wrapper/Request.java b/src/main/java/net/tylermurphy/ken/api/Request.java
index a5b8e4d..9da2061 100644
--- a/src/main/java/net/tylermurphy/ken/api/wrapper/Request.java
+++ b/src/main/java/net/tylermurphy/ken/api/Request.java
@@ -1,4 +1,4 @@
-package net.tylermurphy.ken.api.wrapper;
+package net.tylermurphy.ken.api;
import java.io.OutputStream;
import java.net.HttpURLConnection;
diff --git a/src/main/java/net/tylermurphy/ken/api/Rule34API.java b/src/main/java/net/tylermurphy/ken/api/Rule34API.java
deleted file mode 100644
index 3c78522..0000000
--- a/src/main/java/net/tylermurphy/ken/api/Rule34API.java
+++ /dev/null
@@ -1,30 +0,0 @@
-package net.tylermurphy.ken.api;
-
-import net.tylermurphy.ken.api.wrapper.HTTPMethod;
-import net.tylermurphy.ken.api.wrapper.XmlRequest;
-import org.json.JSONException;
-import org.w3c.dom.Document;
-import org.w3c.dom.Element;
-import org.w3c.dom.Node;
-import org.w3c.dom.NodeList;
-
-public class Rule34API {
-
- public static String request(String query){
- Document doc = (Document) new XmlRequest()
- .setURL("https://rule34.xxx/index.php?page=dapi&s=post&q=index&tags="+ query)
- .setType(HTTPMethod.GET)
- .request();
- try {
- NodeList nList = doc.getElementsByTagName("post");
- int choice = (int) (Math.random()*nList.getLength()-1);
- if(choice < 0) return null;
- Node node = nList.item(choice);
- Element element = (Element) node;
- return element.getAttribute("file_url");
- } catch (JSONException e) {
- return null;
- }
- }
-
-}
diff --git a/src/main/java/net/tylermurphy/ken/api/wrapper/XmlRequest.java b/src/main/java/net/tylermurphy/ken/api/XmlRequest.java
index 80a755a..e82603d 100644
--- a/src/main/java/net/tylermurphy/ken/api/wrapper/XmlRequest.java
+++ b/src/main/java/net/tylermurphy/ken/api/XmlRequest.java
@@ -1,4 +1,4 @@
-package net.tylermurphy.ken.api.wrapper;
+package net.tylermurphy.ken.api;
import org.w3c.dom.Document;
import org.xml.sax.SAXException;
diff --git a/src/main/java/net/tylermurphy/ken/command/Responder.java b/src/main/java/net/tylermurphy/ken/command/Responder.java
index 2a00ee0..edd7317 100644
--- a/src/main/java/net/tylermurphy/ken/command/Responder.java
+++ b/src/main/java/net/tylermurphy/ken/command/Responder.java
@@ -10,10 +10,12 @@ import net.dv8tion.jda.api.events.interaction.command.SlashCommandInteractionEve
import net.dv8tion.jda.api.events.interaction.component.ButtonInteractionEvent;
import net.dv8tion.jda.api.hooks.ListenerAdapter;
import net.dv8tion.jda.api.interactions.commands.build.Commands;
+import net.dv8tion.jda.api.interactions.commands.build.OptionData;
import net.dv8tion.jda.api.interactions.commands.build.SlashCommandData;
import net.dv8tion.jda.api.interactions.components.buttons.Button;
import net.dv8tion.jda.api.requests.restaction.WebhookMessageAction;
import net.tylermurphy.ken.Ken;
+import net.tylermurphy.ken.util.*;
import org.reflections.Reflections;
import org.reflections.scanners.MethodAnnotationsScanner;
@@ -63,6 +65,19 @@ public class Responder extends ListenerAdapter {
Option option = method.getAnnotation(Option.class);
data = data.addOption(option.type(), option.name(), option.description(), option.required());
}
+ if(method.isAnnotationPresent(Selections.class)){
+ Selection[] selections = method.getAnnotation(Selections.class).value();
+ for(Selection selection : selections){
+ OptionData optionData = new OptionData(selection.type(), selection.name(), selection.description(), selection.required());
+ Arrays.stream(selection.choices()).forEach(choice -> optionData.addChoice(choice, choice.toLowerCase(Locale.ROOT)));
+ data.addOptions(optionData);
+ }
+ } else if(method.isAnnotationPresent(Selection.class)){
+ Selection selection = method.getAnnotation(Selection.class);
+ OptionData optionData = new OptionData(selection.type(), selection.name(), selection.description(), selection.required());
+ Arrays.stream(selection.choices()).forEach(choice -> optionData.addChoice(choice, choice.toLowerCase(Locale.ROOT)));
+ data.addOptions(optionData);
+ }
api.upsertCommand(data).queue();
}
diff --git a/src/main/java/net/tylermurphy/ken/command/fun/Dice.java b/src/main/java/net/tylermurphy/ken/command/fun/Dice.java
index 8bce8bf..54ece6d 100644
--- a/src/main/java/net/tylermurphy/ken/command/fun/Dice.java
+++ b/src/main/java/net/tylermurphy/ken/command/fun/Dice.java
@@ -4,8 +4,8 @@ import net.dv8tion.jda.api.EmbedBuilder;
import net.dv8tion.jda.api.entities.Member;
import net.dv8tion.jda.api.interactions.commands.OptionType;
import net.tylermurphy.ken.Ken;
-import net.tylermurphy.ken.command.Command;
-import net.tylermurphy.ken.command.Option;
+import net.tylermurphy.ken.util.Command;
+import net.tylermurphy.ken.util.Option;
import net.tylermurphy.ken.command.Response;
import java.util.List;
diff --git a/src/main/java/net/tylermurphy/ken/command/fun/Eject.java b/src/main/java/net/tylermurphy/ken/command/fun/Eject.java
index 48a5991..996f228 100644
--- a/src/main/java/net/tylermurphy/ken/command/fun/Eject.java
+++ b/src/main/java/net/tylermurphy/ken/command/fun/Eject.java
@@ -2,8 +2,8 @@ package net.tylermurphy.ken.command.fun;
import net.dv8tion.jda.api.entities.Member;
import net.dv8tion.jda.api.interactions.commands.OptionType;
-import net.tylermurphy.ken.command.Command;
-import net.tylermurphy.ken.command.Option;
+import net.tylermurphy.ken.util.Command;
+import net.tylermurphy.ken.util.Option;
import net.tylermurphy.ken.command.Response;
import net.tylermurphy.ken.image.GifFactory;
diff --git a/src/main/java/net/tylermurphy/ken/command/main/Help.java b/src/main/java/net/tylermurphy/ken/command/main/Help.java
new file mode 100644
index 0000000..08a97f4
--- /dev/null
+++ b/src/main/java/net/tylermurphy/ken/command/main/Help.java
@@ -0,0 +1,90 @@
+package net.tylermurphy.ken.command.main;
+
+import net.dv8tion.jda.api.EmbedBuilder;
+import net.dv8tion.jda.api.entities.Member;
+import net.dv8tion.jda.api.entities.Message;
+import net.dv8tion.jda.api.entities.MessageEmbed;
+import net.tylermurphy.ken.Ken;
+import net.tylermurphy.ken.util.ButtonCallback;
+import net.tylermurphy.ken.util.Command;
+import net.tylermurphy.ken.command.Response;
+
+public class Help {
+
+ private final int PAGES = 5;
+
+ @Command(name="help", description="Gets information about all the commands in the plugin")
+ public Response execute(Member sender){
+ return Response.success(getPage(sender, 1)).addSecondaryButton("help", "previous", "Previous").addSecondaryButton("help", "next", "Next");
+ }
+
+ @ButtonCallback(name="help")
+ public Response onButton(String id, Message message, Member sender){
+ int page;
+ int pages = PAGES;
+ if (message != null && message.getEmbeds().size() > 0 && message.getEmbeds().get(0) != null) {
+ page = Integer.parseInt(message.getEmbeds().get(0).getFooter().getText().split("/")[0].substring(5));
+ } else {
+ page = 0;
+ }
+ if(id.equals("previous"))
+ page = page - 1 < 1 ? pages : page - 1;
+ else
+ page = page + 1 > pages ? 1 : page + 1;
+ return Response.success(getPage(sender, page));
+ }
+
+ private MessageEmbed getPage(Member sender, int page) {
+ String name = Ken.getInstance().getConfig().getString("botName");
+ String supportServer = Ken.getInstance().getConfig().getString("supportServer");
+ EmbedBuilder[] embeds = new EmbedBuilder[]{
+ Ken.getInstance().getDefaultEmbed()
+ .setAuthor(name + " Command List", sender.getAvatarUrl())
+ .appendDescription(
+ "These are all the commands that are included with "+name+"\n" +
+ "Read below to see what each command does, and what parameters the\n" +
+ "command requires. Any questions? Join our [discord support server](https://discord.gg/"+supportServer+")"
+ ).setFooter("Page "+page+"/"+PAGES),
+ Ken.getInstance().getDefaultEmbed()
+ .setAuthor(name + " Command List", sender.getAvatarUrl())
+ .setTitle(":pen_ballpoint: **Main Commands**")
+ .appendDescription("**/help** Gives a list of commands\n")
+ .appendDescription("**/purge <amount>** Purges an amount of messages from a channel\n")
+ .setFooter("Page "+page+"/"+PAGES),
+ Ken.getInstance().getDefaultEmbed()
+ .setAuthor(name + " Command List", sender.getAvatarUrl())
+ .setTitle(":musical_note: **Music Commands**")
+ .appendDescription("**/play <query>** Plays a song in a voice channel\n")
+ .appendDescription("**/join** Make the bot join your audio channel\n")
+ .appendDescription("**/leave** Make the bot leave your audio channel\n")
+ .appendDescription("**/pause** Pause the current playing track\n")
+ .appendDescription("**/resume** Resume the current paused track\n")
+ .appendDescription("**/stop** Stop the current playing track and clear queue\n")
+ .appendDescription("**/skip** Vote to skip the current track\n")
+ .appendDescription("**/forceskip** Force skip the current track\n")
+ .appendDescription("**/loop** Loop the current track\n")
+ .appendDescription("**/loopqueue** Loop the current song queue\n")
+ .appendDescription("**/remove <index>** Remove a song from the queue\n")
+ .appendDescription("**/nowplaying** See what track is currently playing\n")
+ .appendDescription("**/queue** View the current song queue\n")
+ .setFooter("Page "+page+"/"+PAGES),
+ Ken.getInstance().getDefaultEmbed()
+ .setAuthor(name + " Command List", sender.getAvatarUrl())
+ .setTitle(":game_die: **Game Commands**")
+ .appendDescription("**/d6** Roll a d6 die\n")
+ .appendDescription("**/d8** Roll a d8 die\n")
+ .appendDescription("**/d12** Roll a d12 die\n")
+ .appendDescription("**/d20** Roll a d20 die\n")
+ .appendDescription("**/dice <sides>** Roll a dice with set sides\n")
+ .setFooter("Page "+page+"/"+PAGES),
+ Ken.getInstance().getDefaultEmbed()
+ .setAuthor(name + " Command List", sender.getAvatarUrl())
+ .setTitle(":underage: **NSFW Commands**")
+ .appendDescription("**/rule34 <query>** Search on rule34\n")
+ .appendDescription("**/e612 <query>** Search on e621\n")
+ .setFooter("Page "+page+"/"+PAGES)
+ };
+ return embeds[page-1].build();
+ }
+
+}
diff --git a/src/main/java/net/tylermurphy/ken/command/util/Purge.java b/src/main/java/net/tylermurphy/ken/command/main/Purge.java
index 416730f..233c714 100644
--- a/src/main/java/net/tylermurphy/ken/command/util/Purge.java
+++ b/src/main/java/net/tylermurphy/ken/command/main/Purge.java
@@ -1,13 +1,13 @@
-package net.tylermurphy.ken.command.util;
+package net.tylermurphy.ken.command.main;
import net.dv8tion.jda.api.Permission;
import net.dv8tion.jda.api.entities.Guild;
import net.dv8tion.jda.api.entities.GuildMessageChannel;
import net.dv8tion.jda.api.entities.Message;
import net.dv8tion.jda.api.interactions.commands.OptionType;
-import net.tylermurphy.ken.command.Command;
-import net.tylermurphy.ken.command.Option;
-import net.tylermurphy.ken.command.Requirement;
+import net.tylermurphy.ken.util.Command;
+import net.tylermurphy.ken.util.Option;
+import net.tylermurphy.ken.util.Requirement;
import net.tylermurphy.ken.command.Response;
import java.util.List;
diff --git a/src/main/java/net/tylermurphy/ken/command/music/ForceSkip.java b/src/main/java/net/tylermurphy/ken/command/music/ForceSkip.java
index 656e3e9..aea0901 100644
--- a/src/main/java/net/tylermurphy/ken/command/music/ForceSkip.java
+++ b/src/main/java/net/tylermurphy/ken/command/music/ForceSkip.java
@@ -5,7 +5,7 @@ import com.sedmelluq.discord.lavaplayer.track.AudioTrack;
import net.dv8tion.jda.api.entities.*;
import net.dv8tion.jda.api.managers.AudioManager;
import net.tylermurphy.ken.Ken;
-import net.tylermurphy.ken.command.Command;
+import net.tylermurphy.ken.util.Command;
import net.tylermurphy.ken.command.Response;
import net.tylermurphy.ken.music.GuildMusicManager;
import net.tylermurphy.ken.music.MusicPermissions;
diff --git a/src/main/java/net/tylermurphy/ken/command/music/Join.java b/src/main/java/net/tylermurphy/ken/command/music/Join.java
index 217e049..72156c6 100644
--- a/src/main/java/net/tylermurphy/ken/command/music/Join.java
+++ b/src/main/java/net/tylermurphy/ken/command/music/Join.java
@@ -4,7 +4,7 @@ import net.dv8tion.jda.api.Permission;
import net.dv8tion.jda.api.entities.*;
import net.dv8tion.jda.api.managers.AudioManager;
import net.tylermurphy.ken.Ken;
-import net.tylermurphy.ken.command.Command;
+import net.tylermurphy.ken.util.Command;
import net.tylermurphy.ken.command.Response;
import net.tylermurphy.ken.music.GuildMusicManager;
import net.tylermurphy.ken.music.MusicPermissions;
diff --git a/src/main/java/net/tylermurphy/ken/command/music/Leave.java b/src/main/java/net/tylermurphy/ken/command/music/Leave.java
index 1f07901..bb85303 100644
--- a/src/main/java/net/tylermurphy/ken/command/music/Leave.java
+++ b/src/main/java/net/tylermurphy/ken/command/music/Leave.java
@@ -4,7 +4,7 @@ import net.dv8tion.jda.api.entities.AudioChannel;
import net.dv8tion.jda.api.entities.Guild;
import net.dv8tion.jda.api.entities.Member;
import net.dv8tion.jda.api.managers.AudioManager;
-import net.tylermurphy.ken.command.Command;
+import net.tylermurphy.ken.util.Command;
import net.tylermurphy.ken.command.Response;
import net.tylermurphy.ken.music.MusicPermissions;
diff --git a/src/main/java/net/tylermurphy/ken/command/music/Loop.java b/src/main/java/net/tylermurphy/ken/command/music/Loop.java
index 65b31d3..463db3f 100644
--- a/src/main/java/net/tylermurphy/ken/command/music/Loop.java
+++ b/src/main/java/net/tylermurphy/ken/command/music/Loop.java
@@ -6,7 +6,7 @@ import net.dv8tion.jda.api.entities.Guild;
import net.dv8tion.jda.api.entities.Member;
import net.dv8tion.jda.api.managers.AudioManager;
import net.tylermurphy.ken.Ken;
-import net.tylermurphy.ken.command.Command;
+import net.tylermurphy.ken.util.Command;
import net.tylermurphy.ken.command.Response;
import net.tylermurphy.ken.music.GuildMusicManager;
import net.tylermurphy.ken.music.MusicPermissions;
diff --git a/src/main/java/net/tylermurphy/ken/command/music/LoopQueue.java b/src/main/java/net/tylermurphy/ken/command/music/LoopQueue.java
index 6cd79b7..3d160fc 100644
--- a/src/main/java/net/tylermurphy/ken/command/music/LoopQueue.java
+++ b/src/main/java/net/tylermurphy/ken/command/music/LoopQueue.java
@@ -6,7 +6,7 @@ import net.dv8tion.jda.api.entities.Guild;
import net.dv8tion.jda.api.entities.Member;
import net.dv8tion.jda.api.managers.AudioManager;
import net.tylermurphy.ken.Ken;
-import net.tylermurphy.ken.command.Command;
+import net.tylermurphy.ken.util.Command;
import net.tylermurphy.ken.command.Response;
import net.tylermurphy.ken.music.GuildMusicManager;
import net.tylermurphy.ken.music.MusicPermissions;
diff --git a/src/main/java/net/tylermurphy/ken/command/music/NowPlaying.java b/src/main/java/net/tylermurphy/ken/command/music/NowPlaying.java
index 97ebd38..382a258 100644
--- a/src/main/java/net/tylermurphy/ken/command/music/NowPlaying.java
+++ b/src/main/java/net/tylermurphy/ken/command/music/NowPlaying.java
@@ -6,7 +6,7 @@ import net.dv8tion.jda.api.EmbedBuilder;
import net.dv8tion.jda.api.entities.*;
import net.dv8tion.jda.api.managers.AudioManager;
import net.tylermurphy.ken.Ken;
-import net.tylermurphy.ken.command.Command;
+import net.tylermurphy.ken.util.Command;
import net.tylermurphy.ken.command.Response;
import net.tylermurphy.ken.music.GuildMusicManager;
import net.tylermurphy.ken.music.PlayerManager;
diff --git a/src/main/java/net/tylermurphy/ken/command/music/Pause.java b/src/main/java/net/tylermurphy/ken/command/music/Pause.java
index 5077e2a..d8afab7 100644
--- a/src/main/java/net/tylermurphy/ken/command/music/Pause.java
+++ b/src/main/java/net/tylermurphy/ken/command/music/Pause.java
@@ -6,7 +6,7 @@ import net.dv8tion.jda.api.entities.Guild;
import net.dv8tion.jda.api.entities.Member;
import net.dv8tion.jda.api.managers.AudioManager;
import net.tylermurphy.ken.Ken;
-import net.tylermurphy.ken.command.Command;
+import net.tylermurphy.ken.util.Command;
import net.tylermurphy.ken.command.Response;
import net.tylermurphy.ken.music.GuildMusicManager;
import net.tylermurphy.ken.music.MusicPermissions;
diff --git a/src/main/java/net/tylermurphy/ken/command/music/Play.java b/src/main/java/net/tylermurphy/ken/command/music/Play.java
index e32333c..e4341f2 100644
--- a/src/main/java/net/tylermurphy/ken/command/music/Play.java
+++ b/src/main/java/net/tylermurphy/ken/command/music/Play.java
@@ -6,8 +6,8 @@ import net.dv8tion.jda.api.entities.*;
import net.dv8tion.jda.api.interactions.commands.OptionType;
import net.dv8tion.jda.api.managers.AudioManager;
import net.tylermurphy.ken.Ken;
-import net.tylermurphy.ken.command.Command;
-import net.tylermurphy.ken.command.Option;
+import net.tylermurphy.ken.util.Command;
+import net.tylermurphy.ken.util.Option;
import net.tylermurphy.ken.command.Response;
import net.tylermurphy.ken.music.PlayerManager;
diff --git a/src/main/java/net/tylermurphy/ken/command/music/Queue.java b/src/main/java/net/tylermurphy/ken/command/music/Queue.java
index f96815f..32d2fc2 100644
--- a/src/main/java/net/tylermurphy/ken/command/music/Queue.java
+++ b/src/main/java/net/tylermurphy/ken/command/music/Queue.java
@@ -6,10 +6,9 @@ import net.dv8tion.jda.api.EmbedBuilder;
import net.dv8tion.jda.api.entities.Guild;
import net.dv8tion.jda.api.entities.Message;
import net.dv8tion.jda.api.entities.MessageEmbed;
-import net.dv8tion.jda.api.interactions.components.buttons.Button;
import net.tylermurphy.ken.Ken;
-import net.tylermurphy.ken.command.ButtonCallback;
-import net.tylermurphy.ken.command.Command;
+import net.tylermurphy.ken.util.ButtonCallback;
+import net.tylermurphy.ken.util.Command;
import net.tylermurphy.ken.command.Response;
import net.tylermurphy.ken.music.GuildMusicManager;
import net.tylermurphy.ken.music.PlayerManager;
@@ -36,7 +35,7 @@ public class Queue {
PlayerManager playerManager = Ken.getInstance().getPlayerManager();
GuildMusicManager musicManager = playerManager.getGuildMusicManager(guild);
int page, pages;
- if (message != null && message.getEmbeds().get(0) != null) {
+ if (message != null && message.getEmbeds().size() > 0 && message.getEmbeds().get(0) != null) {
page = Integer.parseInt(message.getEmbeds().get(0).getFooter().getText().split("/")[0].substring(5));
pages = Integer.parseInt(message.getEmbeds().get(0).getFooter().getText().split("/")[1]);
} else {
diff --git a/src/main/java/net/tylermurphy/ken/command/music/Remove.java b/src/main/java/net/tylermurphy/ken/command/music/Remove.java
index 3457767..5eaffb6 100644
--- a/src/main/java/net/tylermurphy/ken/command/music/Remove.java
+++ b/src/main/java/net/tylermurphy/ken/command/music/Remove.java
@@ -7,8 +7,8 @@ import net.dv8tion.jda.api.entities.Member;
import net.dv8tion.jda.api.interactions.commands.OptionType;
import net.dv8tion.jda.api.managers.AudioManager;
import net.tylermurphy.ken.Ken;
-import net.tylermurphy.ken.command.Command;
-import net.tylermurphy.ken.command.Option;
+import net.tylermurphy.ken.util.Command;
+import net.tylermurphy.ken.util.Option;
import net.tylermurphy.ken.command.Response;
import net.tylermurphy.ken.music.GuildMusicManager;
import net.tylermurphy.ken.music.MusicPermissions;
diff --git a/src/main/java/net/tylermurphy/ken/command/music/Resume.java b/src/main/java/net/tylermurphy/ken/command/music/Resume.java
index c74e909..b7b8f6a 100644
--- a/src/main/java/net/tylermurphy/ken/command/music/Resume.java
+++ b/src/main/java/net/tylermurphy/ken/command/music/Resume.java
@@ -6,7 +6,7 @@ import net.dv8tion.jda.api.entities.Guild;
import net.dv8tion.jda.api.entities.Member;
import net.dv8tion.jda.api.managers.AudioManager;
import net.tylermurphy.ken.Ken;
-import net.tylermurphy.ken.command.Command;
+import net.tylermurphy.ken.util.Command;
import net.tylermurphy.ken.command.Response;
import net.tylermurphy.ken.music.GuildMusicManager;
import net.tylermurphy.ken.music.MusicPermissions;
diff --git a/src/main/java/net/tylermurphy/ken/command/music/Skip.java b/src/main/java/net/tylermurphy/ken/command/music/Skip.java
index a82e0d5..1fdbf2a 100644
--- a/src/main/java/net/tylermurphy/ken/command/music/Skip.java
+++ b/src/main/java/net/tylermurphy/ken/command/music/Skip.java
@@ -8,7 +8,7 @@ import net.dv8tion.jda.api.entities.GuildMessageChannel;
import net.dv8tion.jda.api.entities.Member;
import net.dv8tion.jda.api.managers.AudioManager;
import net.tylermurphy.ken.Ken;
-import net.tylermurphy.ken.command.Command;
+import net.tylermurphy.ken.util.Command;
import net.tylermurphy.ken.command.Response;
import net.tylermurphy.ken.music.GuildMusicManager;
import net.tylermurphy.ken.music.PlayerManager;
diff --git a/src/main/java/net/tylermurphy/ken/command/music/Stop.java b/src/main/java/net/tylermurphy/ken/command/music/Stop.java
index b942561..29e196f 100644
--- a/src/main/java/net/tylermurphy/ken/command/music/Stop.java
+++ b/src/main/java/net/tylermurphy/ken/command/music/Stop.java
@@ -6,7 +6,7 @@ import net.dv8tion.jda.api.entities.Guild;
import net.dv8tion.jda.api.entities.Member;
import net.dv8tion.jda.api.managers.AudioManager;
import net.tylermurphy.ken.Ken;
-import net.tylermurphy.ken.command.Command;
+import net.tylermurphy.ken.util.Command;
import net.tylermurphy.ken.command.Response;
import net.tylermurphy.ken.music.GuildMusicManager;
import net.tylermurphy.ken.music.MusicPermissions;
diff --git a/src/main/java/net/tylermurphy/ken/command/nsfw/Akaneko.java b/src/main/java/net/tylermurphy/ken/command/nsfw/Akaneko.java
new file mode 100644
index 0000000..648f9e1
--- /dev/null
+++ b/src/main/java/net/tylermurphy/ken/command/nsfw/Akaneko.java
@@ -0,0 +1,51 @@
+package net.tylermurphy.ken.command.nsfw;
+
+import net.dv8tion.jda.api.entities.GuildMessageChannel;
+import net.dv8tion.jda.api.entities.TextChannel;
+import net.dv8tion.jda.api.interactions.commands.OptionType;
+import net.tylermurphy.ken.Ken;
+import net.tylermurphy.ken.api.HTTPMethod;
+import net.tylermurphy.ken.api.JsonRequest;
+import net.tylermurphy.ken.command.Response;
+import net.tylermurphy.ken.util.Command;
+import net.tylermurphy.ken.util.Selection;
+import org.json.JSONException;
+import org.json.JSONObject;
+
+import java.util.List;
+
+public class Akaneko {
+
+ @Command(name="akaneko", description=":underage: Searches for an image off of akaneko")
+ @Selection(name="type", description="Type of post you want to get", type=OptionType.STRING, required=true, choices={"ass","bdsm","cum","hentai","femdom","doujin","maid","orgy","panties","nsfwwallpapers","nsfwmobilewallpapers","netorare","gifs","gif","blowjob","feet","pussy","uglybastard","uniform","gangbang","foxgirl","cumslut","glasses","thighs","tentacles","masturbation","school","yuri","succubus"})
+ public Response execute(GuildMessageChannel channel, List<Object> args){
+ if(!(channel instanceof TextChannel)) {
+ return Response.error("This command can only be used in a text channel");
+ }
+ TextChannel textChannel = (TextChannel) channel;
+ if(!textChannel.isNSFW()){
+ return Response.error("This command can only be used in an NSFW channel");
+ }
+ String url = request((String)args.get(0));
+ if(url == null){
+ return Response.error("Unable to find post with search: "+args.get(0));
+ } else {
+ if(url.endsWith(".mp4") || url.endsWith(".webm"))
+ return Response.success(url);
+ return Response.success(Ken.getInstance().getDefaultEmbed().setImage(url).build());
+ }
+ }
+
+ private String request(String query){
+ JSONObject json = (JSONObject) new JsonRequest()
+ .setURL("https://akaneko-api.herokuapp.com/api/"+query)
+ .setType(HTTPMethod.GET)
+ .request();
+ try {
+ return json.getString("url");
+ } catch (JSONException e) {
+ return null;
+ }
+ }
+
+}
diff --git a/src/main/java/net/tylermurphy/ken/command/nsfw/E621.java b/src/main/java/net/tylermurphy/ken/command/nsfw/E621.java
index 837cca9..b62dec4 100644
--- a/src/main/java/net/tylermurphy/ken/command/nsfw/E621.java
+++ b/src/main/java/net/tylermurphy/ken/command/nsfw/E621.java
@@ -4,10 +4,14 @@ import net.dv8tion.jda.api.entities.GuildMessageChannel;
import net.dv8tion.jda.api.entities.TextChannel;
import net.dv8tion.jda.api.interactions.commands.OptionType;
import net.tylermurphy.ken.Ken;
-import net.tylermurphy.ken.api.E621API;
-import net.tylermurphy.ken.command.Command;
-import net.tylermurphy.ken.command.Option;
+import net.tylermurphy.ken.api.HTTPMethod;
+import net.tylermurphy.ken.api.JsonRequest;
+import net.tylermurphy.ken.util.Command;
+import net.tylermurphy.ken.util.Option;
import net.tylermurphy.ken.command.Response;
+import org.json.JSONArray;
+import org.json.JSONException;
+import org.json.JSONObject;
import java.util.List;
@@ -23,7 +27,7 @@ public class E621 {
if(!textChannel.isNSFW()){
return Response.error("This command can only be used in an NSFW channel");
}
- String url = E621API.request(args.get(0));
+ String url = request(args.get(0));
if(url == null){
return Response.error("Unable to find post with search: "+args.get(0));
} else {
@@ -33,4 +37,20 @@ public class E621 {
}
}
+ private String request(String query){
+ JSONObject json = (JSONObject) new JsonRequest()
+ .setURL("https://e621.net/posts.json?tags="+query)
+ .setType(HTTPMethod.GET)
+ .request();
+ try {
+ JSONArray results = json.getJSONArray("posts");
+ int choice = (int) (Math.random()*results.length()-1);
+ JSONObject post = (JSONObject) results.get(choice);
+ JSONObject file = post.getJSONObject("file");
+ return file.getString("url");
+ } catch (JSONException e) {
+ return null;
+ }
+ }
+
}
diff --git a/src/main/java/net/tylermurphy/ken/command/nsfw/Rule34.java b/src/main/java/net/tylermurphy/ken/command/nsfw/Rule34.java
index e16ec9b..e1d9146 100644
--- a/src/main/java/net/tylermurphy/ken/command/nsfw/Rule34.java
+++ b/src/main/java/net/tylermurphy/ken/command/nsfw/Rule34.java
@@ -4,10 +4,16 @@ import net.dv8tion.jda.api.entities.GuildMessageChannel;
import net.dv8tion.jda.api.entities.TextChannel;
import net.dv8tion.jda.api.interactions.commands.OptionType;
import net.tylermurphy.ken.Ken;
-import net.tylermurphy.ken.api.Rule34API;
-import net.tylermurphy.ken.command.Command;
-import net.tylermurphy.ken.command.Option;
+import net.tylermurphy.ken.api.HTTPMethod;
+import net.tylermurphy.ken.api.XmlRequest;
+import net.tylermurphy.ken.util.Command;
+import net.tylermurphy.ken.util.Option;
import net.tylermurphy.ken.command.Response;
+import org.json.JSONException;
+import org.w3c.dom.Document;
+import org.w3c.dom.Element;
+import org.w3c.dom.Node;
+import org.w3c.dom.NodeList;
import java.util.List;
@@ -15,7 +21,7 @@ public class Rule34 {
@Command(name="rule34",description=":underage: Searches for an image off of rule34")
@Option(name="query",description="Search query for rule34",type=OptionType.STRING,required=true)
- public Response execute(GuildMessageChannel channel, List<String> args){
+ public Response execute(GuildMessageChannel channel, List<Object> args){
if(!(channel instanceof TextChannel)) {
return Response.error("This command can only be used in a text channel");
}
@@ -23,7 +29,7 @@ public class Rule34 {
if(!textChannel.isNSFW()){
return Response.error("This command can only be used in an NSFW channel");
}
- String url = Rule34API.request(args.get(0));
+ String url = request((String)args.get(0));
if(url == null){
return Response.error("Unable to find post with search: "+args.get(0));
} else {
@@ -33,4 +39,21 @@ public class Rule34 {
}
}
+ private String request(String query) {
+ Document doc = (Document) new XmlRequest()
+ .setURL("https://rule34.xxx/index.php?page=dapi&s=post&q=index&tags=" + query)
+ .setType(HTTPMethod.GET)
+ .request();
+ try {
+ NodeList nList = doc.getElementsByTagName("post");
+ int choice = (int) (Math.random() * nList.getLength() - 1);
+ if (choice < 0) return null;
+ Node node = nList.item(choice);
+ Element element = (Element) node;
+ return element.getAttribute("file_url");
+ } catch (JSONException e) {
+ return null;
+ }
+ }
+
}
diff --git a/src/main/java/net/tylermurphy/ken/command/util/Help.java b/src/main/java/net/tylermurphy/ken/command/util/Help.java
deleted file mode 100644
index 278eefb..0000000
--- a/src/main/java/net/tylermurphy/ken/command/util/Help.java
+++ /dev/null
@@ -1,52 +0,0 @@
-package net.tylermurphy.ken.command.util;
-
-import net.dv8tion.jda.api.EmbedBuilder;
-import net.dv8tion.jda.api.entities.Member;
-import net.tylermurphy.ken.Ken;
-import net.tylermurphy.ken.command.Command;
-import net.tylermurphy.ken.command.Response;
-
-public class Help {
-
- @Command(name="help", description="Gets information about all the commands in the plugin")
- public Response execute(Member sender){
- String name = Ken.getInstance().getConfig().getString("botName");
- String supportServer = Ken.getInstance().getConfig().getString("supportServer");
- EmbedBuilder main = Ken.getInstance().getDefaultEmbed()
- .setAuthor(name + " Command List", sender.getAvatarUrl())
- .appendDescription(
- "These are all the commands that are included with "+name+"\n" +
- "Read below to see what each command does, and what parameters the\n" +
- "command requires. Any questions? Join our [discord support server](https://discord.gg/"+supportServer+")"
- );
- EmbedBuilder essential = Ken.getInstance().getDefaultEmbed()
- .setTitle(":pen_ballpoint: **Main Commands**")
- .appendDescription("**/help** Gives a list of commands\n")
- .appendDescription("**/purge <amount>** Purges an amount of messages from a channel\n");
- EmbedBuilder music = Ken.getInstance().getDefaultEmbed()
- .setTitle(":musical_note: **Music Commands**")
- .appendDescription("**/play <query>** Plays a song in a voice channel\n")
- .appendDescription("**/join** Make the bot join your audio channel\n")
- .appendDescription("**/leave** Make the bot leave your audio channel\n")
- .appendDescription("**/pause** Pause the current playing track\n")
- .appendDescription("**/resume** Resume the current paused track\n")
- .appendDescription("**/stop** Stop the current playing track and clear queue\n")
- .appendDescription("**/skip** Vote to skip the current track\n")
- .appendDescription("**/forceskip** Force skip the current track\n")
- .appendDescription("**/loop** Loop the current track\n")
- .appendDescription("**/loopqueue** Loop the current song queue\n")
- .appendDescription("**/remove <index>** Remove a song from the queue\n")
- .appendDescription("**/nowplaying** See what track is currently playing\n")
- .appendDescription("**/queue** View the current song queue\n");
- EmbedBuilder game = Ken.getInstance().getDefaultEmbed()
- .setTitle(":game_die: **Game Commands**")
- .appendDescription("**/d6** Roll a d6 die\n")
- .appendDescription("**/d8** Roll a d8 die\n")
- .appendDescription("**/d12** Roll a d12 die\n")
- .appendDescription("**/d20** Roll a d20 die\n")
- .appendDescription("**/dice <sides>** Roll a dice with set sides\n");
- sender.getUser().openPrivateChannel().complete().sendMessageEmbeds(main.build(), essential.build(), music.build(), game.build()).queue();
- return Response.success(":grey_question: Sent help message. Check your DMs!");
- }
-
-}
diff --git a/src/main/java/net/tylermurphy/ken/command/ButtonCallback.java b/src/main/java/net/tylermurphy/ken/util/ButtonCallback.java
index 7d96dac..83682c0 100644
--- a/src/main/java/net/tylermurphy/ken/command/ButtonCallback.java
+++ b/src/main/java/net/tylermurphy/ken/util/ButtonCallback.java
@@ -1,4 +1,4 @@
-package net.tylermurphy.ken.command;
+package net.tylermurphy.ken.util;
import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;
diff --git a/src/main/java/net/tylermurphy/ken/command/Command.java b/src/main/java/net/tylermurphy/ken/util/Command.java
index 0b961d5..8129555 100644
--- a/src/main/java/net/tylermurphy/ken/command/Command.java
+++ b/src/main/java/net/tylermurphy/ken/util/Command.java
@@ -1,4 +1,4 @@
-package net.tylermurphy.ken.command;
+package net.tylermurphy.ken.util;
import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;
diff --git a/src/main/java/net/tylermurphy/ken/command/Option.java b/src/main/java/net/tylermurphy/ken/util/Option.java
index 09ae9e9..19d1fe4 100644
--- a/src/main/java/net/tylermurphy/ken/command/Option.java
+++ b/src/main/java/net/tylermurphy/ken/util/Option.java
@@ -1,4 +1,4 @@
-package net.tylermurphy.ken.command;
+package net.tylermurphy.ken.util;
import net.dv8tion.jda.api.interactions.commands.OptionType;
diff --git a/src/main/java/net/tylermurphy/ken/command/Options.java b/src/main/java/net/tylermurphy/ken/util/Options.java
index a5ec6fc..a7e9690 100644
--- a/src/main/java/net/tylermurphy/ken/command/Options.java
+++ b/src/main/java/net/tylermurphy/ken/util/Options.java
@@ -1,4 +1,4 @@
-package net.tylermurphy.ken.command;
+package net.tylermurphy.ken.util;
import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;
diff --git a/src/main/java/net/tylermurphy/ken/command/Requirement.java b/src/main/java/net/tylermurphy/ken/util/Requirement.java
index fd59d29..1ffc83c 100644
--- a/src/main/java/net/tylermurphy/ken/command/Requirement.java
+++ b/src/main/java/net/tylermurphy/ken/util/Requirement.java
@@ -1,4 +1,4 @@
-package net.tylermurphy.ken.command;
+package net.tylermurphy.ken.util;
import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;
diff --git a/src/main/java/net/tylermurphy/ken/util/Selection.java b/src/main/java/net/tylermurphy/ken/util/Selection.java
new file mode 100644
index 0000000..4711202
--- /dev/null
+++ b/src/main/java/net/tylermurphy/ken/util/Selection.java
@@ -0,0 +1,16 @@
+package net.tylermurphy.ken.util;
+
+import net.dv8tion.jda.api.interactions.commands.OptionType;
+
+import java.lang.annotation.*;
+
+@Target(ElementType.METHOD)
+@Retention(RetentionPolicy.RUNTIME)
+@Repeatable(Selections.class)
+public @interface Selection {
+ OptionType type();
+ String name();
+ String description();
+ String[] choices();
+ boolean required() default false;
+}
diff --git a/src/main/java/net/tylermurphy/ken/util/Selections.java b/src/main/java/net/tylermurphy/ken/util/Selections.java
new file mode 100644
index 0000000..d49ea32
--- /dev/null
+++ b/src/main/java/net/tylermurphy/ken/util/Selections.java
@@ -0,0 +1,12 @@
+package net.tylermurphy.ken.util;
+
+import java.lang.annotation.ElementType;
+import java.lang.annotation.Retention;
+import java.lang.annotation.RetentionPolicy;
+import java.lang.annotation.Target;
+
+@Target(ElementType.METHOD)
+@Retention(RetentionPolicy.RUNTIME)
+public @interface Selections {
+ Selection[] value();
+} \ No newline at end of file