Skip to content

Commit 20721f2

Browse files
committed
CR simplified subcommand setup
1 parent 5977d63 commit 20721f2

File tree

1 file changed

+24
-24
lines changed

1 file changed

+24
-24
lines changed

application/src/main/java/org/togetherjava/tjbot/features/messages/MessageCommand.java

Lines changed: 24 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -62,37 +62,37 @@ public final class MessageCommand extends SlashCommandAdapter {
6262
public MessageCommand() {
6363
super("message", "Provides commands to work with messages", CommandVisibility.GUILD);
6464

65-
getData().addSubcommands(new SubcommandData(Subcommand.RAW.name,
65+
SubcommandData raw = new SubcommandData(Subcommand.RAW.name,
6666
"View the raw content of a message, without Discord interpreting any of its content")
6767
.addOption(OptionType.CHANNEL, SRC_CHANNEL_OPTION,
6868
"where to find the message to retrieve content from", true)
6969
.addOption(OptionType.STRING, CONTENT_MESSAGE_ID_OPTION,
70-
"the id of the message to read content from", true),
70+
"the id of the message to read content from", true);
71+
72+
SubcommandData post =
7173
new SubcommandData(Subcommand.POST.name, "Let this bot post a message")
7274
.addOption(OptionType.CHANNEL, DEST_CHANNEL_OPTION, DEST_CHANNEL_DESCRIPTION,
7375
true)
74-
.addOption(OptionType.STRING, CONTENT_OPTION, CONTENT_DESCRIPTION, true),
75-
new SubcommandData(Subcommand.POST_WITH_MESSAGE.name,
76-
"Let this bot post a message. Content is retrieved from the given message.")
77-
.addOption(OptionType.CHANNEL, DEST_CHANNEL_OPTION, DEST_CHANNEL_DESCRIPTION,
78-
true)
79-
.addOption(OptionType.STRING, CONTENT_MESSAGE_ID_OPTION,
80-
CONTENT_MESSAGE_ID_DESCRIPTION, true),
81-
new SubcommandData(Subcommand.EDIT.name,
82-
"Edits a message posted by this bot, the old content is replaced")
83-
.addOption(OptionType.CHANNEL, SRC_CHANNEL_OPTION, EDIT_SRC_CHANNEL_DESCRIPTION,
84-
true)
85-
.addOption(OptionType.STRING, EDIT_MESSAGE_ID_OPTION,
86-
EDIT_MESSAGE_ID_DESCRIPTION, true)
87-
.addOption(OptionType.STRING, CONTENT_OPTION, CONTENT_DESCRIPTION, true),
88-
new SubcommandData(Subcommand.EDIT_WITH_MESSAGE.name,
89-
"Edits a message posted by this bot. Content is retrieved from the given message.")
90-
.addOption(OptionType.CHANNEL, SRC_CHANNEL_OPTION, EDIT_SRC_CHANNEL_DESCRIPTION,
91-
true)
92-
.addOption(OptionType.STRING, EDIT_MESSAGE_ID_OPTION,
93-
EDIT_MESSAGE_ID_DESCRIPTION, true)
94-
.addOption(OptionType.STRING, CONTENT_MESSAGE_ID_OPTION,
95-
CONTENT_MESSAGE_ID_DESCRIPTION, true));
76+
.addOption(OptionType.STRING, CONTENT_OPTION, CONTENT_DESCRIPTION, true);
77+
SubcommandData postWithMessage = new SubcommandData(Subcommand.POST_WITH_MESSAGE.name,
78+
"Let this bot post a message. Content is retrieved from the given message.")
79+
.addOption(OptionType.CHANNEL, DEST_CHANNEL_OPTION, DEST_CHANNEL_DESCRIPTION, true)
80+
.addOption(OptionType.STRING, CONTENT_MESSAGE_ID_OPTION, CONTENT_MESSAGE_ID_DESCRIPTION,
81+
true);
82+
83+
SubcommandData edit = new SubcommandData(Subcommand.EDIT.name,
84+
"Edits a message posted by this bot, the old content is replaced")
85+
.addOption(OptionType.CHANNEL, SRC_CHANNEL_OPTION, EDIT_SRC_CHANNEL_DESCRIPTION, true)
86+
.addOption(OptionType.STRING, EDIT_MESSAGE_ID_OPTION, EDIT_MESSAGE_ID_DESCRIPTION, true)
87+
.addOption(OptionType.STRING, CONTENT_OPTION, CONTENT_DESCRIPTION, true);
88+
SubcommandData editWithMessage = new SubcommandData(Subcommand.EDIT_WITH_MESSAGE.name,
89+
"Edits a message posted by this bot. Content is retrieved from the given message.")
90+
.addOption(OptionType.CHANNEL, SRC_CHANNEL_OPTION, EDIT_SRC_CHANNEL_DESCRIPTION, true)
91+
.addOption(OptionType.STRING, EDIT_MESSAGE_ID_OPTION, EDIT_MESSAGE_ID_DESCRIPTION, true)
92+
.addOption(OptionType.STRING, CONTENT_MESSAGE_ID_OPTION, CONTENT_MESSAGE_ID_DESCRIPTION,
93+
true);
94+
95+
getData().addSubcommands(raw, post, postWithMessage, edit, editWithMessage);
9696
}
9797

9898
/**

0 commit comments

Comments
 (0)