Skip to content

Commit

Permalink
formatting
Browse files Browse the repository at this point in the history
  • Loading branch information
Kaktushose committed Dec 4, 2024
1 parent 2d0dc0d commit 6d9eb8b
Show file tree
Hide file tree
Showing 20 changed files with 118 additions and 118 deletions.
4 changes: 2 additions & 2 deletions src/main/java/com/github/kaktushose/jda/commands/Helpers.java
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@

public final class Helpers {

private static final Logger log = LoggerFactory.getLogger(com.github.kaktushose.jda.commands.Helpers.class);
private static final Logger log = LoggerFactory.getLogger(Helpers.class);

/**
* Sanitizes a String containing a raw mention. This will remove all markdown characters namely <em>< @ # & ! ></em>
Expand Down Expand Up @@ -68,7 +68,7 @@ public static boolean isIncorrectParameterType(Method method, int index, Class<?
log.error("An error has occurred! Skipping Interaction {}.{}:",
method.getDeclaringClass().getSimpleName(),
method.getName(),
new IllegalArgumentException(String.format("%d. parameter must be of type %s", index+1, type.getSimpleName())));
new IllegalArgumentException(String.format("%d. parameter must be of type %s", index + 1, type.getSimpleName())));
return true;
}
return false;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,8 @@ public List<Guild> getGuilds() {
return switch (context) {
case ShardManager shardManager -> shardManager.getGuilds();
case JDA jda -> jda.getGuilds();
default -> throw new IllegalArgumentException(String.format("Cannot cast %s", context.getClass().getSimpleName()));
default ->
throw new IllegalArgumentException(String.format("Cannot cast %s", context.getClass().getSimpleName()));
};
}

Expand All @@ -69,7 +70,8 @@ public SnowflakeCacheView<Guild> getGuildCache() {
return switch (context) {
case ShardManager shardManager -> shardManager.getGuildCache();
case JDA jda -> jda.getGuildCache();
default -> throw new IllegalArgumentException(String.format("Cannot cast %s", context.getClass().getSimpleName()));
default ->
throw new IllegalArgumentException(String.format("Cannot cast %s", context.getClass().getSimpleName()));
};
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,6 @@ public class SlashCommandUpdater {

/**
* Constructs a new SlashCommandUpdater.
*
*/
public SlashCommandUpdater(JDAContext jdaContext, GuildScopeProvider guildScopeProvider, InteractionRegistry interactionRegistry) {
this.jdaContext = jdaContext;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ public class SlashCommandContext extends Context {
/**
* Constructs a new CommandContext.
*
* @param event the corresponding {@link SlashCommandInteractionEvent}
* @param event the corresponding {@link SlashCommandInteractionEvent}
*/
public SlashCommandContext(SlashCommandInteractionEvent event, InteractionRegistry interactionRegistry, ImplementationRegistry implementationRegistry) {
super(event, interactionRegistry, implementationRegistry);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@ public class MiddlewareRegistry {

/**
* Constructs a new MiddlewareRegistry.
*
*/
public MiddlewareRegistry() {
middlewares = new HashMap<>();
Expand All @@ -37,8 +36,8 @@ public MiddlewareRegistry() {
/**
* Register {@link Middleware Middleware(s)} with the given {@link Priority}.
*
* @param priority the {@link Priority} to register the {@link Middleware Middleware(s)} with
* @param first the first {@link Middleware} to register
* @param priority the {@link Priority} to register the {@link Middleware Middleware(s)} with
* @param first the first {@link Middleware} to register
* @param middlewares additional {@link Middleware Middlewares} to register
* @return this instance for fluent interface
*/
Expand All @@ -50,7 +49,7 @@ public MiddlewareRegistry register(Priority priority, Middleware first, Middlewa
/**
* Register {@link Middleware Middleware(s)} with the given {@link Priority}.
*
* @param priority the {@link Priority} to register the {@link Middleware Middleware(s)} with
* @param priority the {@link Priority} to register the {@link Middleware Middleware(s)} with
* @param middlewares the {@link Middleware Middleware(s)} to register
* @return this instance for fluent interface
*/
Expand All @@ -63,8 +62,8 @@ public MiddlewareRegistry register(Priority priority, Collection<Middleware> mid
/**
* Unregister {@link Middleware Middleware(s)} with the given {@link Priority}.
*
* @param priority the {@link Priority} to unregister the {@link Middleware Middleware(s)} with
* @param first the first {@link Middleware} to unregister
* @param priority the {@link Priority} to unregister the {@link Middleware Middleware(s)} with
* @param first the first {@link Middleware} to unregister
* @param middlewares additional {@link Middleware Middlewares} to unregister
* @return this instance for fluent interface
*/
Expand All @@ -76,7 +75,7 @@ public MiddlewareRegistry unregister(Priority priority, Middleware first, Middle
/**
* Unregister {@link Middleware Middleware(s)} with the given {@link Priority}.
*
* @param priority the {@link Priority} to unregister the {@link Middleware Middleware(s)} with
* @param priority the {@link Priority} to unregister the {@link Middleware Middleware(s)} with
* @param middlewares the {@link Middleware Middleware(s)} to unregister
* @return this instance for fluent interface
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
* @see Replyable#with(Component...)
* @since 2.3.0
*/
public record Buttons(Collection<ButtonContainer> buttonContainers) implements Component {
public record Buttons(Collection<ButtonContainer> buttonContainers) implements Component {

public Buttons(Collection<ButtonContainer> buttonContainers) {
this.buttonContainers = Collections.unmodifiableCollection(buttonContainers);
Expand Down Expand Up @@ -54,5 +54,6 @@ private static Buttons build(boolean enabled, String... buttons) {
/**
* Contains information about a single {@link com.github.kaktushose.jda.commands.annotations.interactions.Button Button}.
*/
public record ButtonContainer(String name, boolean enabled) { }
public record ButtonContainer(String name, boolean enabled) {
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -120,8 +120,8 @@ public MessageCreateData getCommandExecutionFailedMessage(@NotNull Context conte
return super.getCommandExecutionFailedMessage(context, exception);
}
String error = String.format("```The user \"%s\" attempted to execute an \"%s\" interaction at %s, " +
"but a \"%s\" occurred. " +
"Please refer to the logs for further information.```",
"but a \"%s\" occurred. " +
"Please refer to the logs for further information.```",
context.getEvent().getUser().toString(),
context.getEvent().getInteraction().getType(),
new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(System.currentTimeMillis()),
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
package com.github.kaktushose.jda.commands.reflect;

import com.github.kaktushose.jda.commands.dispatching.validation.Validator;
import org.jetbrains.annotations.NotNull;

/**
* Representation of parameter constraint.
Expand All @@ -10,4 +9,5 @@
* @see Validator
* @since 2.0.0
*/
public record ConstraintDefinition(Validator validator, String message, Object annotation) {}
public record ConstraintDefinition(Validator validator, String message, Object annotation) {
}
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
public record CooldownDefinition(
long delay,
TimeUnit timeUnit
){
) {
/**
* Builds a new CooldownDefinition.
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,4 +18,5 @@ public record MethodBuildContext(
CooldownDefinition cooldownDefinition,
Method method,
Collection<AutoCompleteDefinition> autoCompleteDefinitions
) {}
) {
}
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@
import net.dv8tion.jda.api.interactions.commands.OptionType;
import net.dv8tion.jda.api.interactions.commands.build.OptionData;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;

import java.lang.annotation.Annotation;
import java.lang.reflect.InvocationTargetException;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ public static Optional<AutoCompleteDefinition> build(@NotNull Method method) {
return Optional.empty();
}

if (com.github.kaktushose.jda.commands.Helpers.isIncorrectParameterType(method, 0, AutoCompleteEvent.class)) {
if (Helpers.isIncorrectParameterType(method, 0, AutoCompleteEvent.class)) {
return Optional.empty();
}

Expand All @@ -63,9 +63,9 @@ public Set<String> getCommandNames() {
@Override
public String toString() {
return "AutoCompleteDefinition{" +
"commands=" + commands +
", id='" + definitionId + "'" +
", method=" + method +
'}';
"commands=" + commands +
", id='" + definitionId + "'" +
", method=" + method +
'}';
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -131,12 +131,12 @@ public String createCustomId(String runtimeId) {
@Override
public String toString() {
return "ModalDefinition{" +
"title='" + title + '\'' +
", textInputs=" + textInputs +
", ephemeral=" + ephemeral +
", id='" + definitionId + '\'' +
", method=" + method +
", permissions=" + permissions +
'}';
"title='" + title + '\'' +
", textInputs=" + textInputs +
", ephemeral=" + ephemeral +
", id='" + definitionId + '\'' +
", method=" + method +
", permissions=" + permissions +
'}';
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ public static Optional<ContextCommandDefinition> build(@NotNull MethodBuildConte
method,
Helpers.ephemeral(context, command.ephemeral()),
command.value(),
com.github.kaktushose.jda.commands.Helpers.permissions(context),
Helpers.permissions(context),
command.isGuildOnly(),
command.isNSFW(),
command.type(),
Expand All @@ -80,17 +80,17 @@ public CommandData toCommandData() {
@Override
public String toString() {
return "ContextCommandDefinition{" +
"id='" + definitionId + '\'' +
", method=" + method +
", name='" + name + '\'' +
", permissions=" + permissions +
", isGuildOnly=" + isGuildOnly +
", isNSFW=" + isNSFW +
", commandType=" + commandType +
", enabledPermissions=" + enabledPermissions +
", scope=" + scope +
", localizationFunction=" + localizationFunction +
", ephemeral=" + ephemeral +
'}';
"id='" + definitionId + '\'' +
", method=" + method +
", name='" + name + '\'' +
", permissions=" + permissions +
", isGuildOnly=" + isGuildOnly +
", isNSFW=" + isNSFW +
", commandType=" + commandType +
", enabledPermissions=" + enabledPermissions +
", scope=" + scope +
", localizationFunction=" + localizationFunction +
", ephemeral=" + ephemeral +
'}';
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -120,18 +120,18 @@ public SlashCommand.CommandScope getCommandScope() {
@Override
public String toString() {
return "GenericCommandDefinition{" +
"id='" + definitionId + '\'' +
", method=" + method +
", name='" + name + '\'' +
", permissions=" + permissions +
", isGuildOnly=" + isGuildOnly +
", isNSFW=" + isNSFW +
", commandType=" + commandType +
", enabledPermissions=" + enabledPermissions +
", scope=" + scope +
", localizationFunction=" + localizationFunction +
", ephemeral=" + ephemeral +
'}';
"id='" + definitionId + '\'' +
", method=" + method +
", name='" + name + '\'' +
", permissions=" + permissions +
", isGuildOnly=" + isGuildOnly +
", isNSFW=" + isNSFW +
", commandType=" + commandType +
", enabledPermissions=" + enabledPermissions +
", scope=" + scope +
", localizationFunction=" + localizationFunction +
", ephemeral=" + ephemeral +
'}';
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ public static Optional<SlashCommandDefinition> build(MethodBuildContext context)
method,
Helpers.ephemeral(context, command.ephemeral()),
name,
com.github.kaktushose.jda.commands.Helpers.permissions(context),
Helpers.permissions(context),
command.isGuildOnly(),
command.isNSFW(),
Command.Type.SLASH,
Expand Down Expand Up @@ -250,21 +250,21 @@ public boolean isAutoComplete() {
@Override
public String toString() {
return "SlashCommandDefinition{" +
"id='" + definitionId + '\'' +
", method=" + method +
", name='" + name + '\'' +
", description='" + description + '\'' +
", parameters=" + parameters +
", cooldown=" + cooldown +
", isAutoComplete=" + isAutoComplete +
", permissions=" + permissions +
", isGuildOnly=" + isGuildOnly +
", isNSFW=" + isNSFW +
", commandType=" + commandType +
", enabledPermissions=" + enabledPermissions +
", scope=" + scope +
", localizationFunction=" + localizationFunction +
", ephemeral=" + ephemeral +
'}';
"id='" + definitionId + '\'' +
", method=" + method +
", name='" + name + '\'' +
", description='" + description + '\'' +
", parameters=" + parameters +
", cooldown=" + cooldown +
", isAutoComplete=" + isAutoComplete +
", permissions=" + permissions +
", isGuildOnly=" + isGuildOnly +
", isNSFW=" + isNSFW +
", commandType=" + commandType +
", enabledPermissions=" + enabledPermissions +
", scope=" + scope +
", localizationFunction=" + localizationFunction +
", ephemeral=" + ephemeral +
'}';
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ public static Optional<ButtonDefinition> build(MethodBuildContext context) {
return Optional.empty();
}

if (com.github.kaktushose.jda.commands.Helpers.isIncorrectParameterType(method, 0, ComponentEvent.class)) {
if (Helpers.isIncorrectParameterType(method, 0, ComponentEvent.class)) {
return Optional.empty();
}

Expand All @@ -70,8 +70,8 @@ public static Optional<ButtonDefinition> build(MethodBuildContext context) {

return Optional.of(new ButtonDefinition(
method,
com.github.kaktushose.jda.commands.Helpers.permissions(context),
com.github.kaktushose.jda.commands.Helpers.ephemeral(context, button.ephemeral()),
Helpers.permissions(context),
Helpers.ephemeral(context, button.ephemeral()),
button.value(),
emoji,
button.link(),
Expand Down Expand Up @@ -143,14 +143,14 @@ public String getDisplayName() {
@Override
public String toString() {
return "ButtonDefinition{" +
"label='" + label + '\'' +
", emoji=" + emoji +
", link='" + link + '\'' +
", style=" + style +
", ephemeral=" + ephemeral +
", permissions=" + permissions +
", id='" + definitionId + '\'' +
", method=" + method +
'}';
"label='" + label + '\'' +
", emoji=" + emoji +
", link='" + link + '\'' +
", style=" + style +
", ephemeral=" + ephemeral +
", permissions=" + permissions +
", id='" + definitionId + '\'' +
", method=" + method +
'}';
}
}
Loading

0 comments on commit 6d9eb8b

Please sign in to comment.