Пример #1
0
        public static async Task LogMessage(SocketMessage msg)
        {
            LoggedMessage message = new LoggedMessage
            {
                MessageID      = msg.Id,
                AuthorID       = msg.Author.Id,
                ChannelID      = msg.Channel.Id,
                MessageContent = new List <string>(),
                Timestamp      = msg.Timestamp
            };

            message.MessageContent.Add(msg.Content);

            JsonSerializerOptions options = new JsonSerializerOptions
            {
                WriteIndented = true
            };

            string jsonout = JsonSerializer.Serialize(message, options);

            if (!Directory.Exists("Logs/" + ((SocketTextChannel)msg.Channel).Guild.Id.ToString() + "/"))
            {
                Directory.CreateDirectory("Logs/" + ((SocketTextChannel)msg.Channel).Guild.Id.ToString() + "/");
            }
            await File.WriteAllTextAsync("Logs/" + ((SocketTextChannel)msg.Channel).Guild.Id.ToString() + "/" + msg.Id.ToString() + ".json", jsonout);
        }
Пример #2
0
        private async Task _client_MessageUpdated(Cacheable <IMessage, ulong> origMsg, SocketMessage message, ISocketMessageChannel channel)
        {
            ulong         guildID = ((SocketTextChannel)channel).Guild.Id;
            LoggedMessage logMsg  = await MessageLogger.GetLog(origMsg.Id, guildID);


            var origField = new EmbedFieldBuilder()
                            .WithName("Original Text of " + logMsg.MessageID.ToString())
                            .WithValue(logMsg.MessageContent[^ 1])
Пример #3
0
        public async Task AccessAsync(ulong iD)
        {
            LoggedMessage message = await MessageLogger.GetLog(iD, Context.Guild.Id);

            var titleField = new EmbedFieldBuilder()
                             .WithName("Message " + message.MessageID);
            var embed = new EmbedBuilder()
                        .AddField(titleField)
                        .WithAuthor(Context.Guild.GetUser(message.AuthorID))
                        .WithColor(Color.Blue)
                        .WithFooter(footer => footer.Text = "ArbitiesLog")
                        .WithTimestamp(message.Timestamp);

            foreach (string s in message.MessageContent)
            {
                var messageField = new EmbedFieldBuilder()
                                   .WithValue(s);
                embed.AddField(messageField);
            }
            var em = embed.Build();

            await ReplyAsync(embed : em);
        }
Пример #4
0
 public static async Task UpdateLog(ulong msgID, ulong guildID, LoggedMessage updatedMessage)
 {
     string jsonOut = JsonSerializer.Serialize(updatedMessage);
     await File.WriteAllTextAsync("Logs/" + guildID.ToString() + "/" + msgID + ".json", jsonOut);
 }