Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Threading.Tasks;
- using Discord;
- using Discord.WebSocket;
- using OctoBot.Configs;
- namespace OctoBot.Handeling
- {
- public class EveryLogHandeling
- {
- private static readonly DiscordSocketClient Client = Global.Client;
- static readonly SocketTextChannel LogTextChannel = Global.Client.GetGuild(375104801018609665).GetTextChannel(446868049589698561);
- public static Task _client_Ready()
- {
- Client.MessageUpdated += Client_MessageUpdated;
- return Task.CompletedTask;
- }
- public static async Task Client_MessageUpdated(Cacheable<IMessage, ulong> messageBefore, SocketMessage messageAfter, ISocketMessageChannel arg3)
- {
- try
- {
- var before = (messageBefore.HasValue ? messageBefore.Value : null) as IUserMessage; // ALWAYS FALSE
- // messageBefore.Value.Content IS ALWAYS NULL
- // messageAfter is good
- if (messageAfter?.Channel is IGuildChannel guildChannel)
- {
- var textChannel = guildChannel as ITextChannel;
- if (messageBefore.HasValue && messageBefore.Value.Content != messageAfter.Content && !string.IsNullOrEmpty(messageBefore.Value.Content))
- {
- string editText = $"**{messageAfter.Author.Username}** modified in {textChannel.Mention}: `{messageBefore.Value.Content}` to `{messageAfter.Content}`";
- await LogTextChannel.SendMessageAsync(editText.Substring(0, Math.Min(editText.Length, Discord.DiscordConfig.MaxMessageSize)));
- }
- }
- }
- catch
- {
- Console.WriteLine($"catch upd");
- }
- }
- }
- }
Add Comment
Please, Sign In to add comment