From 4549b1f4e4800135e872c0c3adf0f72f27e3d997 Mon Sep 17 00:00:00 2001
From: Toastie <toastie@toastiet0ast.com>
Date: Fri, 21 Mar 2025 19:43:00 +1300
Subject: [PATCH] .lcha will now let you override an existing channel template
 even if you're at the limit (which is 1 right now, will be upped very soon)

---
 .../Utility/LiveChannel/LiveChannelService.cs      | 14 +++++++-------
 1 file changed, 7 insertions(+), 7 deletions(-)

diff --git a/src/EllieBot/Modules/Utility/LiveChannel/LiveChannelService.cs b/src/EllieBot/Modules/Utility/LiveChannel/LiveChannelService.cs
index f43db76..e8c764a 100644
--- a/src/EllieBot/Modules/Utility/LiveChannel/LiveChannelService.cs
+++ b/src/EllieBot/Modules/Utility/LiveChannel/LiveChannelService.cs
@@ -119,16 +119,16 @@ public class LiveChannelService(
     /// Adds a new live channel configuration to the specified guild.
     /// </summary>
     /// <param name="guildId">ID of the guild</param>
-    /// <param name="channel">Channel to set as live</param>
+    /// <param name="channelId">ID of the channel</param>
     /// <param name="template">Template text to use for the channel</param>
     /// <returns>True if successfully added, false otherwise</returns>
-    public async Task<bool> AddLiveChannelAsync(ulong guildId, IChannel channel, string template)
+    public async Task<bool> AddLiveChannelAsync(ulong guildId, ulong channelId, string template)
     {
         var guildDict = _liveChannels.GetOrAdd(
             guildId,
             _ => new());
 
-        if (guildDict.Count >= MAX_LIVECHANNELS)
+        if (!guildDict.ContainsKey(channelId) && guildDict.Count >= MAX_LIVECHANNELS)
             return false;
 
         await using var uow = db.GetDbContext();
@@ -136,7 +136,7 @@ public class LiveChannelService(
             .InsertOrUpdateAsync(() => new()
             {
                 GuildId = guildId,
-                ChannelId = channel.Id,
+                ChannelId = channelId,
                 Template = template
             },
                 (_) => new()
@@ -146,18 +146,18 @@ public class LiveChannelService(
                 () => new()
                 {
                     GuildId = guildId,
-                    ChannelId = channel.Id
+                    ChannelId = channelId
                 });
 
         // Add to in-memory cache
         var newConfig = new LiveChannelConfig
         {
             GuildId = guildId,
-            ChannelId = channel.Id,
+            ChannelId = channelId,
             Template = template
         };
 
-        guildDict[channel.Id] = newConfig;
+        guildDict[channelId] = newConfig;
         return true;
     }