From 4f6a4c000da051c9e801585596eb6f011de37bb7 Mon Sep 17 00:00:00 2001 From: Ske Date: Thu, 25 Jun 2020 22:23:15 +0200 Subject: [PATCH] Fix setting server name/avatar with no row in the member_guild table --- PluralKit.Bot/Commands/MemberAvatar.cs | 2 +- PluralKit.Bot/Commands/MemberEdit.cs | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/PluralKit.Bot/Commands/MemberAvatar.cs b/PluralKit.Bot/Commands/MemberAvatar.cs index eccc1ea2..9226cccb 100644 --- a/PluralKit.Bot/Commands/MemberAvatar.cs +++ b/PluralKit.Bot/Commands/MemberAvatar.cs @@ -144,7 +144,7 @@ namespace PluralKit.Bot { AvatarLocation.Server => _db.Execute(c => c.ExecuteAsync( - "update member_guild set avatar_url = @Avatar where member = @Member and guild = @Guild", + "insert into member_guild(member, guild, avatar_url) values (@Member, @Guild, @Avatar) on conflict (member, guild) do update set avatar_url = @Avatar", new {Avatar = avatar, Guild = ctx.Guild.Id, Member = target.Id})), AvatarLocation.Member => _db.Execute(c => c.ExecuteAsync( diff --git a/PluralKit.Bot/Commands/MemberEdit.cs b/PluralKit.Bot/Commands/MemberEdit.cs index c109902e..06a998e0 100644 --- a/PluralKit.Bot/Commands/MemberEdit.cs +++ b/PluralKit.Bot/Commands/MemberEdit.cs @@ -331,7 +331,7 @@ namespace PluralKit.Bot var newServerName = ctx.RemainderOrNull(); await _db.Execute(c => - c.ExecuteAsync("update member_guild set display_name = @newServerName where member = @member and guild = @guild", + c.ExecuteAsync("insert into member_guild(member, guild, display_name) values (@member, @guild, @newServerName) on conflict (member, guild) do update set display_name = @newServerName", new {member = target.Id, guild = ctx.Guild.Id, newServerName})); await ctx.Reply($"{Emojis.Success} Member server name changed. This member will now be proxied using the name \"{newServerName}\" in this server ({ctx.Guild.Name}).");