Skip to content

Commit

Permalink
Release 2.9.0 (#174)
Browse files Browse the repository at this point in the history
  • Loading branch information
rainbowdashlabs authored Jan 17, 2024
2 parents 4d07374 + 063cec9 commit bc6e754
Show file tree
Hide file tree
Showing 21 changed files with 420 additions and 104 deletions.
8 changes: 4 additions & 4 deletions .github/workflows/javadocs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,16 +3,16 @@ name: Javadocs
on:
push:
branches:
- master
- main
workflow_dispatch:

jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
- name: Set up JDK 17
uses: actions/setup-java@v3
uses: actions/setup-java@v4
with:
distribution: adopt
java-version: 17
Expand All @@ -25,7 +25,7 @@ jobs:
echo "Creating .nojekyll to have Github pages deploy html as is:"
touch .nojekyll
- name: Deploy
uses: JamesIves/github-pages-deploy-action@v4.4.2
uses: JamesIves/github-pages-deploy-action@v4
with:
branch: gh-pages # The branch the action should deploy to.
folder: build/docs/javadoc # The folder the action should deploy.
6 changes: 3 additions & 3 deletions .github/workflows/publish_to_nexus.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ name: Publish to Nexus
on:
push:
branches:
- master
- main
- dev*
- feature/*
- fix/*
Expand All @@ -13,9 +13,9 @@ jobs:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
- name: Set up JDK 17
uses: actions/setup-java@v3
uses: actions/setup-java@v4
with:
java-version: 17
distribution: adopt
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/verify.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,9 @@ jobs:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
- name: Set up JDK 17
uses: actions/setup-java@v3
uses: actions/setup-java@v4
with:
java-version: 17
distribution: adopt
Expand Down
18 changes: 9 additions & 9 deletions build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ plugins {
java
`maven-publish`
`java-library`
id("de.chojo.publishdata") version "1.2.4"
id("de.chojo.publishdata") version "1.3.0"
id("org.cadixdev.licenser") version "0.6.1"
}

Expand All @@ -14,22 +14,22 @@ repositories {
}

dependencies {
api("net.dv8tion", "JDA", "5.0.0-beta.11")
api("org.apache.commons", "commons-text", "1.10.0")
api("club.minnced", "discord-webhooks", "0.8.2")
api("net.dv8tion", "JDA", "5.0.0-beta.19")
api("org.apache.commons", "commons-text", "1.11.0")
api("club.minnced", "discord-webhooks", "0.8.4")

// Serialization
api("com.google.guava", "guava", "32.0.1-jre")
api("com.fasterxml.jackson.core", "jackson-databind", "2.15.2")
api("com.google.guava", "guava", "32.1.3-jre")
api("com.fasterxml.jackson.core", "jackson-databind", "2.16.1")

// web api
api("io.javalin", "javalin", "4.6.8")
api("io.javalin", "javalin-openapi", "4.6.8")

// unit testing
testImplementation(platform("org.junit:junit-bom:5.9.3"))
testImplementation(platform("org.junit:junit-bom:5.10.1"))
testImplementation("org.junit.jupiter", "junit-jupiter")
testImplementation("org.mockito", "mockito-core", "5.3.1")
testImplementation("org.mockito", "mockito-core", "5.9.0")
}

license {
Expand All @@ -38,7 +38,7 @@ license {
}

group = "de.chojo"
version = "2.8.6+beta.11"
version = "2.9.0+beta.19"
description = "Discord utilities for use with JDA"

publishData {
Expand Down
Binary file modified gradle/wrapper/gradle-wrapper.jar
Binary file not shown.
3 changes: 2 additions & 1 deletion gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-8.1.1-bin.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-8.5-bin.zip
networkTimeout=10000
validateDistributionUrl=true
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
22 changes: 13 additions & 9 deletions gradlew
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,8 @@ done
# This is normally unused
# shellcheck disable=SC2034
APP_BASE_NAME=${0##*/}
APP_HOME=$( cd "${APP_HOME:-./}" && pwd -P ) || exit
# Discard cd standard output in case $CDPATH is set (https://github.com/gradle/gradle/issues/25036)
APP_HOME=$( cd "${APP_HOME:-./}" > /dev/null && pwd -P ) || exit

