Skip to content

Commit

Permalink
Remove elements requiring intents
Browse files Browse the repository at this point in the history
  • Loading branch information
couchoud-t committed Jul 8, 2024
1 parent 636257a commit 8069d42
Show file tree
Hide file tree
Showing 6 changed files with 2 additions and 394 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ public class JdaConfiguration{
public JDA getJda(List<ListenerAdapter> listenerAdapters, ApplicationSettings applicationSettings) throws InterruptedException{
log.info("Building JDA");
var jda = JDABuilder.createDefault(applicationSettings.getBotToken())
.enableIntents(GatewayIntent.GUILD_MEMBERS, GatewayIntent.MESSAGE_CONTENT)
.setMemberCachePolicy(MemberCachePolicy.ALL)
.enableCache(CacheFlag.EMOJI)
.setAutoReconnect(true)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,12 +36,10 @@ public class AutoTodoEventListener extends ListenerAdapter{
};

private final ChannelRepository channelRepository;
private final FixLinksEventListener fixLinksEventListener;

@Autowired
public AutoTodoEventListener(ChannelRepository channelRepository, FixLinksEventListener fixLinksEventListener){
public AutoTodoEventListener(ChannelRepository channelRepository){
this.channelRepository = channelRepository;
this.fixLinksEventListener = fixLinksEventListener;
}

@Override
Expand All @@ -64,21 +62,11 @@ public void onMessageReceived(@NotNull MessageReceivedEvent event){
case CHANNEL_PINNED_ADD, THREAD_CREATED -> JDAWrappers.delete(message).submit();
case DEFAULT, INLINE_REPLY, SLASH_COMMAND, CONTEXT_COMMAND -> JDAWrappers
.createThread(message, "reply-" + event.getMessageId()).submit()
.thenCompose(thread -> JDAWrappers.message(thread, ActionRow.of(BUTTONS_NORMAL)).submit()
.thenCompose(m -> fixLinks(thread)));
.thenCompose(thread -> JDAWrappers.message(thread, ActionRow.of(BUTTONS_NORMAL)).submit());
}
}
}

@NotNull
private CompletableFuture<Message> fixLinks(@NotNull ThreadChannel thread){
return thread.retrieveParentMessage().submit()
.thenApply(message -> fixLinksEventListener.extractFixedLinks(message.getContentRaw()))
.thenCompose(links -> links.isEmpty()
? CompletableFuture.completedFuture(null)
: JDAWrappers.message(thread, String.join("\n", links)).submit());
}

@Override
public void onChannelCreate(@NotNull ChannelCreateEvent event){
if(!event.isFromGuild() || event.getChannelType() != ChannelType.GUILD_PUBLIC_THREAD){
Expand Down

This file was deleted.

This file was deleted.

This file was deleted.

Loading

0 comments on commit 8069d42

Please sign in to comment.