11package net .javadiscord .javabot .systems .notification ;
22
3+ import lombok .extern .slf4j .Slf4j ;
34import net .dv8tion .jda .api .entities .Guild ;
45import net .dv8tion .jda .api .entities .MessageEmbed ;
56import net .javadiscord .javabot .Bot ;
89/**
910 * Sends notifications within a single {@link Guild}.
1011 */
12+ @ Slf4j
1113public final class GuildNotificationService extends NotificationService {
1214
1315 private final Guild guild ;
@@ -18,19 +20,57 @@ public GuildNotificationService(Guild guild) {
1820 this .config = Bot .config .get (guild );
1921 }
2022
23+ /**
24+ * Sends a {@link MessageEmbed} to the Guild's log channel.
25+ *
26+ * @param embed The {@link MessageEmbed} to send.
27+ */
2128 public void sendLogChannelNotification (MessageEmbed embed ) {
29+ if (config .getModeration ().getLogChannel () == null ) {
30+ log .warn ("Could not find Log Channel for Guild {}" , guild .getName ());
31+ return ;
32+ }
2233 this .sendMessageChannelNotification (config .getModeration ().getLogChannel (), embed );
2334 }
2435
36+ /**
37+ * Sends a simple Message to the Guild's log channel.
38+ *
39+ * @param string The message that should be sent.
40+ * @param args Optional args for formatting.
41+ */
2542 public void sendLogChannelNotification (String string , Object ... args ) {
43+ if (config .getModeration ().getLogChannel () == null ) {
44+ log .warn ("Could not find Log Channel for Guild {}" , guild .getName ());
45+ return ;
46+ }
2647 this .sendMessageChannelNotification (config .getModeration ().getLogChannel (), string , args );
2748 }
2849
50+ /**
51+ * Sends a {@link MessageEmbed} to the Guild's message log channel.
52+ *
53+ * @param embed The {@link MessageEmbed} to send.
54+ */
2955 public void sendMessageLogChannelNotification (MessageEmbed embed ) {
56+ if (config .getMessageCache ().getMessageCacheLogChannel () == null ) {
57+ log .warn ("Could not find Message Log Channel for Guild {}" , guild .getName ());
58+ return ;
59+ }
3060 this .sendMessageChannelNotification (config .getMessageCache ().getMessageCacheLogChannel (), embed );
3161 }
3262
63+ /**
64+ * Sends a simple Message to the Guild's message log channel.
65+ *
66+ * @param string The message that should be sent.
67+ * @param args Optional args for formatting.
68+ */
3369 private void sendMessageLogChannelNotification (String string , Object ... args ) {
70+ if (config .getMessageCache ().getMessageCacheLogChannel () == null ) {
71+ log .warn ("Could not find Message Log Channel for Guild {}" , guild .getName ());
72+ return ;
73+ }
3474 this .sendMessageChannelNotification (config .getMessageCache ().getMessageCacheLogChannel (), string , args );
3575 }
3676}
0 commit comments