mirror of
https://github.com/Noratrieb/killua-bot.git
synced 2026-01-15 23:55:02 +01:00
dinge
This commit is contained in:
parent
2319549ff9
commit
70fc06c69e
7 changed files with 195 additions and 108 deletions
|
|
@ -2,11 +2,15 @@ package com.github.nilstrieb.commands.fun;
|
||||||
|
|
||||||
import com.github.nilstrieb.cofig.Config;
|
import com.github.nilstrieb.cofig.Config;
|
||||||
import com.github.nilstrieb.commands.handler.Command;
|
import com.github.nilstrieb.commands.handler.Command;
|
||||||
|
import com.github.nilstrieb.reactions.ReactionEventManager;
|
||||||
|
import com.github.nilstrieb.reactions.ReactionListener;
|
||||||
import com.github.nilstrieb.util.DepartureSong;
|
import com.github.nilstrieb.util.DepartureSong;
|
||||||
import net.dv8tion.jda.api.EmbedBuilder;
|
import net.dv8tion.jda.api.EmbedBuilder;
|
||||||
import net.dv8tion.jda.api.events.message.MessageReceivedEvent;
|
import net.dv8tion.jda.api.events.message.MessageReceivedEvent;
|
||||||
|
import net.dv8tion.jda.api.events.message.react.MessageReactionAddEvent;
|
||||||
|
import net.dv8tion.jda.api.events.message.react.MessageReactionRemoveEvent;
|
||||||
|
|
||||||
public class DepartureCommand extends Command {
|
public class DepartureCommand extends Command implements ReactionListener {
|
||||||
public DepartureCommand() {
|
public DepartureCommand() {
|
||||||
super("departure");
|
super("departure");
|
||||||
}
|
}
|
||||||
|
|
@ -19,5 +23,16 @@ public class DepartureCommand extends Command {
|
||||||
.addField("Youtube Link: ", DepartureSong.DEPARTURE_YOUTUBE_LINK, false);
|
.addField("Youtube Link: ", DepartureSong.DEPARTURE_YOUTUBE_LINK, false);
|
||||||
reply(event, builder.build());
|
reply(event, builder.build());
|
||||||
reply(event, "Lyrics:\n" + DepartureSong.LYRICS_LATIN);
|
reply(event, "Lyrics:\n" + DepartureSong.LYRICS_LATIN);
|
||||||
|
//TODO add message id
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onReactionAdded(MessageReactionAddEvent event) {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onReactionRemoved(MessageReactionRemoveEvent event) {
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -9,6 +9,7 @@ import com.github.nilstrieb.commands.info.EvalCommand;
|
||||||
import com.github.nilstrieb.commands.info.HelpCommand;
|
import com.github.nilstrieb.commands.info.HelpCommand;
|
||||||
import com.github.nilstrieb.commands.info.ToukaCommand;
|
import com.github.nilstrieb.commands.info.ToukaCommand;
|
||||||
import com.github.nilstrieb.listener.CommandListener;
|
import com.github.nilstrieb.listener.CommandListener;
|
||||||
|
import com.github.nilstrieb.listener.ReactionEventListener;
|
||||||
import com.github.nilstrieb.listener.StartUpListener;
|
import com.github.nilstrieb.listener.StartUpListener;
|
||||||
import net.dv8tion.jda.api.JDA;
|
import net.dv8tion.jda.api.JDA;
|
||||||
import net.dv8tion.jda.api.JDABuilder;
|
import net.dv8tion.jda.api.JDABuilder;
|
||||||
|
|
@ -24,7 +25,7 @@ public class Main {
|
||||||
builder.setCompression(Compression.ZLIB);
|
builder.setCompression(Compression.ZLIB);
|
||||||
builder.setActivity(Activity.watching("over Gon"));
|
builder.setActivity(Activity.watching("over Gon"));
|
||||||
|
|
||||||
builder.addEventListeners(new StartUpListener(), new CommandListener());
|
builder.addEventListeners(new StartUpListener(), new CommandListener(), new ReactionEventListener());
|
||||||
|
|
||||||
JDA jda = builder.build();
|
JDA jda = builder.build();
|
||||||
setupCommands();
|
setupCommands();
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,19 @@
|
||||||
|
package com.github.nilstrieb.listener;
|
||||||
|
|
||||||
|
import com.github.nilstrieb.reactions.ReactionEventManager;
|
||||||
|
import net.dv8tion.jda.api.events.message.react.MessageReactionAddEvent;
|
||||||
|
import net.dv8tion.jda.api.events.message.react.MessageReactionRemoveEvent;
|
||||||
|
import net.dv8tion.jda.api.hooks.ListenerAdapter;
|
||||||
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
|
||||||
|
public class ReactionEventListener extends ListenerAdapter {
|
||||||
|
@Override
|
||||||
|
public void onMessageReactionAdd(@NotNull MessageReactionAddEvent event) {
|
||||||
|
ReactionEventManager.onReactionAdd(event);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onMessageReactionRemove(@NotNull MessageReactionRemoveEvent event) {
|
||||||
|
ReactionEventManager.onReactionRemove(event);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,36 @@
|
||||||
|
package com.github.nilstrieb.reactions;
|
||||||
|
|
||||||
|
import net.dv8tion.jda.api.entities.Message;
|
||||||
|
import net.dv8tion.jda.api.events.message.react.MessageReactionAddEvent;
|
||||||
|
import net.dv8tion.jda.api.events.message.react.MessageReactionRemoveEvent;
|
||||||
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
|
||||||
|
import java.util.HashMap;
|
||||||
|
|
||||||
|
public class ReactionEventManager {
|
||||||
|
private static HashMap<String, ReactionListener> currentReactions = new HashMap<>();
|
||||||
|
|
||||||
|
public static void addMessage(Message message, ReactionListener listener){
|
||||||
|
currentReactions.put(message.getId(), listener);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void removeMessage(Message message){
|
||||||
|
currentReactions.remove(message.getId());
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void onReactionAdd(MessageReactionAddEvent event){
|
||||||
|
String message = event.getMessageId();
|
||||||
|
ReactionListener listener = currentReactions.get(message);
|
||||||
|
if (listener != null) {
|
||||||
|
listener.onReactionAdded(event);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void onReactionRemove(MessageReactionRemoveEvent event){
|
||||||
|
String message = event.getMessageId();
|
||||||
|
ReactionListener listener = currentReactions.get(message);
|
||||||
|
if (listener != null) {
|
||||||
|
listener.onReactionRemoved(event);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,9 @@
|
||||||
|
package com.github.nilstrieb.reactions;
|
||||||
|
|
||||||
|
import net.dv8tion.jda.api.events.message.react.MessageReactionAddEvent;
|
||||||
|
import net.dv8tion.jda.api.events.message.react.MessageReactionRemoveEvent;
|
||||||
|
|
||||||
|
public interface ReactionListener {
|
||||||
|
void onReactionAdded(MessageReactionAddEvent event);
|
||||||
|
void onReactionRemoved(MessageReactionRemoveEvent event);
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,7 @@
|
||||||
|
package com.github.nilstrieb.util;
|
||||||
|
|
||||||
|
public class MultiPageEmbed {
|
||||||
|
public static final String NEXT_PAGE_DEFAULT_REACTION = "";
|
||||||
|
public static final String PREVIOUS_PAGE_DEFAULT_REACTION = "";
|
||||||
|
//TODO implement
|
||||||
|
}
|
||||||
Loading…
Add table
Add a link
Reference in a new issue