diff --git a/NadekoBot/Commands/CrossServerTextChannel.cs b/NadekoBot/Commands/CrossServerTextChannel.cs index 9db245ce..1b6545e8 100644 --- a/NadekoBot/Commands/CrossServerTextChannel.cs +++ b/NadekoBot/Commands/CrossServerTextChannel.cs @@ -10,8 +10,8 @@ using NadekoBot.Modules; namespace NadekoBot.Commands { class CrossServerTextChannel : DiscordCommand { public CrossServerTextChannel(DiscordModule module) : base(module) { - try { - NadekoBot.Client.MessageReceived += async (s, e) => { + NadekoBot.Client.MessageReceived += async (s, e) => { + try { if (e.Message.User.Id == NadekoBot.Creds.BotId) return; foreach (var subscriber in Subscribers) { var set = subscriber.Value; @@ -21,24 +21,26 @@ namespace NadekoBot.Commands { await chan.SendMessage(GetText(e.Server, e.Channel, e.User, e.Message)); } } - }; - NadekoBot.Client.MessageUpdated += async (s, e) => { - if (e.After.User.Id == NadekoBot.Creds.BotId) return; + } catch { } + }; + NadekoBot.Client.MessageUpdated += async (s, e) => { + try { + if (e.After?.User?.Id == null || e.After.User.Id == NadekoBot.Creds.BotId) return; foreach (var subscriber in Subscribers) { var set = subscriber.Value; if (!set.Contains(e.Channel)) continue; foreach (var chan in set.Except(new[] { e.Channel })) { var msg = chan.Messages - .FirstOrDefault(m => - m.RawText == GetText(e.Server, e.Channel, e.User, e.Before)); + .FirstOrDefault(m => + m.RawText == GetText(e.Server, e.Channel, e.User, e.Before)); if (msg != default(Message)) await msg.Edit(GetText(e.Server, e.Channel, e.User, e.After)); } } - }; - } catch { } + } catch { } + }; } private string GetText(Server server, Channel channel, User user, Message message) => diff --git a/NadekoBot/Commands/StreamNotifications.cs b/NadekoBot/Commands/StreamNotifications.cs index 8a981a74..5bab0258 100644 --- a/NadekoBot/Commands/StreamNotifications.cs +++ b/NadekoBot/Commands/StreamNotifications.cs @@ -8,6 +8,7 @@ using System.Timers; using Discord.Commands; using NadekoBot.Classes; using NadekoBot.Classes.JSONModels; +using NadekoBot.Classes.Permissions; using NadekoBot.Modules; using Newtonsoft.Json.Linq; @@ -85,12 +86,14 @@ namespace NadekoBot.Commands { .Description("Notifies this channel when a certain user starts streaming." + "\n**Usage**: ~hitbox SomeStreamer") .Parameter("username", ParameterType.Unparsed) + .AddCheck(SimpleCheckers.ManageServer()) .Do(TrackStream(StreamNotificationConfig.StreamType.Hitbox)); cgb.CreateCommand(Module.Prefix + "twitch") .Alias(Module.Prefix + "tw") .Description("Notifies this channel when a certain user starts streaming." + "\n**Usage**: ~twitch SomeStreamer") + .AddCheck(SimpleCheckers.ManageServer()) .Parameter("username", ParameterType.Unparsed) .Do(TrackStream(StreamNotificationConfig.StreamType.Twitch)); @@ -98,6 +101,7 @@ namespace NadekoBot.Commands { .Alias(Module.Prefix + "rms") .Description("Removes notifications of a certain streamer on this channel." + "\n**Usage**: ~srm SomeGuy") + .AddCheck(SimpleCheckers.ManageServer()) .Parameter("username", ParameterType.Unparsed) .Do(async e => { var username = e.GetArg("username")?.ToLower().Trim(); @@ -155,7 +159,8 @@ namespace NadekoBot.Commands { Username = username, Type = type, }; - if (NadekoBot.Config.ObservingStreams.Contains(stream)) { + var exists = NadekoBot.Config.ObservingStreams.Contains(stream); + if (exists) { await e.Channel.SendMessage(":anger: I am already notifying that stream on this channel."); } Tuple data; @@ -174,7 +179,9 @@ namespace NadekoBot.Commands { else if (type == StreamNotificationConfig.StreamType.YoutubeGaming) msg += $"\n`Here is the Link:` not implemented yet - {stream.Username}"; stream.LastStatus = data.Item1; - await e.Channel.SendMessage($":ok: I will notify this channel when status changes.\n{msg}"); + if (!exists) + msg = $":ok: I will notify this channel when status changes.\n{msg}"; + await e.Channel.SendMessage(msg); NadekoBot.Config.ObservingStreams.Add(stream); ConfigHandler.SaveConfig(); };