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)
|
var m = Rememberer.SearchMessage(mi => mi.ExternalId == dMessage.Id.ToString() && mi.Protocol == Protocol)
|
||||||
?? new()
|
?? 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
|
Protocol = Protocol
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -226,7 +224,6 @@ public class DiscordInterface : ProtocolInterface
|
|||||||
m.Timestamp = dMessage.EditedTimestamp ?? dMessage.CreatedAt;
|
m.Timestamp = dMessage.EditedTimestamp ?? dMessage.CreatedAt;
|
||||||
m.Channel = UpsertChannel(dMessage.Channel);
|
m.Channel = UpsertChannel(dMessage.Channel);
|
||||||
m.Author = UpsertAccount(dMessage.Author, m.Channel);
|
m.Author = UpsertAccount(dMessage.Author, m.Channel);
|
||||||
Console.WriteLine($"received message; author: {m.Author.DisplayName}, {m.Author.Id}");
|
|
||||||
if (dMessage.Channel is IGuildChannel)
|
if (dMessage.Channel is IGuildChannel)
|
||||||
{
|
{
|
||||||
m.Author.DisplayName = (dMessage.Author as IGuildUser).DisplayName;//discord forgot how display names work.
|
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));
|
&& (dMessage.MentionedUserIds?.FirstOrDefault(muid => muid == client.CurrentUser.Id) > 0));
|
||||||
|
|
||||||
Rememberer.RememberMessage(m);
|
Rememberer.RememberMessage(m);
|
||||||
|
Console.WriteLine($"received message; author: {m.Author.DisplayName}, {m.Author.Id}. messageid:{m.Id}");
|
||||||
return m;
|
return m;
|
||||||
}
|
}
|
||||||
internal Channel UpsertChannel(IMessageChannel channel)
|
internal Channel UpsertChannel(IMessageChannel channel)
|
||||||
|
@ -84,8 +84,15 @@ public static class Rememberer
|
|||||||
public static void RememberMessage(Message toRemember)
|
public static void RememberMessage(Message toRemember)
|
||||||
{
|
{
|
||||||
dbAccessSemaphore.Wait();
|
dbAccessSemaphore.Wait();
|
||||||
toRemember.Channel ??= new() { Messages = [toRemember] };
|
toRemember.Channel ??= new();
|
||||||
|
toRemember.Channel.Messages ??= [];
|
||||||
|
if (!toRemember.Channel.Messages.Contains(toRemember))
|
||||||
|
{
|
||||||
|
toRemember.Channel.Messages.Add(toRemember);
|
||||||
db.Update(toRemember.Channel);
|
db.Update(toRemember.Channel);
|
||||||
|
// db.SaveChanges();
|
||||||
|
}
|
||||||
|
db.Update(toRemember);
|
||||||
db.SaveChanges();
|
db.SaveChanges();
|
||||||
dbAccessSemaphore.Release();
|
dbAccessSemaphore.Release();
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user