Skip to content

Commit

Permalink
Suppress notifications for event detail messages except the first inf…
Browse files Browse the repository at this point in the history
…o message

Bump JDA version and replace deprecated enum
Jsoup update
  • Loading branch information
Alf-Melmac committed Feb 21, 2023
1 parent 6489eb7 commit f85fba3
Show file tree
Hide file tree
Showing 4 changed files with 31 additions and 8 deletions.
4 changes: 2 additions & 2 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,9 @@
<!--https://github.com/atteo/classindex/tags -->
<classindex.version>3.13</classindex.version>
<!--https://github.com/DV8FromTheWorld/JDA/releases -->
<jda.version>5.0.0-beta.3</jda.version>
<jda.version>5.0.0-beta.4</jda.version>
<!--https://jsoup.org/news/ -->
<jsoup.version>1.15.3</jsoup.version>
<jsoup.version>1.15.4</jsoup.version>
<!--https://github.com/ical4j/ical4j/tags -->
<ical4j.version>4.0.0-beta5</ical4j.version>
<!--https://github.com/vojtechhabarta/typescript-generator/releases -->
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ public void startUp() {
new ReactionAddListener(reactionAddService),
new GuildReadyListener(commandsService),
new InteractionListener(commandClassHelper, messageSource))
.disableIntents(GUILD_BANS, GUILD_EMOJIS_AND_STICKERS, GUILD_WEBHOOKS, GUILD_INVITES, GUILD_VOICE_STATES, GUILD_PRESENCES, GUILD_MESSAGE_REACTIONS, GUILD_MESSAGE_TYPING, DIRECT_MESSAGE_TYPING, SCHEDULED_EVENTS)
.disableIntents(GUILD_MODERATION, GUILD_EMOJIS_AND_STICKERS, GUILD_WEBHOOKS, GUILD_INVITES, GUILD_VOICE_STATES, GUILD_PRESENCES, GUILD_MESSAGE_REACTIONS, GUILD_MESSAGE_TYPING, DIRECT_MESSAGE_TYPING, SCHEDULED_EVENTS)
.build();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -148,14 +148,14 @@ private Consumer<Message> infoMsgConsumer(MessageChannelUnion channel, @NonNull
} else {
spacer = "https://cdn.discordapp.com/attachments/759147249325572097/798539020677808178/Discord_Missionstrenner.png";
}
sendMessage(channel, spacer);
sendMessage(channel, spacer, true);

final List<String> slotListMessages = eventApiDto.getSlotList(Long.parseLong(guildId), StaticContextAccessor.getBean(MessageSource.class).getMessage("event.slotlist.title", null, guildLocale));
if (slotListMessages.size() > 2) {
throw BusinessRuntimeException.builder().title("Currently, only a maximum of two slotlist messages with " + Message.MAX_CONTENT_LENGTH + " characters each are possible.").build();
}
//Send SlotList
sendMessage(channel, ListUtils.shift(slotListMessages),
sendMessage(channel, ListUtils.shift(slotListMessages), true,
slotListMsgConsumer(channel, eventApiDto, slotListMessages, guildId));
};
}
Expand All @@ -169,7 +169,7 @@ private Consumer<Message> slotListMsgConsumer(@NonNull MessageChannelUnion chann

slotListMsg.pin().queue();

sendMessage(channel, spacerCharIfEmpty(ListUtils.shift(slotListMessages)),
sendMessage(channel, spacerCharIfEmpty(ListUtils.shift(slotListMessages)), true,
slotListMsgLastConsumer(channel, eventApiDto, guildId));
};
}
Expand Down
27 changes: 25 additions & 2 deletions src/main/java/de/webalf/slotbot/util/bot/MessageUtils.java
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,18 @@ private static void reply(@NonNull Message message, @NotBlank String reply, Cons
* @param message to send
*/
public static void sendMessage(@NonNull MessageChannel channel, @NotBlank String message) {
sendMessage(channel, message, doNothing());
sendMessage(channel, message, false);
}

/**
* Sends the given message in the given channel
*
* @param channel to send into
* @param message to send
* @param suppressNotifications suppress notifications for this message
*/
public static void sendMessage(@NonNull MessageChannel channel, @NotBlank String message, boolean suppressNotifications) {
sendMessage(channel, message, suppressNotifications, doNothing());
}

/**
Expand All @@ -153,7 +164,19 @@ public static void sendMessage(@NonNull MessageChannel channel, @NotBlank String
* @param success message consumer
*/
public static void sendMessage(@NonNull MessageChannel channel, @NotBlank String message, Consumer<Message> success) {
channel.sendMessage(message).queue(success);
sendMessage(channel, message, false, success);
}

/**
* Sends the given message in the given channel and queues the given success consumer
*
* @param channel to send into
* @param message to send
* @param suppressedNotifications suppress notifications for this message
* @param success message consumer
*/
public static void sendMessage(@NonNull MessageChannel channel, @NotBlank String message, boolean suppressedNotifications, Consumer<Message> success) {
channel.sendMessage(message).setSuppressedNotifications(suppressedNotifications).queue(success);
}

/**
Expand Down

0 comments on commit f85fba3

Please sign in to comment.