12
12
import net .dv8tion .jda .api .entities .Guild ;
13
13
import net .dv8tion .jda .api .entities .Member ;
14
14
import net .dv8tion .jda .api .entities .User ;
15
+ import net .dv8tion .jda .api .entities .channel .concrete .TextChannel ;
15
16
import net .dv8tion .jda .api .entities .channel .concrete .VoiceChannel ;
16
17
import net .dv8tion .jda .api .entities .channel .unions .AudioChannelUnion ;
17
18
import net .dv8tion .jda .internal .utils .Checks ;
@@ -66,6 +67,8 @@ public static void destroyAll() {
66
67
private AudioModifier audioModifier ;
67
68
private TrackControls controls ;
68
69
70
+ private TextChannel boundChannel ;
71
+
69
72
private AudioManager (@ NotNull AudioPlayer player , @ NotNull Guild guild ) {
70
73
this .guild = guild ;
71
74
@@ -76,6 +79,16 @@ private AudioManager(@NotNull AudioPlayer player, @NotNull Guild guild) {
76
79
guild .getAudioManager ().setSendingHandler (new JDASendHandler (player ));
77
80
}
78
81
82
+ /**
83
+ * Binds the audio manager to the specified text channel, this essentially does nothing but can be useful for blocking access in other channels
84
+ * <br><b>Note - The bound channel will automatically be reset if {@link #disconnect()} is called</b>
85
+ * @param channel The text channel to bind to, must not be null
86
+ * @see #isBoundChannel(TextChannel)
87
+ */
88
+ public void bindTextChannel (@ NotNull TextChannel channel ) {
89
+ boundChannel = channel ;
90
+ }
91
+
79
92
/**
80
93
* Makes the bot join the specified voice channel
81
94
* @param channel The voice channel to join, must not be null
@@ -96,6 +109,8 @@ public void disconnect() {
96
109
97
110
if (isConnected ())
98
111
scheduler .getGuild ().getAudioManager ().closeAudioConnection ();
112
+
113
+ boundChannel = null ;
99
114
}
100
115
101
116
/**
@@ -214,4 +229,12 @@ public boolean isConnected() {
214
229
public Guild getGuild () {
215
230
return guild ;
216
231
}
232
+
233
+ public TextChannel getBoundChannel () {
234
+ return boundChannel ;
235
+ }
236
+
237
+ public boolean isBoundChannel (TextChannel channel ) {
238
+ return boundChannel != null && boundChannel .equals (channel );
239
+ }
217
240
}
0 commit comments