public static async void HandleEdit(object client, MessageUpdatedEventArgs e) { // Don't handle own message or any message containing embeds that was *just* replied to if (e != null && e.Before != null && !e.Before.IsAuthor && ((e.Before.Embeds != null && e.Before.Embeds.Length == 0) || !IsMessageLastRepliedTo(e.Before.Channel.Id, e.Before.Id))) { if (LastHandledMessageOnChannel.ContainsKey(e.Before.Channel.Id)) LastHandledMessageOnChannel.Remove(e.Before.Channel.Id); bool calcDate = (DateTime.Now - e.Before.Timestamp).Minutes < Program.EditThreshold; string server = e.Before.Server == null ? "1-1" : e.Before.Server.Name; string user = e.Before.User == null ? "?" : e.Before.User.Name; string rawtext = e.Before.RawText ?? ""; Console.WriteLine(string.Format("[{0}][Edit] {1}: {2}", server, user, rawtext)); string reply = null; string[] words = rawtext.Split(' '); reply = await HandleCommands((DiscordClient) client, reply, words); if (reply == null) { reply = HandleEmotesAndConversions(reply, words); } if (!string.IsNullOrWhiteSpace(reply) && calcDate) { Message botRelation = GetExistingBotReplyOrNull(e.Before.Id); if (botRelation == null) { await SendReply(client, e.After, e.After.Channel.Id, e.After.Id, reply); } else if (botRelation != null) { try { await botRelation.Edit(reply); } catch (Exception ex) { Console.WriteLine(ex.ToString()); } } } } }
private async void MsgUpdtd(object sender, MessageUpdatedEventArgs e) { try { if (e.Server == null || e.Channel.IsPrivate || e.User.Id == NadekoBot.Client.CurrentUser.Id) return; Channel ch; if (!logs.TryGetValue(e.Server, out ch) || e.Channel == ch) return; await ch.SendMessage($"`Type:` **Message updated** `Time:` **{DateTime.Now}** `Channel:` **{e.Channel.Name}**\n**BEFORE**: `{e.User}:` {e.Before.Text}\n---------------\n**AFTER**: `{e.User}:` {e.After.Text}"); } catch { } }