Skip to content

Commit 5e188b3

Browse files
author
Anastasia Calico
committed
tweak: Changes to /image upload command logic.
- The command may only be used in a specific channel. - The URL link is now on a newline. - All error messages are now ephemeral, but the result is not.
1 parent 4d38f79 commit 5e188b3

1 file changed

Lines changed: 17 additions & 2 deletions

File tree

src/main/java/net/modgarden/gardenbot/commands/image/UploadHandler.java

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,14 @@
2222

2323
public class UploadHandler {
2424
public static Response handleUpload(SlashCommandInteraction interaction) {
25-
interaction.event().deferReply(false).queue();
25+
if (interaction.event().getChannelId() == null || !interaction.event().getChannelId().equals(GardenBot.DOTENV.get("IMAGE_CHANNEL_ID"))) {
26+
return new EmbedResponse()
27+
.setTitle("Encountered an exception whilst attempting to upload an image to Mod Garden's CDN.")
28+
.setDescription("You may not use this command in this channel.")
29+
.markEphemeral(true)
30+
.setColor(0x5D3E40);
31+
}
32+
2633

2734
ModGardenEvent event;
2835
Message.Attachment attachment = interaction.event().getOption("attachment", OptionMapping::getAsAttachment);
@@ -31,6 +38,7 @@ public static Response handleUpload(SlashCommandInteraction interaction) {
3138
return new EmbedResponse()
3239
.setTitle("Encountered an exception whilst attempting to upload an image to Mod Garden's CDN.")
3340
.setDescription("Attachment must be a PNG.")
41+
.markEphemeral()
3442
.setColor(0x5D3E40);
3543
}
3644

@@ -40,6 +48,7 @@ public static Response handleUpload(SlashCommandInteraction interaction) {
4048
return new EmbedResponse()
4149
.setTitle("Encountered an exception whilst attempting to upload an image to Mod Garden's CDN.")
4250
.setDescription("There is no active event to upload images for.")
51+
.markEphemeral()
4352
.setColor(0x5D3E40);
4453
}
4554
try (InputStreamReader eventReader = new InputStreamReader(eventResult.body())) {
@@ -50,6 +59,7 @@ public static Response handleUpload(SlashCommandInteraction interaction) {
5059
return new EmbedResponse()
5160
.setTitle("Encountered an exception whilst attempting to upload an image to Mod Garden's CDN.")
5261
.setDescription(ex.getMessage() + "\nPlease report this to a team member.")
62+
.markEphemeral()
5363
.setColor(0xFF0000);
5464
}
5565

@@ -60,6 +70,7 @@ public static Response handleUpload(SlashCommandInteraction interaction) {
6070
return new EmbedResponse()
6171
.setTitle("Encountered an exception whilst attempting to upload an image to Mod Garden's CDN.")
6272
.setDescription("You do not have a Mod Garden account. Please create one with **/register**.")
73+
.markEphemeral()
6374
.setColor(0x5D3E40);
6475
}
6576

@@ -70,6 +81,7 @@ public static Response handleUpload(SlashCommandInteraction interaction) {
7081
return new EmbedResponse()
7182
.setTitle("Encountered an exception whilst attempting to upload an image to Mod Garden's CDN.")
7283
.setDescription("You are not associated with any projects within " + event.displayName + ".")
84+
.markEphemeral()
7385
.setColor(0x5D3E40);
7486
}
7587
}
@@ -78,6 +90,7 @@ public static Response handleUpload(SlashCommandInteraction interaction) {
7890
return new EmbedResponse()
7991
.setTitle("Encountered an exception whilst attempting to upload an image to Mod Garden's CDN.")
8092
.setDescription(ex.getMessage() + "\nPlease report this to a team member.")
93+
.markEphemeral()
8194
.setColor(0xFF0000);
8295
}
8396
StringBuilder fileNameBuilder = new StringBuilder()
@@ -91,6 +104,7 @@ public static Response handleUpload(SlashCommandInteraction interaction) {
91104
return new EmbedResponse()
92105
.setTitle("Encountered an exception whilst attempting to upload an image to Mod Garden's CDN.")
93106
.setDescription(ex.getMessage() + "\nPlease report this to a team member.")
107+
.markEphemeral()
94108
.setColor(0xFF0000);
95109
}
96110

@@ -116,6 +130,7 @@ public static Response handleUpload(SlashCommandInteraction interaction) {
116130
return new EmbedResponse()
117131
.setTitle("Encountered an exception whilst attempting to upload an image to Mod Garden's CDN.")
118132
.setDescription(uploadResponse.statusCode() + ": " + errorMessage + "\nPlease report this to a team member.")
133+
.markEphemeral()
119134
.setColor(0xFF0000);
120135
}
121136
}
@@ -124,6 +139,7 @@ public static Response handleUpload(SlashCommandInteraction interaction) {
124139
return new EmbedResponse()
125140
.setTitle("Encountered an exception whilst attempting to upload an image to Mod Garden's CDN.")
126141
.setDescription(ex.getMessage() + "\nPlease report this to a team member.")
142+
.markEphemeral()
127143
.setColor(0xFF0000);
128144
}
129145

@@ -148,7 +164,6 @@ public static String selectUniqueHash(String basePath) throws IOException, Inter
148164

149165
@SuppressWarnings("MismatchedQueryAndUpdateOfCollection")
150166
private static class ModGardenUser {
151-
String id;
152167
List<String> events;
153168
}
154169

0 commit comments

Comments
 (0)