|
12 | 12 | import hera.core.api.handlers.YouTubeApiHandler;
|
13 | 13 | import hera.core.commands.Commands;
|
14 | 14 | import hera.core.commands.Queue;
|
| 15 | +import hera.core.commands.Vote; |
15 | 16 | import hera.core.music.HeraAudioManager;
|
16 | 17 | import hera.database.entities.Guild;
|
17 | 18 | import hera.database.entities.Token;
|
@@ -139,21 +140,40 @@ public static void main(String[] args) {
|
139 | 140 | // Reaction emoji event stream
|
140 | 141 | client.getEventDispatcher().on(ReactionAddEvent.class)
|
141 | 142 | .flatMap(event -> Mono.justOrEmpty(client.getSelfId())
|
142 |
| - .filter(selfId -> event.getUserId().asLong() != selfId.asLong()) |
143 |
| - .flatMap(selfId -> event.getGuild() |
144 |
| - .filter(guild -> event.getMessageId().asLong() == HeraAudioManager.getScheduler(guild).getCurrentQueueMessageId()) |
145 |
| - .flatMap(guild -> event.getChannel() |
146 |
| - .flatMap(channel -> event.getMessage() |
147 |
| - .flatMap(message -> Mono.justOrEmpty(message.getEmbeds().get(0).getFooter()) |
148 |
| - .flatMap(footer -> Mono.justOrEmpty(event.getEmoji().asUnicodeEmoji()) |
149 |
| - .flatMap(unicode -> message.delete() |
150 |
| - .then(Queue.executeFromReaction(event, channel, footer.getText(), unicode.getRaw(), guild)) |
| 143 | + .filter(selfId -> event.getUserId().asLong() != selfId.asLong()) |
| 144 | + .flatMap(selfId -> event.getGuild() |
| 145 | + .filter(guild -> event.getMessageId().asLong() == HeraAudioManager.getScheduler(guild).getCurrentQueueMessageId()) |
| 146 | + .flatMap(guild -> event.getChannel() |
| 147 | + .flatMap(channel -> event.getMessage() |
| 148 | + .flatMap(message -> Mono.justOrEmpty(message.getEmbeds().get(0).getFooter()) |
| 149 | + .flatMap(footer -> Mono.justOrEmpty(event.getEmoji().asUnicodeEmoji()) |
| 150 | + .flatMap(unicode -> message.delete() |
| 151 | + .then(Queue.executeFromReaction(event, channel, footer.getText(), unicode.getRaw(), guild)) |
| 152 | + ) |
| 153 | + ) |
| 154 | + ) |
| 155 | + ) |
| 156 | + ) |
| 157 | + .switchIfEmpty(Mono.just(Vote.ACTIVE_VOTE_MESSAGE_IDS) |
| 158 | + .filter(activeVotes -> activeVotes.keySet().contains(event.getMessageId().asLong())) |
| 159 | + .flatMap(activeVotes -> event.getGuild() |
| 160 | + .flatMap(guild -> event.getChannel() |
| 161 | + .flatMap(channel -> event.getUser() |
| 162 | + .flatMap(user -> user.asMember(guild.getId()) |
| 163 | + .flatMap(member -> event.getMessage() |
| 164 | + .flatMap(message -> Mono.justOrEmpty(message.getEmbeds().get(0).getDescription()) |
| 165 | + .flatMap(description -> Mono.justOrEmpty(event.getEmoji().asUnicodeEmoji()) |
| 166 | + .flatMap(unicode -> Vote.executeFromReaction(event, channel, message.getReactions(), description, unicode.getRaw(), member, guild)) |
| 167 | + .then() |
| 168 | + ) |
| 169 | + ) |
| 170 | + ) |
| 171 | + ) |
151 | 172 | )
|
152 | 173 | )
|
153 | 174 | )
|
154 | 175 | )
|
155 | 176 | )
|
156 |
| - ) |
157 | 177 | )
|
158 | 178 | .subscribe();
|
159 | 179 |
|
|
0 commit comments