示例#1
0
 /// <summary>
 /// Initializes a new instance of the <see cref="MessageCountConditionResponder"/> class.
 /// </summary>
 /// <param name="autoroles">The autorole service.</param>
 /// <param name="statistics">The statistics service.</param>
 /// <param name="autoroleUpdates">The autorole update service.</param>
 public MessageCountConditionResponder
 (
     AutoroleService autoroles,
     UserStatisticsService statistics,
     AutoroleUpdateService autoroleUpdates
 )
 {
     _autoroles       = autoroles;
     _statistics      = statistics;
     _autoroleUpdates = autoroleUpdates;
 }
 /// <summary>
 /// Initializes a new instance of the <see cref="UserActivityResponder"/> class.
 /// </summary>
 /// <param name="autoroles">The autorole service.</param>
 /// <param name="autoroleUpdates">The autorole update service.</param>
 /// <param name="statistics">The statistics service.</param>
 public UserActivityResponder
 (
     AutoroleService autoroles,
     AutoroleUpdateService autoroleUpdates,
     UserStatisticsService statistics
 )
 {
     _autoroles       = autoroles;
     _autoroleUpdates = autoroleUpdates;
     _statistics      = statistics;
 }
        /// <summary>
        /// Updates the last activity timestamp for the given user.
        /// </summary>
        /// <param name="userStatistics">The statistics service.</param>
        /// <param name="guildUser">The guild user.</param>
        /// <returns>A <see cref="Task"/> representing the asynchronous operation.</returns>
        private async Task UpdateLastActivityTimestampForUser
        (
            UserStatisticsService userStatistics,
            IGuildUser guildUser
        )
        {
            var getGlobalStats = await userStatistics.GetOrCreateUserServerStatisticsAsync(guildUser);

            if (!getGlobalStats.IsSuccess)
            {
                this.Log.LogError(getGlobalStats.Exception, getGlobalStats.ErrorReason);
                return;
            }

            var globalStats = getGlobalStats.Entity;

            globalStats.LastActivityTime = DateTimeOffset.UtcNow;
        }
示例#4
0
        private async Task <OperationResult> UpdateServerMessageCountAsync
        (
            UserStatisticsService userStatistics,
            SocketGuildUser guildUser,
            CancellationToken ct = default
        )
        {
            var getGlobalStats = await userStatistics.GetOrCreateUserServerStatisticsAsync(guildUser, ct);

            if (!getGlobalStats.IsSuccess)
            {
                return(OperationResult.FromError(getGlobalStats));
            }

            var globalStats = getGlobalStats.Entity;

            long?totalMessageCount;

            if (!(globalStats.TotalMessageCount is null))
            {
                totalMessageCount = globalStats.TotalMessageCount.Value + 1;
            }
示例#5
0
 public HomeController(TankService tankService, MedalService medalService, UserStatisticsService userStatisticsService)
 {
     _tankService           = tankService;
     _medalService          = medalService;
     _userStatisticsService = userStatisticsService;
 }