@@ -97,6 +97,19 @@ public boolean isMonitoringChannel(final long channelId) {
97
97
return channelsToMonitorById .containsKey (channelId );
98
98
}
99
99
100
+ /**
101
+ * This method tests whether a channel id is configured for monitoring in the free command
102
+ * system. To add a channel for monitoring see
103
+ * {@link org.togetherjava.tjbot.config.FreeCommandConfig} or
104
+ * {@link #addChannelToMonitor(long)}.
105
+ *
106
+ * @param channel the channel to test.
107
+ * @return {@code true} if the channel is configured in the system, {@code false} otherwise.
108
+ */
109
+ public boolean isMonitoringChannel (@ NotNull TextChannel channel ) {
110
+ return isMonitoringChannel (channel .getIdLong ());
111
+ }
112
+
100
113
private ChannelStatus requiresIsMonitored (final long channelId ) {
101
114
if (!channelsToMonitorById .containsKey (channelId )) {
102
115
throw new IllegalArgumentException (
@@ -117,6 +130,18 @@ public boolean isChannelBusy(final long channelId) {
117
130
return requiresIsMonitored (channelId ).isBusy ();
118
131
}
119
132
133
+ /**
134
+ * This method tests if channel status to busy, see {@link ChannelStatus#isBusy()} for details.
135
+ *
136
+ * @param channel the channel to test.
137
+ * @return {@code true} if the channel is 'busy', false if the channel is 'free'.
138
+ * @throws IllegalArgumentException if the channel passed is not monitored. See
139
+ * {@link #addChannelToMonitor(long)}
140
+ */
141
+ public boolean isChannelBusy (@ NotNull TextChannel channel ) {
142
+ return isChannelBusy (channel .getIdLong ());
143
+ }
144
+
120
145
/**
121
146
* This method tests if a channel is currently active by fetching the latest message and testing
122
147
* if it was posted more recently than the configured time limit, see
@@ -170,6 +195,18 @@ public void setChannelFree(final long channelId) {
170
195
requiresIsMonitored (channelId ).setFree ();
171
196
}
172
197
198
+ /**
199
+ * This method sets the channel's status to 'free', see {@link ChannelStatus#setFree()} for
200
+ * details.
201
+ *
202
+ * @param channel the channel status to modify.
203
+ * @throws IllegalArgumentException if the channel passed is not monitored. See
204
+ * {@link #addChannelToMonitor(long)}
205
+ */
206
+ public void setChannelFree (@ NotNull TextChannel channel ) {
207
+ setChannelFree (channel .getIdLong ());
208
+ }
209
+
173
210
/**
174
211
* This method provides a stream of the id's for guilds that are currently being monitored. This
175
212
* is streamed purely as a simple method of encapsulation.
@@ -338,6 +375,23 @@ public void displayStatus(@NotNull TextChannel channel) {
338
375
}
339
376
}
340
377
378
+ /**
379
+ * Displays the message that will be displayed for users.
380
+ * <p>
381
+ * This method detects if any messages have been posted in the channel below the status message.
382
+ * If that is the case this will delete the existing status message and post another one so that
383
+ * it's the last message in the channel.
384
+ * <p>
385
+ * If it cannot find an existing status message it will create a new one.
386
+ * <p>
387
+ * Otherwise it will edit the existing message.
388
+ *
389
+ * @param guild the guild the status message will be posted in.
390
+ */
391
+ public void displayStatus (@ NotNull Guild guild ) {
392
+ displayStatus (getStatusChannelFor (guild ));
393
+ }
394
+
341
395
private @ NotNull Optional <Message > deleteIfNotLatest (@ NotNull Message message ) {
342
396
343
397
OptionalLong lastId = FreeUtil .getLastMessageId (message .getTextChannel ());
0 commit comments