Properly handle duplicate message insertions to the database
This commit is contained in:
parent
356fb76cb2
commit
c3d439dc5f
@ -298,7 +298,8 @@ namespace PluralKit.Core {
|
||||
}
|
||||
public async Task AddMessage(ulong senderId, ulong messageId, ulong guildId, ulong channelId, ulong originalMessage, PKMember member) {
|
||||
using (var conn = await _conn.Obtain())
|
||||
await conn.ExecuteAsync("insert into messages(mid, guild, channel, member, sender, original_mid) values(@MessageId, @GuildId, @ChannelId, @MemberId, @SenderId, @OriginalMid)", new {
|
||||
// "on conflict do nothing" in the (pretty rare) case of duplicate events coming in from Discord, which would lead to a DB error before
|
||||
await conn.ExecuteAsync("insert into messages(mid, guild, channel, member, sender, original_mid) values(@MessageId, @GuildId, @ChannelId, @MemberId, @SenderId, @OriginalMid) on conflict do nothing", new {
|
||||
MessageId = messageId,
|
||||
GuildId = guildId,
|
||||
ChannelId = channelId,
|
||||
|
Loading…
Reference in New Issue
Block a user