Skip to content

Commit edf680a

Browse files
committed
Fixed issues after rebase.
1 parent 2e22402 commit edf680a

File tree

2 files changed

+12
-17
lines changed

2 files changed

+12
-17
lines changed

application/src/main/java/org/togetherjava/tjbot/commands/SlashCommandAdapter.java

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
import net.dv8tion.jda.api.events.interaction.command.SlashCommandInteractionEvent;
44
import net.dv8tion.jda.api.events.interaction.component.ButtonInteractionEvent;
55
import net.dv8tion.jda.api.events.interaction.component.SelectMenuInteractionEvent;
6+
import net.dv8tion.jda.api.interactions.commands.OptionMapping;
67
import net.dv8tion.jda.api.interactions.commands.build.CommandData;
78
import net.dv8tion.jda.api.interactions.commands.build.Commands;
89
import net.dv8tion.jda.api.interactions.commands.build.SlashCommandData;
@@ -72,9 +73,9 @@ public abstract class SlashCommandAdapter implements SlashCommand {
7273
* Creates a new adapter with the given data.
7374
*
7475
* @param name the name of this command, requirements for this are documented in
75-
* {@link CommandData#CommandData(String, String)}
76+
* {@link SlashCommandData#setName(String)}
7677
* @param description the description of this command, requirements for this are documented in
77-
* {@link CommandData#CommandData(String, String)}
78+
* {@link SlashCommandData#setDescription(String)}
7879
* @param visibility the visibility of the command
7980
*/
8081
protected SlashCommandAdapter(@NotNull String name, @NotNull String description,
@@ -176,9 +177,8 @@ public void onSelectionMenu(@NotNull SelectMenuInteractionEvent event,
176177
* @see #varArgOptionsToList(Collection, Function)
177178
*/
178179
@Unmodifiable
179-
protected static final @NotNull List<OptionData> generateOptionalVarArgList(
180+
protected static @NotNull List<OptionData> generateOptionalVarArgList(
180181
final @NotNull OptionData optionData, @Range(from = 1, to = 25) final int amount) {
181-
182182
OptionData varArgOption = new OptionData(optionData.getType(), optionData.getName(),
183183
optionData.getDescription());
184184

@@ -187,7 +187,7 @@ public void onSelectionMenu(@NotNull SelectMenuInteractionEvent event,
187187

188188
/**
189189
* This method takes a {@link Collection} of {@link OptionMapping OptionMapping's}, these get
190-
* mapped using the given {@link Function}
190+
* mapped using the given {@link Function}.
191191
*
192192
* @param options A {@link Collection} of {@link OptionMapping OptionMapping's}.
193193
* @param mapper The mapper {@link Function}

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

Lines changed: 7 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -45,14 +45,14 @@ public final class RoleSelectCommand extends SlashCommandAdapter {
4545

4646
private static final String TITLE_OPTION = "title";
4747
private static final String DESCRIPTION_OPTION = "description";
48-
private static final String ROLE_OPTION = "Selectable role";
48+
private static final String ROLE_OPTION = "selectable-role";
4949

5050
private static final Color AMBIENT_COLOR = new Color(24, 221, 136, 255);
5151

5252
private static final List<OptionData> messageOptions = List.of(
53-
new OptionData(OptionType.STRING, TITLE_OPTION, "The title for the message", false),
53+
new OptionData(OptionType.STRING, TITLE_OPTION, "The title for the message", true),
5454
new OptionData(OptionType.STRING, DESCRIPTION_OPTION, "A description for the message",
55-
false));
55+
true));
5656

5757
/**
5858
* Amount of times the role-option will be copied ({@value})
@@ -151,7 +151,6 @@ private static String mentionablesToJoinedString(
151151

152152
@Override
153153
public void onSlashCommand(@NotNull final SlashCommandInteractionEvent event) {
154-
155154
if (!event.getMember().hasPermission(Permission.MANAGE_ROLES)) {
156155
event.reply("You dont have the required manage role permission to use this command")
157156
.setEphemeral(true)
@@ -166,7 +165,6 @@ public void onSlashCommand(@NotNull final SlashCommandInteractionEvent event) {
166165
return;
167166
}
168167

169-
170168
List<Role> rawRoles =
171169
varArgOptionsToList(event.getOptionsByName(ROLE_OPTION), OptionMapping::getAsRole);
172170
List<Role> roles = filterToBotAccessibleRoles(rawRoles);
@@ -176,7 +174,6 @@ public void onSlashCommand(@NotNull final SlashCommandInteractionEvent event) {
176174
return;
177175
}
178176

179-
180177
List<Role> rolesBotCantInteractWith =
181178
roles.stream().filter(role -> !selfMember.canInteract(role)).toList();
182179

@@ -186,7 +183,6 @@ public void onSlashCommand(@NotNull final SlashCommandInteractionEvent event) {
186183
return;
187184
}
188185

189-
190186
handleCommandSuccess(event, roles);
191187
}
192188

@@ -246,11 +242,10 @@ private static boolean handleIsSystemRole(final @NotNull Role role) {
246242
private void handleCommandSuccess(@NotNull final CommandInteraction event,
247243
@NotNull final Collection<? extends Role> roles) {
248244

249-
SelectionMenu.Builder menu =
250-
SelectionMenu.create(generateComponentId(event.getUser().getId()))
251-
.setPlaceholder("Select your roles")
252-
.setMaxValues(roles.size())
253-
.setMinValues(0);
245+
SelectMenu.Builder menu = SelectMenu.create(generateComponentId(event.getUser().getId()))
246+
.setPlaceholder("Select your roles")
247+
.setMaxValues(roles.size())
248+
.setMinValues(0);
254249

255250
roles.forEach(role -> menu.addOptions(mapToSelectOption(role)));
256251

0 commit comments

Comments
 (0)