Skip to content

Commit 97ed98a

Browse files
committed
Made changes Zabu requested, typos, Moved declarations, updated doc, removed some more empty lines etc.
1 parent aeb8e79 commit 97ed98a

File tree

1 file changed

+11
-16
lines changed

1 file changed

+11
-16
lines changed

application/src/main/java/org/togetherjava/tjbot/commands/basic/VcActivityCommand.java

Lines changed: 11 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -46,8 +46,8 @@ public final class VcActivityCommand extends SlashCommandAdapter {
4646
private static final String MAX_USES_OPTION = "max-uses";
4747
private static final String MAX_AGE_OPTION = "max-age";
4848

49-
private static final long MAX_VALUE_MAX_AGE = TimeUnit.DAYS.toSeconds(7);
50-
private static final long MAX_VALE_MAX_USES = 100;
49+
private static final long MAX_AGE_LIMIT = TimeUnit.DAYS.toSeconds(7);
50+
private static final long MAX_USES_LIMIT = 100;
5151

5252
public static final String YOUTUBE_TOGETHER_NAME = "YouTube Together";
5353
public static final String POKER_NAME = "Poker";
@@ -73,7 +73,6 @@ public final class VcActivityCommand extends SlashCommandAdapter {
7373
new Command.Choice(WORDSNACK_NAME, WORDSNACK_NAME),
7474
new Command.Choice(LETTERTILE_NAME, LETTERTILE_NAME));
7575

76-
7776
/**
7877
* List comes from <a href="https://github.com/DV8FromTheWorld/JDA/pull/1628">the "Implement
7978
* invite targets" PR on JDA</a>. There is no official list from Discord themselves, so this is
@@ -88,11 +87,11 @@ public final class VcActivityCommand extends SlashCommandAdapter {
8887

8988
private static final List<OptionData> inviteOptions = List.of(
9089
new OptionData(OptionType.INTEGER, MAX_USES_OPTION,
91-
"The amount of times the invite can be used, default is infinity", false)
92-
.setRequiredRange(0, MAX_VALE_MAX_USES),
90+
"Max uses for invites, 0 for infinite, 100 is the top limit.", false)
91+
.setRequiredRange(0, MAX_USES_LIMIT),
9392
new OptionData(OptionType.INTEGER, MAX_AGE_OPTION,
9493
"Max age in seconds. Set this to 0 to never expire, default is 1 day", false)
95-
.setRequiredRange(0, MAX_VALUE_MAX_AGE));
94+
.setRequiredRange(0, MAX_AGE_LIMIT));
9695

9796
/**
9897
* Constructs an instance
@@ -155,13 +154,8 @@ public void onSlashCommand(@NotNull SlashCommandEvent event) {
155154

156155
String applicationId;
157156
String applicationName;
158-
Integer maxUses;
159-
Integer maxAge;
160-
161-
162-
maxUses = handleIntegerTypeOption(maxUsesOption);
163-
maxAge = handleIntegerTypeOption(maxAgeOption);
164-
157+
Integer maxUses = handleIntegerTypeOption(maxUsesOption);
158+
Integer maxAge = handleIntegerTypeOption(maxAgeOption);
165159

166160
if (applicationOption != null) {
167161
applicationName = applicationOption.getAsString();
@@ -176,6 +170,7 @@ public void onSlashCommand(@NotNull SlashCommandEvent event) {
176170
handleSubcommand(event, voiceChannel, applicationId, maxUses, maxAge, applicationName);
177171
}
178172

173+
179174
private static <K, V> @NotNull Optional<K> getKeyByValue(@NotNull Map<K, V> map,
180175
@NotNull V value) {
181176
for (Map.Entry<K, V> entry : map.entrySet()) {
@@ -215,9 +210,9 @@ private static void handleErrors(@NotNull SlashCommandEvent event,
215210
}
216211

217212
/**
218-
* This grabs the OptionMapping, after this it returns null of the OptionMapping is null, else
219-
* it'll return the number option as an Integer
220-
*
213+
* This grabs the OptionMapping, and interprets the given option as Integer, throws is the given
214+
* option is not an integer. it'll return the number option as an Integer returns the option
215+
* interpreted as int, null if option was null already.
221216
* <p>
222217
* <p/>
223218
*

0 commit comments

Comments
 (0)