[Activity] Add full check

This commit is contained in:
2023-03-21 22:52:47 +01:00
parent bffa7d06bb
commit 21996a2e03
4 changed files with 63 additions and 6 deletions

View File

@@ -14,7 +14,7 @@ namespace Cocotte.Modules.Activities;
/// </summary>
[Group("activite", "Organise des activités")]
[SuppressMessage("ReSharper", "UnusedMember.Local")]
public class ActivityModule : InteractionModuleBase<SocketInteractionContext>
public partial class ActivityModule : InteractionModuleBase<SocketInteractionContext>
{
private readonly ILogger<ActivityModule> _logger;
private readonly ActivityOptions _options;
@@ -129,6 +129,17 @@ public class ActivityModule : InteractionModuleBase<SocketInteractionContext>
return;
}
// Check if activity is full
if (await _activitiesRepository.ActivityPlayerCount(activity) >= activity.MaxPlayers)
{
await RespondAsync(
ephemeral: true,
embed: EmbedUtils.ErrorEmbed("L'activité est complète").Build()
);
return;
}
_logger.LogTrace("Player {Player} joined activity {Id}", user.DisplayName, activityId);
var roles = _activityHelper.GetPlayerRoles(user.Roles);