This commit is contained in:
@@ -9,10 +9,12 @@ import java.util.Objects;
|
||||
|
||||
public record MessageResponse(@Nullable String content,
|
||||
@Nullable MessageEmbed embed,
|
||||
@Nullable ItemComponent... components) {
|
||||
@Nullable ItemComponent... components)
|
||||
{
|
||||
|
||||
@Override
|
||||
public boolean equals(Object o) {
|
||||
public boolean equals(Object o)
|
||||
{
|
||||
if (this == o) return true;
|
||||
if (o == null || getClass() != o.getClass()) return false;
|
||||
MessageResponse response = (MessageResponse) o;
|
||||
@@ -22,14 +24,16 @@ public record MessageResponse(@Nullable String content,
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
public int hashCode()
|
||||
{
|
||||
int result = Objects.hash(content, embed);
|
||||
result = 31 * result + Arrays.hashCode(components);
|
||||
return result;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
public String toString()
|
||||
{
|
||||
return "MessageResponse{" +
|
||||
"content=" + content +
|
||||
", embed=" + embed +
|
||||
|
@@ -9,10 +9,14 @@ public enum CommandCategory
|
||||
;
|
||||
|
||||
private String emoji;
|
||||
|
||||
CommandCategory(String emoji)
|
||||
{
|
||||
this.emoji = emoji;
|
||||
}
|
||||
|
||||
public String getEmoji() { return emoji; }
|
||||
public String getEmoji()
|
||||
{
|
||||
return emoji;
|
||||
}
|
||||
}
|
||||
|
@@ -70,12 +70,10 @@ public interface MessageCommand
|
||||
*
|
||||
* @param event the received message event. It should not be used for parsing message contents data as
|
||||
* the arguments already account for it in a better way.
|
||||
*
|
||||
* @param label the command label that was used, taken from all available command aliases.
|
||||
*
|
||||
* @param args a pre-formatted list of arguments, excluding the bot prefix and the command name.
|
||||
* This is useful because command logic won't have to change in case the bot prefix is changed,
|
||||
* removed, or we switch to another method of triggering commands (ping, trigger words, ...).
|
||||
* @param args a pre-formatted list of arguments, excluding the bot prefix and the command name.
|
||||
* This is useful because command logic won't have to change in case the bot prefix is changed,
|
||||
* removed, or we switch to another method of triggering commands (ping, trigger words, ...).
|
||||
*/
|
||||
void runCommand(MessageReceivedEvent event, String label, String[] args);
|
||||
}
|
||||
|
@@ -12,6 +12,7 @@ public interface SlashArgumentsCompleter
|
||||
* @return the command object.
|
||||
*/
|
||||
SlashCommand getCommand();
|
||||
|
||||
/**
|
||||
* Run the argument-completion logic by parsing the event and replying accordingly.
|
||||
*
|
||||
|
@@ -6,13 +6,16 @@ import org.jetbrains.annotations.NotNull;
|
||||
public class SlashArgumentsCompleterImpl implements SlashArgumentsCompleter
|
||||
{
|
||||
private final SlashCommand parentCommand;
|
||||
|
||||
public SlashArgumentsCompleterImpl(SlashCommand parentCommand)
|
||||
{
|
||||
this.parentCommand = parentCommand;
|
||||
}
|
||||
|
||||
public SlashCommand getCommand()
|
||||
{ return parentCommand; }
|
||||
{
|
||||
return parentCommand;
|
||||
}
|
||||
|
||||
public void runCompletion(@NotNull CommandAutoCompleteInteractionEvent event)
|
||||
{
|
||||
|
@@ -21,6 +21,7 @@ public interface SlashCommand
|
||||
* @return the command data object.
|
||||
*/
|
||||
CommandData getSlashCommandData();
|
||||
|
||||
/**
|
||||
* Run the command logic by parsing the event and replying accordingly.
|
||||
*
|
||||
|
@@ -8,17 +8,20 @@ public class SlashCommandImpl implements SlashCommand
|
||||
{
|
||||
|
||||
@Override
|
||||
public String getCommandName() {
|
||||
public String getCommandName()
|
||||
{
|
||||
return getSlashCommandData().getName();
|
||||
}
|
||||
|
||||
@Override
|
||||
public CommandData getSlashCommandData() {
|
||||
public CommandData getSlashCommandData()
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void runSlashCommand(@NotNull SlashCommandInteractionEvent event) {
|
||||
public void runSlashCommand(@NotNull SlashCommandInteractionEvent event)
|
||||
{
|
||||
event.reply("Base command implementation").queue();
|
||||
}
|
||||
}
|
||||
|
@@ -6,13 +6,15 @@ import java.util.LinkedList;
|
||||
/**
|
||||
* This class gets two linked lists, and compares their first value alphabetically.
|
||||
*/
|
||||
public class MessageCommandAliasesComparator implements Comparator<LinkedList<String>> {
|
||||
public class MessageCommandAliasesComparator implements Comparator<LinkedList<String>>
|
||||
{
|
||||
|
||||
@Override
|
||||
public int compare(LinkedList<String> linkedList, LinkedList<String> t1) {
|
||||
public int compare(LinkedList<String> linkedList, LinkedList<String> t1)
|
||||
{
|
||||
|
||||
if(linkedList.isEmpty()) return 0;
|
||||
if(t1.isEmpty()) return 0;
|
||||
if (linkedList.isEmpty()) return 0;
|
||||
if (t1.isEmpty()) return 0;
|
||||
|
||||
return linkedList.get(0).compareTo(t1.get(0));
|
||||
}
|
||||
|
@@ -7,10 +7,12 @@ import java.util.Comparator;
|
||||
/**
|
||||
* This class gets two trivia categories, and compares them by their name.
|
||||
*/
|
||||
public class TriviaCategoryComparator implements Comparator<TriviaCategory> {
|
||||
public class TriviaCategoryComparator implements Comparator<TriviaCategory>
|
||||
{
|
||||
|
||||
@Override
|
||||
public int compare(TriviaCategory o1, TriviaCategory o2) {
|
||||
public int compare(TriviaCategory o1, TriviaCategory o2)
|
||||
{
|
||||
return CharSequence.compare(o1.categoryName(), o2.categoryName());
|
||||
}
|
||||
}
|
||||
|
@@ -7,10 +7,12 @@ import java.util.Comparator;
|
||||
/**
|
||||
* This class gets two trivia scores, and compares their score.
|
||||
*/
|
||||
public class TriviaScoreComparator implements Comparator<TriviaScore> {
|
||||
public class TriviaScoreComparator implements Comparator<TriviaScore>
|
||||
{
|
||||
|
||||
@Override
|
||||
public int compare(TriviaScore o1, TriviaScore o2) {
|
||||
public int compare(TriviaScore o1, TriviaScore o2)
|
||||
{
|
||||
return Integer.compare(o2.getScore(), o1.getScore()); // inverted, because higher number should come first
|
||||
}
|
||||
}
|
||||
|
@@ -1,5 +1,6 @@
|
||||
package wtf.beatrice.hidekobot.objects.fun;
|
||||
|
||||
public record TriviaCategory(String categoryName, int categoryId) {
|
||||
public record TriviaCategory(String categoryName, int categoryId)
|
||||
{
|
||||
|
||||
}
|
||||
|
@@ -3,6 +3,7 @@ package wtf.beatrice.hidekobot.objects.fun;
|
||||
import java.util.List;
|
||||
|
||||
public record TriviaQuestion(String question, String correctAnswer,
|
||||
List<String> wrongAnswers) {
|
||||
List<String> wrongAnswers)
|
||||
{
|
||||
|
||||
}
|
||||
|
@@ -18,9 +18,15 @@ public class TriviaScore
|
||||
score += add;
|
||||
}
|
||||
|
||||
public int getScore() { return score; }
|
||||
public int getScore()
|
||||
{
|
||||
return score;
|
||||
}
|
||||
|
||||
public User getUser() { return user; }
|
||||
public User getUser()
|
||||
{
|
||||
return user;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString()
|
||||
|
Reference in New Issue
Block a user