Compare commits
No commits in common. "ae8a63eeac2ab8869dcf06186ee47f1890d60b5b" and "9b8d00d1845a29cb935764a79a949d8247090a33" have entirely different histories.
ae8a63eeac
...
9b8d00d184
2 changed files with 8 additions and 8 deletions
src/EllieBot/Modules/Utility/LiveChannel
|
@ -13,7 +13,7 @@ public partial class Utility
|
|||
[BotPerm(GuildPerm.ManageChannels)]
|
||||
public async Task LiveChAdd(IChannel channel, [Leftover] string template)
|
||||
{
|
||||
if (!await svc.AddLiveChannelAsync(ctx.Guild.Id, channel.Id, template))
|
||||
if (!await svc.AddLiveChannelAsync(ctx.Guild.Id, channel, template))
|
||||
{
|
||||
await Response()
|
||||
.Error(strs.livechannel_limit(LiveChannelService.MAX_LIVECHANNELS))
|
||||
|
|
|
@ -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="channelId">ID of the channel</param>
|
||||
/// <param name="channel">Channel to set as live</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, ulong channelId, string template)
|
||||
public async Task<bool> AddLiveChannelAsync(ulong guildId, IChannel channel, string template)
|
||||
{
|
||||
var guildDict = _liveChannels.GetOrAdd(
|
||||
guildId,
|
||||
_ => new());
|
||||
|
||||
if (!guildDict.ContainsKey(channelId) && guildDict.Count >= MAX_LIVECHANNELS)
|
||||
if (guildDict.Count >= MAX_LIVECHANNELS)
|
||||
return false;
|
||||
|
||||
await using var uow = db.GetDbContext();
|
||||
|
@ -136,7 +136,7 @@ public class LiveChannelService(
|
|||
.InsertOrUpdateAsync(() => new()
|
||||
{
|
||||
GuildId = guildId,
|
||||
ChannelId = channelId,
|
||||
ChannelId = channel.Id,
|
||||
Template = template
|
||||
},
|
||||
(_) => new()
|
||||
|
@ -146,18 +146,18 @@ public class LiveChannelService(
|
|||
() => new()
|
||||
{
|
||||
GuildId = guildId,
|
||||
ChannelId = channelId
|
||||
ChannelId = channel.Id
|
||||
});
|
||||
|
||||
// Add to in-memory cache
|
||||
var newConfig = new LiveChannelConfig
|
||||
{
|
||||
GuildId = guildId,
|
||||
ChannelId = channelId,
|
||||
ChannelId = channel.Id,
|
||||
Template = template
|
||||
};
|
||||
|
||||
guildDict[channelId] = newConfig;
|
||||
guildDict[channel.Id] = newConfig;
|
||||
return true;
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue