From 2339e7cde64c5d5ddbe8bcd6e2e2d664cbeb78ab Mon Sep 17 00:00:00 2001 From: SebClem Date: Thu, 23 Jun 2022 13:30:54 +0200 Subject: [PATCH] :hammer: Audio refracto --- .../net/Broken/Api/Data/Music/TrackInfo.java | 2 +- .../CustomMethodSecurityExpressionRoot.java | 7 +- .../net/Broken/Api/Services/AudioService.java | 24 +- .../AudioPlayerSendHandler.java | 2 +- .../GuildAudioManager.java} | 6 +- .../GuildAudioWrapper.java} | 170 +++++-------- .../NotConnectedException.java | 2 +- .../{audio => Audio}/NullMusicManager.java | 2 +- .../{audio => Audio}/TrackScheduler.java | 26 +- .../{audio => Audio}/UserAudioTrack.java | 2 +- .../Youtube/RelatedIdNotFound.java | 2 +- .../Youtube/SearchResult.java | 2 +- .../Youtube/YoutubeSearchRework.java | 2 +- .../Youtube/YoutubeTools.java | 12 +- src/main/java/net/Broken/BotListener.java | 18 +- .../java/net/Broken/RestApi/Commands/Add.java | 19 -- .../Broken/RestApi/Commands/AutoFlowOff.java | 22 -- .../Broken/RestApi/Commands/AutoFlowOn.java | 23 -- .../net/Broken/RestApi/Commands/Connect.java | 37 --- .../net/Broken/RestApi/Commands/Dell.java | 27 -- .../Broken/RestApi/Commands/Disconnect.java | 22 -- .../net/Broken/RestApi/Commands/Flush.java | 21 -- .../net/Broken/RestApi/Commands/Next.java | 21 -- .../net/Broken/RestApi/Commands/Pause.java | 21 -- .../net/Broken/RestApi/Commands/Play.java | 21 -- .../net/Broken/RestApi/Commands/Stop.java | 22 -- .../RestApi/Data/UserAudioTrackData.java | 2 +- .../Broken/RestApi/MusicWebAPIController.java | 239 ------------------ .../Broken/RestApi/PlaylistAPIController.java | 99 -------- .../java/net/Broken/SlashCommands/Music.java | 4 +- .../net/Broken/Tools/EmbedMessageUtils.java | 6 +- .../net/Broken/audio/GetVoiceChanels.java | 47 ---- .../Exception/PlaylistNotFoundException.java | 4 - .../audio/Playlist/PlaylistManager.java | 218 ---------------- .../java/net/Broken/audio/WebLoadUtils.java | 101 -------- 35 files changed, 126 insertions(+), 1129 deletions(-) rename src/main/java/net/Broken/{audio => Audio}/AudioPlayerSendHandler.java (97%) rename src/main/java/net/Broken/{audio/GuildMusicManager.java => Audio/GuildAudioManager.java} (88%) rename src/main/java/net/Broken/{audio/AudioM.java => Audio/GuildAudioWrapper.java} (80%) rename src/main/java/net/Broken/{audio => Audio}/NotConnectedException.java (80%) rename src/main/java/net/Broken/{audio => Audio}/NullMusicManager.java (76%) rename src/main/java/net/Broken/{audio => Audio}/TrackScheduler.java (91%) rename src/main/java/net/Broken/{audio => Audio}/UserAudioTrack.java (95%) rename src/main/java/net/Broken/{audio => Audio}/Youtube/RelatedIdNotFound.java (61%) rename src/main/java/net/Broken/{audio => Audio}/Youtube/SearchResult.java (97%) rename src/main/java/net/Broken/{audio => Audio}/Youtube/YoutubeSearchRework.java (99%) rename src/main/java/net/Broken/{audio => Audio}/Youtube/YoutubeTools.java (94%) delete mode 100644 src/main/java/net/Broken/RestApi/Commands/Add.java delete mode 100644 src/main/java/net/Broken/RestApi/Commands/AutoFlowOff.java delete mode 100644 src/main/java/net/Broken/RestApi/Commands/AutoFlowOn.java delete mode 100644 src/main/java/net/Broken/RestApi/Commands/Connect.java delete mode 100644 src/main/java/net/Broken/RestApi/Commands/Dell.java delete mode 100644 src/main/java/net/Broken/RestApi/Commands/Disconnect.java delete mode 100644 src/main/java/net/Broken/RestApi/Commands/Flush.java delete mode 100644 src/main/java/net/Broken/RestApi/Commands/Next.java delete mode 100644 src/main/java/net/Broken/RestApi/Commands/Pause.java delete mode 100644 src/main/java/net/Broken/RestApi/Commands/Play.java delete mode 100644 src/main/java/net/Broken/RestApi/Commands/Stop.java delete mode 100644 src/main/java/net/Broken/RestApi/MusicWebAPIController.java delete mode 100644 src/main/java/net/Broken/RestApi/PlaylistAPIController.java delete mode 100644 src/main/java/net/Broken/audio/GetVoiceChanels.java delete mode 100644 src/main/java/net/Broken/audio/Playlist/Exception/PlaylistNotFoundException.java delete mode 100644 src/main/java/net/Broken/audio/Playlist/PlaylistManager.java delete mode 100644 src/main/java/net/Broken/audio/WebLoadUtils.java diff --git a/src/main/java/net/Broken/Api/Data/Music/TrackInfo.java b/src/main/java/net/Broken/Api/Data/Music/TrackInfo.java index fcb8abf..8a1885e 100644 --- a/src/main/java/net/Broken/Api/Data/Music/TrackInfo.java +++ b/src/main/java/net/Broken/Api/Data/Music/TrackInfo.java @@ -2,7 +2,7 @@ package net.Broken.Api.Data.Music; import com.sedmelluq.discord.lavaplayer.track.AudioTrackInfo; import net.Broken.Api.Data.UserInfo; -import net.Broken.audio.UserAudioTrack; +import net.Broken.Audio.UserAudioTrack; public record TrackInfo(UserInfo submitter, AudioTrackInfo detail) { public TrackInfo(UserInfo submitter, AudioTrackInfo detail) { diff --git a/src/main/java/net/Broken/Api/Security/Expression/CustomMethodSecurityExpressionRoot.java b/src/main/java/net/Broken/Api/Security/Expression/CustomMethodSecurityExpressionRoot.java index fc87d0c..27ab12c 100644 --- a/src/main/java/net/Broken/Api/Security/Expression/CustomMethodSecurityExpressionRoot.java +++ b/src/main/java/net/Broken/Api/Security/Expression/CustomMethodSecurityExpressionRoot.java @@ -4,12 +4,11 @@ import net.Broken.Api.Data.Music.Connect; import net.Broken.Api.Security.Data.JwtPrincipal; import net.Broken.MainBot; import net.Broken.Tools.CacheTools; -import net.Broken.audio.AudioM; +import net.Broken.Audio.GuildAudioWrapper; import net.dv8tion.jda.api.Permission; import net.dv8tion.jda.api.entities.Guild; import net.dv8tion.jda.api.entities.Member; import net.dv8tion.jda.api.entities.VoiceChannel; -import okhttp3.Cache; import org.springframework.security.access.expression.SecurityExpressionRoot; import org.springframework.security.access.expression.method.MethodSecurityExpressionOperations; import org.springframework.security.core.Authentication; @@ -62,8 +61,8 @@ public class CustomMethodSecurityExpressionRoot public boolean canInteractWithVoiceChannel(String guildId) { JwtPrincipal jwtPrincipal = (JwtPrincipal) authentication.getPrincipal(); Guild guild = MainBot.jda.getGuildById(guildId); - AudioM audioM = AudioM.getInstance(guild); - VoiceChannel channel = audioM.getPlayedChanel(); + GuildAudioWrapper guildAudioWrapper = GuildAudioWrapper.getInstance(guild); + VoiceChannel channel = guild.getAudioManager().getConnectedChannel(); if (channel == null) { return false; diff --git a/src/main/java/net/Broken/Api/Services/AudioService.java b/src/main/java/net/Broken/Api/Services/AudioService.java index cb95755..6518df6 100644 --- a/src/main/java/net/Broken/Api/Services/AudioService.java +++ b/src/main/java/net/Broken/Api/Services/AudioService.java @@ -6,8 +6,8 @@ import net.Broken.Api.Data.Music.PlayBackInfo; import net.Broken.Api.Data.Music.Status; import net.Broken.Api.Data.Music.TrackInfo; import net.Broken.MainBot; -import net.Broken.audio.AudioM; -import net.Broken.audio.UserAudioTrack; +import net.Broken.Audio.GuildAudioWrapper; +import net.Broken.Audio.UserAudioTrack; import net.dv8tion.jda.api.Permission; import net.dv8tion.jda.api.audio.hooks.ConnectionStatus; import net.dv8tion.jda.api.entities.Guild; @@ -38,7 +38,7 @@ public class AudioService { boolean canView = member.hasPermission(channel, Permission.VIEW_CHANNEL) || (member.getVoiceState() != null && member.getVoiceState().getChannel() == channel); - AudioM audioM = AudioM.getInstance(guild); + GuildAudioWrapper guildAudioWrapper = GuildAudioWrapper.getInstance(guild); if (canView) { // The user can interact with the audio if: @@ -51,12 +51,12 @@ public class AudioService { && member.hasPermission(channel, Permission.VOICE_SPEAK); - boolean stopped = audioM.getGuildAudioPlayer().player.getPlayingTrack() == null; + boolean stopped = guildAudioWrapper.getGuidAudioManager().player.getPlayingTrack() == null; PlayBackInfo playBackInfo; if (!stopped) { - boolean paused = audioM.getGuildAudioPlayer().player.isPaused(); - long position = audioM.getGuildAudioPlayer().player.getPlayingTrack().getPosition(); - UserAudioTrack userAudioTrack = audioM.getGuildAudioPlayer().scheduler.getCurrentPlayingTrack(); + boolean paused = guildAudioWrapper.getGuidAudioManager().player.isPaused(); + long position = guildAudioWrapper.getGuidAudioManager().player.getPlayingTrack().getPosition(); + UserAudioTrack userAudioTrack = guildAudioWrapper.getGuidAudioManager().scheduler.getCurrentPlayingTrack(); playBackInfo = new PlayBackInfo(paused, false, position, new TrackInfo(userAudioTrack)); @@ -75,20 +75,18 @@ public class AudioService { public ResponseEntity connect(String guildId, Connect body, String userId) { Guild guild = MainBot.jda.getGuildById(guildId); - AudioM audioM = AudioM.getInstance(guild); + GuildAudioWrapper guildAudioWrapper = GuildAudioWrapper.getInstance(guild); VoiceChannel voiceChannel = guild.getVoiceChannelById(body.channelId()); - audioM.getGuildAudioPlayer(); + guildAudioWrapper.getGuidAudioManager(); guild.getAudioManager().openAudioConnection(voiceChannel); - audioM.setPlayedChanel(voiceChannel); - Status status = getGuildAudioStatus(guildId, userId); return new ResponseEntity<>(status, HttpStatus.OK); } public ResponseEntity disconnect(String guildId, String userId) { Guild guild = MainBot.jda.getGuildById(guildId); - AudioM audioM = AudioM.getInstance(guild); - audioM.disconnect(); + GuildAudioWrapper guildAudioWrapper = GuildAudioWrapper.getInstance(guild); + guildAudioWrapper.disconnect(); Status status = getGuildAudioStatus(guildId, userId); return new ResponseEntity<>(status, HttpStatus.OK); } diff --git a/src/main/java/net/Broken/audio/AudioPlayerSendHandler.java b/src/main/java/net/Broken/Audio/AudioPlayerSendHandler.java similarity index 97% rename from src/main/java/net/Broken/audio/AudioPlayerSendHandler.java rename to src/main/java/net/Broken/Audio/AudioPlayerSendHandler.java index 6a3f600..5d99c8f 100644 --- a/src/main/java/net/Broken/audio/AudioPlayerSendHandler.java +++ b/src/main/java/net/Broken/Audio/AudioPlayerSendHandler.java @@ -1,4 +1,4 @@ -package net.Broken.audio; +package net.Broken.Audio; import com.sedmelluq.discord.lavaplayer.player.AudioPlayer; import com.sedmelluq.discord.lavaplayer.track.playback.MutableAudioFrame; diff --git a/src/main/java/net/Broken/audio/GuildMusicManager.java b/src/main/java/net/Broken/Audio/GuildAudioManager.java similarity index 88% rename from src/main/java/net/Broken/audio/GuildMusicManager.java rename to src/main/java/net/Broken/Audio/GuildAudioManager.java index c878b13..7563144 100644 --- a/src/main/java/net/Broken/audio/GuildMusicManager.java +++ b/src/main/java/net/Broken/Audio/GuildAudioManager.java @@ -1,4 +1,4 @@ -package net.Broken.audio; +package net.Broken.Audio; import com.sedmelluq.discord.lavaplayer.player.AudioPlayer; import com.sedmelluq.discord.lavaplayer.player.AudioPlayerManager; @@ -7,7 +7,7 @@ import net.dv8tion.jda.api.entities.Guild; /** * Holder for both the player and a track scheduler for one guild. */ -public class GuildMusicManager { +public class GuildAudioManager { /** * Audio player for the guild. */ @@ -24,7 +24,7 @@ public class GuildMusicManager { * * @param manager Audio player manager to use for creating the player. */ - public GuildMusicManager(AudioPlayerManager manager, Guild guild) { + public GuildAudioManager(AudioPlayerManager manager, Guild guild) { player = manager.createPlayer(); scheduler = new TrackScheduler(player, guild); player.addListener(scheduler); diff --git a/src/main/java/net/Broken/audio/AudioM.java b/src/main/java/net/Broken/Audio/GuildAudioWrapper.java similarity index 80% rename from src/main/java/net/Broken/audio/AudioM.java rename to src/main/java/net/Broken/Audio/GuildAudioWrapper.java index 7409a8e..cbb39f8 100644 --- a/src/main/java/net/Broken/audio/AudioM.java +++ b/src/main/java/net/Broken/Audio/GuildAudioWrapper.java @@ -1,4 +1,4 @@ -package net.Broken.audio; +package net.Broken.Audio; import com.sedmelluq.discord.lavaplayer.player.AudioLoadResultHandler; import com.sedmelluq.discord.lavaplayer.player.AudioPlayerManager; @@ -27,49 +27,37 @@ import java.util.Collections; import java.util.HashMap; import java.util.List; -public class AudioM { +public class GuildAudioWrapper { + + private static final HashMap INSTANCES = new HashMap<>(); + + private final GuildAudioManager guildAudioManager; + + private final AudioPlayerManager audioPlayerManager; - private static HashMap INSTANCES = new HashMap<>(); - /** - * Music manager for this guild - */ - private GuildMusicManager musicManager; - /** - * Audio player manager for this guild - */ - private AudioPlayerManager playerManager; - /** - * Current voice chanel (null if not connected) - */ - private VoiceChannel playedChanel; - /** - * Time out for list message - */ - private int listTimeOut = 30; /** * Extrem limit for playlist */ - private int listExtremLimit = 300; - /** - * Current guild - */ - private Guild guild; - private Logger logger = LogManager.getLogger(); + private final int listExtremLimit = 300; + + private final Guild guild; + private final Logger logger = LogManager.getLogger(); private Message lastMessageWithButton; - private AudioM(Guild guild) { - this.playerManager = new DefaultAudioPlayerManager(); - AudioSourceManagers.registerRemoteSources(playerManager); - AudioSourceManagers.registerLocalSource(playerManager); + private GuildAudioWrapper(Guild guild) { + this.audioPlayerManager = new DefaultAudioPlayerManager(); + AudioSourceManagers.registerRemoteSources(audioPlayerManager); + AudioSourceManagers.registerLocalSource(audioPlayerManager); + this.guildAudioManager = new GuildAudioManager(audioPlayerManager, guild); + guild.getAudioManager().setSendingHandler(guildAudioManager.getSendHandler()); this.guild = guild; } - public static AudioM getInstance(Guild guild) { + public static GuildAudioWrapper getInstance(Guild guild) { if (!INSTANCES.containsKey(guild)) { - INSTANCES.put(guild, new AudioM(guild)); + INSTANCES.put(guild, new GuildAudioWrapper(guild)); } - return INSTANCES.get(guild); } @@ -83,10 +71,9 @@ public class AudioM { * @param onHead True for adding audio track on top of playlist */ public void loadAndPlay(SlashCommandEvent event, VoiceChannel voiceChannel, final String trackUrl, int playlistLimit, boolean onHead) { - GuildMusicManager musicManager = getGuildAudioPlayer(); - playedChanel = voiceChannel; + GuildAudioManager guidAudioManager = getGuidAudioManager(); - playerManager.loadItemOrdered(musicManager, trackUrl, new AudioLoadResultHandler() { + audioPlayerManager.loadItemOrdered(guidAudioManager, trackUrl, new AudioLoadResultHandler() { @Override public void trackLoaded(AudioTrack track) { logger.info("[" + guild + "] Single Track detected!"); @@ -96,7 +83,7 @@ public class AudioM { .build(); clearLastButton(); lastMessageWithButton = event.getHook().sendMessage(message).addActionRow(getActionButton()).complete(); - play(guild, voiceChannel, musicManager, uat, onHead); + play(guild, voiceChannel, guidAudioManager, uat, onHead); } @Override @@ -130,12 +117,13 @@ public class AudioM { } public void loadAndPlayAuto(String trackUrl) { - playerManager.loadItemOrdered(musicManager, trackUrl, new AudioLoadResultHandler() { + VoiceChannel playedChanel = guild.getAudioManager().getConnectedChannel(); + audioPlayerManager.loadItemOrdered(guildAudioManager, trackUrl, new AudioLoadResultHandler() { @Override public void trackLoaded(AudioTrack track) { logger.info("[" + guild + "] Auto add " + track.getInfo().title + " to playlist."); UserAudioTrack userAudioTrack = new UserAudioTrack(MainBot.jda.getSelfUser(), track); - play(guild, playedChanel, musicManager, userAudioTrack, true); + play(guild, playedChanel, guildAudioManager, userAudioTrack, true); } @Override @@ -143,7 +131,7 @@ public class AudioM { AudioTrack track = playlist.getTracks().get(0); logger.info("[" + guild + "] Auto add " + track.getInfo().title + " to playlist."); UserAudioTrack userAudioTrack = new UserAudioTrack(MainBot.jda.getSelfUser(), track); - play(guild, playedChanel, musicManager, userAudioTrack, true); + play(guild, playedChanel, guildAudioManager, userAudioTrack, true); } @Override @@ -169,30 +157,24 @@ public class AudioM { * @param onHead True for adding audio track on top of playlist */ public void playListLoader(AudioPlaylist playlist, int playlistLimit, User user, boolean onHead) { - int i = 0; + + VoiceChannel playedChanel = guild.getAudioManager().getConnectedChannel(); List tracks = playlist.getTracks(); if (onHead) Collections.reverse(tracks); + int i = 0; for (AudioTrack track : playlist.getTracks()) { UserAudioTrack uat = new UserAudioTrack(user, track); - play(guild, playedChanel, musicManager, uat, onHead); - i++; - if ((i >= playlistLimit && i != -1) || i > listExtremLimit) + play(guild, playedChanel, guildAudioManager, uat, onHead); + if ((playlistLimit != -1 && i >= playlistLimit) || i > listExtremLimit) break; + i++; } } - public GuildMusicManager getGuildAudioPlayer() { - if (musicManager == null) { - musicManager = new GuildMusicManager(playerManager, guild); - } - guild.getAudioManager().setSendingHandler(musicManager.getSendHandler()); - - return musicManager; - } /** * Add single track to playlist, auto-connect if not connected to vocal chanel @@ -203,7 +185,7 @@ public class AudioM { * @param track Track to add to playlist * @param onHead True for adding audio track on top of playlist */ - public void play(Guild guild, VoiceChannel channel, GuildMusicManager musicManager, UserAudioTrack track, boolean onHead) { + public void play(Guild guild, VoiceChannel channel, GuildAudioManager musicManager, UserAudioTrack track, boolean onHead) { if (!guild.getAudioManager().isConnected()) guild.getAudioManager().openAudioConnection(channel); if (!onHead) @@ -218,7 +200,7 @@ public class AudioM { * @param event */ public void skipTrack(GenericInteractionCreateEvent event) { - GuildMusicManager musicManager = getGuildAudioPlayer(); + GuildAudioManager musicManager = getGuidAudioManager(); musicManager.scheduler.nextTrack(); Message message = new MessageBuilder().setEmbeds( EmbedMessageUtils.buildStandar( @@ -236,7 +218,7 @@ public class AudioM { * @param event */ public void pause(GenericInteractionCreateEvent event) { - GuildMusicManager musicManager = getGuildAudioPlayer(); + GuildAudioManager musicManager = getGuidAudioManager(); musicManager.scheduler.pause(); Message message = new MessageBuilder().setEmbeds( EmbedMessageUtils.buildStandar( @@ -256,16 +238,16 @@ public class AudioM { * @param event */ public void resume(GenericInteractionCreateEvent event) { - GuildMusicManager musicManager = getGuildAudioPlayer(); + GuildAudioManager musicManager = getGuidAudioManager(); Message message; - if(musicManager.player.getPlayingTrack() == null){ + if (musicManager.player.getPlayingTrack() == null) { message = new MessageBuilder().setEmbeds( EmbedMessageUtils.buildStandar( new EmbedBuilder() .setTitle(":warning: Nothing to play, playlist is empty !") .setColor(Color.green) )).build(); - }else{ + } else { musicManager.scheduler.resume(); message = new MessageBuilder().setEmbeds( EmbedMessageUtils.buildStandar( @@ -284,7 +266,7 @@ public class AudioM { * @param event */ public void info(GenericInteractionCreateEvent event) { - GuildMusicManager musicManager = getGuildAudioPlayer(); + GuildAudioManager musicManager = getGuidAudioManager(); AudioTrackInfo info = musicManager.scheduler.getInfo(); UserAudioTrack userAudioTrack = musicManager.scheduler.getCurrentPlayingTrack(); Message message = new MessageBuilder().setEmbeds(EmbedMessageUtils.getMusicInfo(info, userAudioTrack)).build(); @@ -293,7 +275,7 @@ public class AudioM { } public void flush(GenericInteractionCreateEvent event) { - GuildMusicManager musicManager = getGuildAudioPlayer(); + GuildAudioManager musicManager = getGuidAudioManager(); musicManager.scheduler.flush(); Message message = new MessageBuilder().setEmbeds( EmbedMessageUtils.buildStandar( @@ -311,7 +293,7 @@ public class AudioM { * @param event */ public void list(GenericInteractionCreateEvent event) { - GuildMusicManager musicManager = getGuildAudioPlayer(); + GuildAudioManager musicManager = getGuidAudioManager(); List list = musicManager.scheduler.getList(); if (list.size() == 0) { @@ -361,8 +343,8 @@ public class AudioM { * @param onHead True for adding audio track on top of playlist */ public void add(SlashCommandEvent event, String url, int playListLimit, boolean onHead) { - if (playedChanel != null) { - loadAndPlay(event, playedChanel, url, playListLimit, onHead); + if (guild.getAudioManager().isConnected()) { + loadAndPlay(event, guild.getAudioManager().getConnectedChannel(), url, playListLimit, onHead); } else { Message message = new MessageBuilder().setEmbeds(EmbedMessageUtils.getMusicError("Not connected to vocal chanel !")).build(); event.getHook().setEphemeral(true).sendMessage(message).queue(); @@ -375,8 +357,8 @@ public class AudioM { * @param event */ public void stop(GenericInteractionCreateEvent event) { - musicManager.scheduler.stop(); - musicManager.scheduler.flush(); + guildAudioManager.scheduler.stop(); + guildAudioManager.scheduler.flush(); if (event != null) { Message message = new MessageBuilder().setEmbeds( @@ -390,7 +372,15 @@ public class AudioM { } } - public void disconnect(GenericInteractionCreateEvent event){ + public void stop() { + + GuildAudioManager musicManager = getGuidAudioManager(); + musicManager.scheduler.stop(); + musicManager.scheduler.flush(); + clearLastButton(); + } + + public void disconnect(GenericInteractionCreateEvent event) { disconnect(); Message message = new MessageBuilder().setEmbeds( EmbedMessageUtils.buildStandar( @@ -402,75 +392,53 @@ public class AudioM { event.getHook().sendMessage(message).queue(); } - public void disconnect(){ - GuildMusicManager musicManager = getGuildAudioPlayer(); + public void disconnect() { + GuildAudioManager musicManager = getGuidAudioManager(); musicManager.scheduler.stop(); musicManager.scheduler.flush(); - playedChanel = null; guild.getAudioManager().closeAudioConnection(); clearLastButton(); } - /** - * Stop current playing track and flush playlist (no confirmation message) - */ - public void stop() { - - GuildMusicManager musicManager = getGuildAudioPlayer(); - musicManager.scheduler.stop(); - musicManager.scheduler.flush(); - clearLastButton(); - } - - public GuildMusicManager getGuildMusicManager() { - if (musicManager == null) - musicManager = getGuildAudioPlayer(); - return musicManager; - - } - public Guild getGuild() { return guild; } - public AudioPlayerManager getPlayerManager() { - return playerManager; + public AudioPlayerManager getAudioPlayerManager() { + return audioPlayerManager; + } + public GuildAudioManager getGuidAudioManager() { + return guildAudioManager; } - public VoiceChannel getPlayedChanel() { - return playedChanel; - } - public void setPlayedChanel(VoiceChannel playedChanel) { - this.playedChanel = playedChanel; - } public void clearLastButton() { - if (lastMessageWithButton != null){ + if (lastMessageWithButton != null) { this.lastMessageWithButton.editMessageComponents(new ArrayList<>()).queue(); this.lastMessageWithButton = null; } } - public void updateLastButton(){ + + public void updateLastButton() { if (lastMessageWithButton != null) lastMessageWithButton = lastMessageWithButton.editMessageComponents(ActionRow.of(getActionButton())).complete(); } - private List