Code to reproduce

unlisted ⁨1⁩ ⁨file⁩ 2021-11-18 01:01:38 UTC

.java

Raw
            client.on(MessageCreateEvent.class)
                    .subscribe(event -> {
                        if(event.getMessage().getContent().equals("!test")) {
                            event.getMember()
                                    .ifPresent(member -> {
                                        member.getVoiceState()
                                                .flatMap(state -> Mono.just(Optional.of(state)))
                                                .defaultIfEmpty(Optional.empty())
                                                .subscribe(optional -> {
                                                    System.out.println("State present:" + optional.isPresent());
                                                });
                            });
                        }
                    });

            client.on(VoiceStateUpdateEvent.class)
                    .subscribe(event -> {
                        if(!event.isMoveEvent()) {
                            System.out.println("Received, not move. " + event.getOld().isPresent());
                            return;
                        }

                        final VoiceState state = event.getOld().get();
                        state.getChannel()
                                .subscribe(channel -> {
                                    System.out.println("Channel: " + channel.getId());

                                    channel.delete().subscribe();
                                });
                    });