.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)
This commit is contained in:
parent
9b8d00d184
commit
4549b1f4e4
1 changed files with 7 additions and 7 deletions
|
@ -119,16 +119,16 @@ public class LiveChannelService(
|
||||||
/// Adds a new live channel configuration to the specified guild.
|
/// Adds a new live channel configuration to the specified guild.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="guildId">ID of the guild</param>
|
/// <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>
|
/// <param name="template">Template text to use for the channel</param>
|
||||||
/// <returns>True if successfully added, false otherwise</returns>
|
/// <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(
|
var guildDict = _liveChannels.GetOrAdd(
|
||||||
guildId,
|
guildId,
|
||||||
_ => new());
|
_ => new());
|
||||||
|
|
||||||
if (guildDict.Count >= MAX_LIVECHANNELS)
|
if (!guildDict.ContainsKey(channelId) && guildDict.Count >= MAX_LIVECHANNELS)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
await using var uow = db.GetDbContext();
|
await using var uow = db.GetDbContext();
|
||||||
|
@ -136,7 +136,7 @@ public class LiveChannelService(
|
||||||
.InsertOrUpdateAsync(() => new()
|
.InsertOrUpdateAsync(() => new()
|
||||||
{
|
{
|
||||||
GuildId = guildId,
|
GuildId = guildId,
|
||||||
ChannelId = channel.Id,
|
ChannelId = channelId,
|
||||||
Template = template
|
Template = template
|
||||||
},
|
},
|
||||||
(_) => new()
|
(_) => new()
|
||||||
|
@ -146,18 +146,18 @@ public class LiveChannelService(
|
||||||
() => new()
|
() => new()
|
||||||
{
|
{
|
||||||
GuildId = guildId,
|
GuildId = guildId,
|
||||||
ChannelId = channel.Id
|
ChannelId = channelId
|
||||||
});
|
});
|
||||||
|
|
||||||
// Add to in-memory cache
|
// Add to in-memory cache
|
||||||
var newConfig = new LiveChannelConfig
|
var newConfig = new LiveChannelConfig
|
||||||
{
|
{
|
||||||
GuildId = guildId,
|
GuildId = guildId,
|
||||||
ChannelId = channel.Id,
|
ChannelId = channelId,
|
||||||
Template = template
|
Template = template
|
||||||
};
|
};
|
||||||
|
|
||||||
guildDict[channel.Id] = newConfig;
|
guildDict[channelId] = newConfig;
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue