mirror of
https://github.com/PluralKit/PluralKit.git
synced 2026-02-04 13:06:50 +00:00
Properly handle duplicate message insertions to the database
This commit is contained in:
parent
356fb76cb2
commit
c3d439dc5f
1 changed files with 2 additions and 1 deletions
|
|
@ -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…
Add table
Add a link
Reference in a new issue