# Use the maximum available, or set MAX_FD != -1 to use that value.
MAX_FD=maximum
Expand Down Expand Up @@ -130,26 +131,29 @@ location of your Java installation."
fi
else
JAVACMD=java
which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
if ! command -v java >/dev/null 2>&1
then
die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
Please set the JAVA_HOME variable in your environment to match the
location of your Java installation."
fi
fi

# Increase the maximum file descriptors if we can.
if ! "$cygwin" && ! "$darwin" && ! "$nonstop" ; then
case $MAX_FD in #(
max*)
# In POSIX sh, ulimit -H is undefined. That's why the result is checked to see if it worked.
# shellcheck disable=SC3045
# shellcheck disable=SC2039,SC3045
MAX_FD=$( ulimit -H -n ) ||
warn "Could not query maximum file descriptor limit"
esac
case $MAX_FD in #(
'' | soft) :;; #(
*)
# In POSIX sh, ulimit -n is undefined. That's why the result is checked to see if it worked.
# shellcheck disable=SC3045
# shellcheck disable=SC2039,SC3045
ulimit -n "$MAX_FD" ||
warn "Could not set maximum file descriptor limit to $MAX_FD"
esac
Expand Down Expand Up @@ -198,11 +202,11 @@ fi
# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"'

# Collect all arguments for the java command;
# * $DEFAULT_JVM_OPTS, $JAVA_OPTS, and $GRADLE_OPTS can contain fragments of
# shell script including quotes and variable substitutions, so put them in
# double quotes to make sure that they get re-expanded; and
# * put everything else in single quotes, so that it's not re-expanded.
# Collect all arguments for the java command:
# * DEFAULT_JVM_OPTS, JAVA_OPTS, JAVA_OPTS, and optsEnvironmentVar are not allowed to contain shell fragments,
# and any embedded shellness will be escaped.
# * For example: A user cannot expect ${Hostname} to be expanded, as it is an environment variable and will be
# treated as '${Hostname}' itself on the command line.

