forked from adam/discord-bot-shtik
messages can be replied to with internalAPI
All checks were successful
gitea.arg.rip/vassago/pipeline/head This commit looks good
All checks were successful
gitea.arg.rip/vassago/pipeline/head This commit looks good
and, they save correctly. which is why they weren't getting guids :face_palm: see #25
This commit is contained in:
parent
7c7793f3b2
commit
8cc6c00db3
@ -208,8 +208,6 @@ public class DiscordInterface : ProtocolInterface
|
||||
var m = Rememberer.SearchMessage(mi => mi.ExternalId == dMessage.Id.ToString() && mi.Protocol == Protocol)
|
||||
?? new()
|
||||
{
|
||||
//I don't understand why messages need to have their Ids specified but no other entity does. shrug dot emoji
|
||||
Id = Guid.NewGuid(),
|
||||
Protocol = Protocol
|
||||
};
|
||||
|
||||
@ -226,7 +224,6 @@ public class DiscordInterface : ProtocolInterface
|
||||
m.Timestamp = dMessage.EditedTimestamp ?? dMessage.CreatedAt;
|
||||
m.Channel = UpsertChannel(dMessage.Channel);
|
||||
m.Author = UpsertAccount(dMessage.Author, m.Channel);
|
||||
Console.WriteLine($"received message; author: {m.Author.DisplayName}, {m.Author.Id}");
|
||||
if (dMessage.Channel is IGuildChannel)
|
||||
{
|
||||
m.Author.DisplayName = (dMessage.Author as IGuildUser).DisplayName;//discord forgot how display names work.
|
||||
@ -235,6 +232,7 @@ public class DiscordInterface : ProtocolInterface
|
||||
&& (dMessage.MentionedUserIds?.FirstOrDefault(muid => muid == client.CurrentUser.Id) > 0));
|
||||
|
||||
Rememberer.RememberMessage(m);
|
||||
Console.WriteLine($"received message; author: {m.Author.DisplayName}, {m.Author.Id}. messageid:{m.Id}");
|
||||
return m;
|
||||
}
|
||||
internal Channel UpsertChannel(IMessageChannel channel)
|
||||
|
@ -84,8 +84,15 @@ public static class Rememberer
|
||||
public static void RememberMessage(Message toRemember)
|
||||
{
|
||||
dbAccessSemaphore.Wait();
|
||||
toRemember.Channel ??= new() { Messages = [toRemember] };
|
||||
db.Update(toRemember.Channel);
|
||||
toRemember.Channel ??= new();
|
||||
toRemember.Channel.Messages ??= [];
|
||||
if (!toRemember.Channel.Messages.Contains(toRemember))
|
||||
{
|
||||
toRemember.Channel.Messages.Add(toRemember);
|
||||
db.Update(toRemember.Channel);
|
||||
// db.SaveChanges();
|
||||
}
|
||||
db.Update(toRemember);
|
||||
db.SaveChanges();
|
||||
dbAccessSemaphore.Release();
|
||||
}
|
||||
@ -129,9 +136,9 @@ public static class Rememberer
|
||||
ForgetChannel(childChannel);
|
||||
}
|
||||
}
|
||||
if(toForget.Users?.Count > 0)
|
||||
if (toForget.Users?.Count > 0)
|
||||
{
|
||||
foreach(var account in toForget.Users.ToList())
|
||||
foreach (var account in toForget.Users.ToList())
|
||||
{
|
||||
ForgetAccount(account);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user