Skip to content

Commit dc872de

Browse files
committed
split up RoleEmojiCommand into command+subcommand
1 parent c25f285 commit dc872de

File tree

2 files changed

+42
-17
lines changed

2 files changed

+42
-17
lines changed

src/main/java/net/javadiscord/javabot/systems/staff_commands/RoleEmojiCommand.java renamed to src/main/java/net/javadiscord/javabot/systems/staff_commands/role_emoji/AddRoleEmojiSubcommand.java

Lines changed: 12 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,45 +1,40 @@
1-
package net.javadiscord.javabot.systems.staff_commands;
1+
package net.javadiscord.javabot.systems.staff_commands.role_emoji;
22

33
import org.jetbrains.annotations.NotNull;
44

5-
import com.dynxsty.dih4jda.interactions.commands.SlashCommand;
5+
import com.dynxsty.dih4jda.interactions.commands.SlashCommand.Subcommand;
66

7-
import net.dv8tion.jda.api.Permission;
87
import net.dv8tion.jda.api.entities.Message.Attachment;
98
import net.dv8tion.jda.api.entities.Role;
109
import net.dv8tion.jda.api.events.interaction.command.SlashCommandInteractionEvent;
11-
import net.dv8tion.jda.api.interactions.commands.DefaultMemberPermissions;
1210
import net.dv8tion.jda.api.interactions.commands.OptionMapping;
1311
import net.dv8tion.jda.api.interactions.commands.OptionType;
14-
import net.dv8tion.jda.api.interactions.commands.build.Commands;
15-
import net.dv8tion.jda.api.interactions.commands.build.SlashCommandData;
12+
import net.dv8tion.jda.api.interactions.commands.build.SubcommandData;
1613
import net.javadiscord.javabot.data.config.BotConfig;
1714
import net.javadiscord.javabot.util.Checks;
1815
import net.javadiscord.javabot.util.Responses;
1916

2017
/**
21-
* This class represents the /add-role-emoji command.
22-
* This command allows adding emojis which are usable only be members with certain roles.
18+
* This class represents the /emoji-admin add subcommand.
19+
* This subcommand allows adding emojis which are usable only be members with certain roles.
2320
*/
24-
public class RoleEmojiCommand extends SlashCommand{
21+
public class AddRoleEmojiSubcommand extends Subcommand{
2522

2623
private final BotConfig botConfig;
2724

2825
/**
29-
* The constructor of this class, which sets the corresponding {@link net.dv8tion.jda.api.interactions.commands.build.SlashCommandData}.
26+
* The constructor of this class, which sets the corresponding {@link SubcommandData}s.
3027
* @param botConfig The main configuration of the bot
3128
*/
32-
public RoleEmojiCommand(BotConfig botConfig) {
29+
public AddRoleEmojiSubcommand(BotConfig botConfig) {
3330
this.botConfig=botConfig;
34-
SlashCommandData slashCommandData = Commands.slash("add-role-emoji", "Adds an emoji only usable only with certain roles")
31+
SubcommandData subCommandData = new SubcommandData("add", "Adds an emoji only usable only with certain roles")
3532
.addOption(OptionType.STRING, "name", "The name of the emoji", true)
36-
.addOption(OptionType.ATTACHMENT, "emoji", "the emoji", true)
37-
.setDefaultPermissions(DefaultMemberPermissions.enabledFor(Permission.ADMINISTRATOR))
38-
.setGuildOnly(true);
33+
.addOption(OptionType.ATTACHMENT, "emoji", "the emoji", true);
3934
for (int i = 1; i <= 10; i++) {
40-
slashCommandData.addOption(OptionType.ROLE, "role-"+i, "A role allowed to use the emoji", i==1);
35+
subCommandData.addOption(OptionType.ROLE, "role-"+i, "A role allowed to use the emoji", i==1);
4136
}
42-
setSlashCommandData(slashCommandData);
37+
setSubcommandData(subCommandData );
4338
requireUsers(botConfig.getSystems().getAdminConfig().getAdminUsers());
4439
}
4540

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
package net.javadiscord.javabot.systems.staff_commands.role_emoji;
2+
3+
import com.dynxsty.dih4jda.interactions.commands.SlashCommand;
4+
5+
import net.dv8tion.jda.api.Permission;
6+
import net.dv8tion.jda.api.interactions.commands.DefaultMemberPermissions;
7+
import net.dv8tion.jda.api.interactions.commands.build.Commands;
8+
import net.dv8tion.jda.api.interactions.commands.build.SlashCommandData;
9+
import net.javadiscord.javabot.data.config.BotConfig;
10+
11+
/**
12+
* This class represents the /emoji-admin command.
13+
* This command allows managing emojis which are usable only be members with certain roles.
14+
*/
15+
public class RoleEmojiCommand extends SlashCommand {
16+
17+
/**
18+
* The constructor of this class, which sets the corresponding {@link SlashCommandData}s.
19+
* @param botConfig The main configuration of the bot
20+
* @param addRoleEmojiSubcommand A subcommand allowing to add role-exclusive emojis
21+
*/
22+
public RoleEmojiCommand(BotConfig botConfig, AddRoleEmojiSubcommand addRoleEmojiSubcommand) {
23+
SlashCommandData slashCommandData = Commands.slash("emoji-admin", "Adds an emoji only usable only with certain roles")
24+
.setDefaultPermissions(DefaultMemberPermissions.enabledFor(Permission.ADMINISTRATOR))
25+
.setGuildOnly(true);
26+
setSlashCommandData(slashCommandData);
27+
addSubcommands(addRoleEmojiSubcommand);
28+
requireUsers(botConfig.getSystems().getAdminConfig().getAdminUsers());
29+
}
30+
}

0 commit comments

Comments
 (0)