Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions application/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ dependencies {
implementation 'org.jetbrains:annotations:23.0.0'

implementation project(':database')
implementation project(':utils')

implementation 'net.dv8tion:JDA:5.0.0-alpha.9'

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ public static void main(String[] args) {
Application.main(args);
}


/**
* Sets any system-properties before anything else is touched.
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,6 @@
import org.togetherjava.tjbot.moderation.ModAuditLogWriter;
import org.togetherjava.tjbot.routines.ModAuditLogRoutine;

import javax.annotation.Nonnull;
import java.util.ArrayList;
import java.util.Collection;

Expand Down Expand Up @@ -60,7 +59,6 @@ private Features() {
* @param config the configuration features should use
* @return a collection of all features
*/
@Nonnull
public static Collection<Feature> createFeatures(JDA jda, Database database, Config config) {
TagSystem tagSystem = new TagSystem(database);
ModerationActionsStore actionsStore = new ModerationActionsStore(database);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
import net.dv8tion.jda.api.events.message.MessageReceivedEvent;
import net.dv8tion.jda.api.events.message.MessageUpdateEvent;

import javax.annotation.Nonnull;
import java.util.regex.Pattern;

/**
Expand All @@ -28,7 +27,6 @@ public interface MessageReceiver extends Feature {
*
* @return the pattern matching the names of relevant channels
*/
@Nonnull
Pattern getChannelNamePattern();

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
import net.dv8tion.jda.api.events.message.MessageReceivedEvent;
import net.dv8tion.jda.api.events.message.MessageUpdateEvent;

import javax.annotation.Nonnull;
import java.util.regex.Pattern;

/**
Expand All @@ -29,7 +28,6 @@ protected MessageReceiverAdapter(Pattern channelNamePattern) {
}

@Override
@Nonnull
public final Pattern getChannelNamePattern() {
return channelNamePattern;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

import net.dv8tion.jda.api.JDA;

import javax.annotation.Nonnull;
import java.util.concurrent.TimeUnit;

/**
Expand All @@ -24,7 +23,6 @@ public interface Routine extends Feature {
*
* @return the schedule of this routine
*/
@Nonnull
Schedule createSchedule();

/**
Expand All @@ -49,7 +47,6 @@ public interface Routine extends Feature {
record Schedule(ScheduleMode mode, long initialDuration, long duration, TimeUnit unit) {
}


/**
* Whether subsequent executions of a routine are executed at a fixed rate or are delayed.
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@
import org.togetherjava.tjbot.commands.componentids.ComponentIdGenerator;
import org.togetherjava.tjbot.commands.componentids.Lifespan;

import javax.annotation.Nonnull;
import java.util.List;

/**
Expand Down Expand Up @@ -49,7 +48,6 @@ public interface SlashCommand extends UserInteractor {
*
* @return the description of the command
*/
@Nonnull
String getDescription();

/**
Expand All @@ -59,7 +57,6 @@ public interface SlashCommand extends UserInteractor {
*
* @return the visibility of the command
*/
@Nonnull
SlashCommandVisibility getVisibility();

/**
Expand All @@ -77,7 +74,6 @@ public interface SlashCommand extends UserInteractor {
*
* @return the command data of this command
*/
@Nonnull
SlashCommandData getData();

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@
import org.togetherjava.tjbot.commands.componentids.ComponentIdGenerator;
import org.togetherjava.tjbot.commands.componentids.Lifespan;

import javax.annotation.Nonnull;
import java.util.Arrays;
import java.util.List;
import java.util.Objects;
Expand Down Expand Up @@ -90,25 +89,21 @@ protected SlashCommandAdapter(String name, String description,
}

@Override
@Nonnull
public final String getName() {
return name;
}

@Override
@Nonnull
public final String getDescription() {
return description;
}

@Override
@Nonnull
public final SlashCommandVisibility getVisibility() {
return visibility;
}

@Override
@Nonnull
public final SlashCommandData getData() {
return data;
}
Expand Down Expand Up @@ -145,7 +140,6 @@ public void onSelectionMenu(SelectMenuInteractionEvent event, List<String> args)
* @return the generated component ID
*/
@SuppressWarnings("OverloadedVarargsMethod")
@Nonnull
protected final String generateComponentId(String... args) {
return generateComponentId(Lifespan.REGULAR, args);
}
Expand All @@ -163,7 +157,6 @@ protected final String generateComponentId(String... args) {
* @return the generated component ID
*/
@SuppressWarnings({"OverloadedVarargsMethod", "WeakerAccess"})
@Nonnull
protected final String generateComponentId(Lifespan lifespan, String... args) {
return Objects.requireNonNull(componentIdGenerator)
.generate(new ComponentId(getName(), Arrays.asList(args)), lifespan);
Expand Down Expand Up @@ -194,7 +187,6 @@ protected final String generateComponentId(Lifespan lifespan, String... args) {
* @return the generated list of options
*/
@Unmodifiable
@Nonnull
protected static List<OptionData> generateMultipleOptions(OptionData optionData,
@Range(from = 1, to = 25) int amount) {
String baseName = optionData.getName();
Expand All @@ -216,7 +208,6 @@ protected static List<OptionData> generateMultipleOptions(OptionData optionData,
* @return all options with the given prefix
*/
@Unmodifiable
@Nonnull
protected static List<OptionMapping> getMultipleOptionsByNamePrefix(
CommandInteractionPayload event, String namePrefix) {
return event.getOptions()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
import net.dv8tion.jda.api.events.interaction.component.SelectMenuInteractionEvent;
import org.togetherjava.tjbot.commands.componentids.ComponentIdGenerator;

import javax.annotation.Nonnull;
import java.util.List;

/**
Expand All @@ -27,7 +26,6 @@ public interface UserInteractor extends Feature {
*
* @return the name of the interactor
*/
@Nonnull
String getName();

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,13 +19,11 @@
import org.togetherjava.tjbot.commands.SlashCommandVisibility;
import org.togetherjava.tjbot.commands.componentids.Lifespan;

import javax.annotation.Nonnull;
import java.awt.Color;
import java.util.*;
import java.util.function.Function;
import java.util.stream.Collectors;


/**
* Implements the {@code /role-select} command.
* <p>
Expand Down Expand Up @@ -57,7 +55,6 @@ public final class RoleSelectCommand extends SlashCommandAdapter {

private static final int OPTIONAL_ROLES_AMOUNT = 22;


/**
* Construct an instance.
*/
Expand Down Expand Up @@ -193,7 +190,6 @@ private void sendRoleSelectionMenu(final CommandInteraction event,
event.replyEmbeds(embed).addActionRow(menu.build()).queue();
}

@Nonnull
private static SelectOption mapToSelectOption(Role role) {
RoleIcon roleIcon = role.getIcon();

Expand Down Expand Up @@ -243,7 +239,6 @@ private static void handleRoleSelection(SelectMenuInteractionEvent event, Guild
modifyRoles(event, event.getMember(), guild, rolesToAdd, rolesToRemove);
}

@Nonnull
private static Function<SelectOption, Optional<Role>> optionToRole(Guild guild) {
return option -> {
Role role = guild.getRoleById(option.getValue());
Expand All @@ -265,7 +260,6 @@ private static void modifyRoles(IReplyCallback event, Member target, Guild guild
.queue();
}

@Nonnull
private static MessageEmbed createEmbed(String title, CharSequence description) {
return new EmbedBuilder().setTitle(title)
.setDescription(description)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@
import org.togetherjava.tjbot.config.Config;
import org.togetherjava.tjbot.config.SuggestionsConfig;

import javax.annotation.Nonnull;
import java.util.Optional;
import java.util.regex.Pattern;

Expand Down Expand Up @@ -89,7 +88,6 @@ private static void reactWith(String emoteName, String fallbackUnicodeEmote, Gui
});
}

@Nonnull
private static Optional<Emote> getEmoteByName(String name, Guild guild) {
return guild.getEmotesByName(name, false).stream().findAny();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,15 +18,13 @@
import org.togetherjava.tjbot.commands.SlashCommandAdapter;
import org.togetherjava.tjbot.commands.SlashCommandVisibility;

import javax.annotation.Nonnull;
import javax.annotation.Nullable;
import java.util.List;
import java.util.Map;
import java.util.Objects;
import java.util.Optional;
import java.util.concurrent.TimeUnit;


/**
* Implements the {@code vc-activity} command. Creates VC activities.
*
Expand Down Expand Up @@ -125,24 +123,20 @@ public VcActivityCommand() {
"Starts a VC activity (you need to be in an voice channel to run this command)",
SlashCommandVisibility.GUILD);


SubcommandData applicationSubCommand =
new SubcommandData(APPLICATION_SUBCOMMAND, "Choose an application from our list")
.addOptions(new OptionData(OptionType.STRING, APPLICATION_OPTION,
"the application", true).addChoices(VC_APPLICATIONS))
.addOptions(inviteOptions);


SubcommandData idSubCommand =
new SubcommandData("id", "specify the ID for the application manually")
.addOption(OptionType.STRING, ID_OPTION, "the ID of the application", true)
.addOptions(inviteOptions);


getData().addSubcommands(applicationSubCommand, idSubCommand);
}


@Override
public void onSlashCommand(SlashCommandInteractionEvent event) {
Member member = Objects.requireNonNull(event.getMember(), "member is null");
Expand Down Expand Up @@ -191,7 +185,6 @@ public void onSlashCommand(SlashCommandInteractionEvent event) {
handleSubcommand(event, voiceChannel, applicationId, maxUses, maxAgeDays, applicationName);
}

@Nonnull
private static <K, V> Optional<K> getKeyByValue(Map<K, V> map, V value) {
for (Map.Entry<K, V> entry : map.entrySet()) {
if (value.equals(entry.getKey())) {
Expand All @@ -206,7 +199,6 @@ private static void handleSubcommand(SlashCommandInteractionEvent event,
VoiceChannel voiceChannel, String applicationId, @Nullable Integer maxUses,
@Nullable Integer maxAgeDays, String applicationName) {


voiceChannel.createInvite()
.setTargetApplication(applicationId)
.setMaxUses(maxUses)
Expand All @@ -217,7 +209,6 @@ private static void handleSubcommand(SlashCommandInteractionEvent event,

}

@Nonnull
private static ReplyCallbackAction replyInvite(SlashCommandInteractionEvent event,
Invite invite, String applicationName) {
return event.reply("""
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,10 @@
* This package offers some basic commands that act as example for how to use the command system of
* the application.
*/
@MethodsReturnNonnullByDefault
@ParametersAreNonnullByDefault
package org.togetherjava.tjbot.commands.basic;

import org.togetherjava.tjbot.annotations.MethodsReturnNonnullByDefault;

import javax.annotation.ParametersAreNonnullByDefault;
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,6 @@
import net.dv8tion.jda.api.interactions.components.buttons.ButtonStyle;
import org.togetherjava.tjbot.commands.SlashCommand;

import javax.annotation.Nonnull;

/**
* Provides component ID generation.
* <p>
Expand Down Expand Up @@ -37,6 +35,5 @@ public interface ComponentIdGenerator {
* @throws InvalidComponentIdFormatException if the given component ID was in an unexpected
* format and could not be serialized
*/
@Nonnull
String generate(ComponentId componentId, Lifespan lifespan);
}
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
import net.dv8tion.jda.api.interactions.components.buttons.Button;
import net.dv8tion.jda.api.interactions.components.buttons.ButtonStyle;

import javax.annotation.Nonnull;
import java.util.Optional;

/**
Expand Down Expand Up @@ -38,6 +37,5 @@ public interface ComponentIdParser {
* @throws InvalidComponentIdFormatException if the component ID associated to the given UUID
* was in an unexpected format and could not be deserialized
*/
@Nonnull
Optional<ComponentId> parse(String uuid);
}
Loading