set -- \
"-Dorg.gradle.appname=$APP_BASE_NAME" \
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ public CommandData toCommandData(ILocalizer localizer) {
.setDefaultPermissions(meta.permission())
.setDefaultPermissions(meta.permission());
if (meta.localized()) {
message.setNameLocalizations(localizer.prefixedLocalizer("user").apply(localeKey()));
message.setNameLocalizations(localizer.prefixedLocalizer("message").apply(localeKey()));
}
return message;
}
Expand Down
3 changes: 3 additions & 0 deletions src/main/java/de/chojo/jdautil/interactions/slash/Group.java
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,9 @@ public Group(RouteMeta routeMeta, List<SubCommand> subCommands) {
public static PartialGroupBuilder of(String name, String description) {
return GroupBuilder.of(name, description);
}
public static PartialGroupBuilder group(String name, String description) {
return of(name, description);
}

@Override
public RouteMeta meta() {
Expand Down
3 changes: 3 additions & 0 deletions src/main/java/de/chojo/jdautil/interactions/slash/Slash.java
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,9 @@ public Slash(CommandMeta meta, SlashHandler handler, List<Group> groups, List<Su
public static RootMetaBuilder of(String name, String description) {
return new SlashBuilder(name, description);
}
public static RootMetaBuilder slash(String name, String description) {
return of(name, description);
}

public Collection<Collection<? extends Route<RouteMeta>>> routes() {
return List.of(groups, leaves);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,13 @@ public static SubCommandBuilder of(String name, String description, SlashHandler
public static PartialSubCommandBuilder of(String name, String description) {
return SubCommandBuilder.partial(name, description);
}
public static SubCommandBuilder sub(String name, String description, SlashHandler handler) {
return of(name, description, handler);
}

public static PartialSubCommandBuilder sub(String name, String description) {
return of(name, description);
}

public RouteMeta meta() {
return meta;
Expand Down
4 changes: 2 additions & 2 deletions src/main/java/de/chojo/jdautil/localization/Localizer.java
Original file line number Diff line number Diff line change
Expand Up @@ -125,8 +125,8 @@ public String localize(String message, DiscordLocale language, Replacement... re
}

private String translate(String message, DiscordLocale language, Replacement... replacements) {
if (message == null) {
return null;
if (message == null || message.isBlank()) {
return message;
}
String result;
// If the matcher doesn't find any key we assume its a simple message.
Expand Down
22 changes: 18 additions & 4 deletions src/main/java/de/chojo/jdautil/menus/MenuAction.java
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
import net.dv8tion.jda.api.interactions.callbacks.IReplyCallback;
import net.dv8tion.jda.api.interactions.components.ActionRow;
import net.dv8tion.jda.api.utils.messages.MessageCreateData;
import net.dv8tion.jda.api.utils.messages.MessageEditData;
import org.jetbrains.annotations.Nullable;

import java.util.List;
Expand All @@ -34,7 +35,7 @@ public class MenuAction {
@Nullable
private final Guild guild;

public MenuAction(MessageCreateData message, IReplyCallback callback, MessageChannel channel, Guild guild, boolean ephemeral, User user, List<de.chojo.jdautil.menus.entries.MenuEntry<?, ?>> components) {
public MenuAction(MessageCreateData message, @Nullable IReplyCallback callback, @Nullable MessageChannel channel, Guild guild, boolean ephemeral, User user, List<de.chojo.jdautil.menus.entries.MenuEntry<?, ?>> components) {
this.message = message;
this.callback = callback;
this.channel = channel;
Expand All @@ -59,8 +60,11 @@ public void send(ILocalizer localizer, long id) {
}

if (callback != null) {
callback.reply(message)
.setEphemeral(ephemeral)
if (!callback.isAcknowledged()) {
callback.deferReply(ephemeral).complete();
}
callback.getHook()
.editOriginal(MessageEditData.fromCreateData(message))
.setComponents(rows)
.queue();
}
Expand All @@ -77,7 +81,7 @@ public User user() {
/**
* Create a new action for a callback
*
* @param embed message to send
* @param embed message to send
* @param channel the channel to send the message to
* @return new action builder
*/
Expand Down Expand Up @@ -117,6 +121,16 @@ public static MenuActionBuilder forCallback(MessageEmbed embed, IReplyCallback c
public static MenuActionBuilder forCallback(String message, IReplyCallback callback) {
return new MenuActionBuilder(MessageCreateData.fromContent(message), callback);
}
/**
* Create a new action for a callback
*
* @param message message to send
* @param callback the callback to respond to
* @return new action builder
*/
public static MenuActionBuilder forCallback(MessageCreateData message, IReplyCallback callback) {
return new MenuActionBuilder(message, callback);
}

public Guild guild() {
return guild;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,15 @@ public ButtonEntry(Button component, Consumer<EntryContext<ButtonInteractionEven

@Override
public ActionComponent component(long id, LocalizationContext localizer) {
if(component().getId() == null){
if (component().getId() == null) {
if(component().getLabel().isBlank()){
return component();
}
return component().withLabel(localizer.localize(component().getLabel()));
}
if (component().getLabel().isBlank()) {
return component().withId(String.format("%s:%s", id, component().getId()));
}
return component().withId(String.format("%s:%s", id, component().getId()))
.withLabel(localizer.localize(component().getLabel()));
}
Expand Down
Loading

0 comments on commit bc6e754

Please sign in to comment.