-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Localization support for slash commands
Improved most slash commands, deprecated prefix commands and removed fallbacks for slash commands JDA upgrade
- Loading branch information
1 parent
34a8b9f
commit 3d41760
Showing
58 changed files
with
864 additions
and
1,021 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,17 +1,31 @@ | ||
package de.webalf.slotbot.constant; | ||
|
||
import lombok.experimental.UtilityClass; | ||
import lombok.AllArgsConstructor; | ||
import lombok.Getter; | ||
import net.dv8tion.jda.api.entities.emoji.Emoji; | ||
import net.dv8tion.jda.api.entities.emoji.UnicodeEmoji; | ||
|
||
/** | ||
* @author Alf | ||
* @since 15.01.2021 | ||
*/ | ||
@UtilityClass | ||
public class Emojis { | ||
@Getter | ||
@AllArgsConstructor | ||
public enum Emojis { | ||
//Codepoint notation | ||
public static final String THUMBS_UP = "U+1F44D"; | ||
public static final String THUMBS_DOWN = "U+1F44E"; | ||
THUMBS_UP(Emoji.fromUnicode("U+1F44D")), //👍 | ||
THUMBS_DOWN(Emoji.fromUnicode("U+1F44E")), //👎 | ||
CHECKBOX(Emoji.fromUnicode("U+2611")), //☑ | ||
CROSS_MARK(Emoji.fromUnicode("U+274C")); //❌ | ||
|
||
//Standard discord notation | ||
public static final String CHECKBOX = ":ballot_box_with_check:"; | ||
private final UnicodeEmoji emoji; | ||
|
||
/** | ||
* Get emoji as formatted string to be used in messages | ||
* | ||
* @return Formatted string | ||
*/ | ||
public String getFormatted() { | ||
return getEmoji().getFormatted(); | ||
} | ||
} |
26 changes: 0 additions & 26 deletions
26
src/main/java/de/webalf/slotbot/model/annotations/SlashCommand.java
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
34 changes: 34 additions & 0 deletions
34
src/main/java/de/webalf/slotbot/model/annotations/bot/SlashCommand.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
package de.webalf.slotbot.model.annotations.bot; | ||
|
||
import de.webalf.slotbot.service.bot.command.DiscordSlashCommand; | ||
import net.dv8tion.jda.api.Permission; | ||
import org.atteo.classindex.IndexAnnotated; | ||
|
||
import java.lang.annotation.*; | ||
|
||
/** | ||
* @author Alf | ||
* @since 15.07.2021 | ||
*/ | ||
@Retention(RetentionPolicy.RUNTIME) | ||
@Target(ElementType.TYPE) | ||
@Repeatable(SlashCommands.class) | ||
@IndexAnnotated | ||
public @interface SlashCommand { | ||
/** | ||
* Translatable name key | ||
*/ | ||
String name(); | ||
|
||
/** | ||
* Translatable description key | ||
*/ | ||
String description(); | ||
|
||
Permission authorization(); | ||
|
||
/** | ||
* Determines if options are available and which index should be used for {@link DiscordSlashCommand#getOptions(int)} | ||
*/ | ||
int optionPosition() default -1; | ||
} |
2 changes: 1 addition & 1 deletion
2
...tbot/model/annotations/SlashCommands.java → .../model/annotations/bot/SlashCommands.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
23 changes: 23 additions & 0 deletions
23
src/main/java/de/webalf/slotbot/model/bot/TranslatableOptionData.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
package de.webalf.slotbot.model.bot; | ||
|
||
import lombok.Value; | ||
import net.dv8tion.jda.api.interactions.commands.OptionType; | ||
import net.dv8tion.jda.api.interactions.commands.build.OptionData; | ||
|
||
/** | ||
* Copy of {@link OptionData} to support translation keys in name and description | ||
* | ||
* @author Alf | ||
* @since 07.01.2023 | ||
*/ | ||
@Value | ||
public class TranslatableOptionData { | ||
OptionType type; | ||
String name; | ||
String description; | ||
boolean isRequired; | ||
|
||
public OptionData toOptionData(String name, String description) { | ||
return new OptionData(type, name, description, isRequired); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.