Пример #1
0
        private async Task <WarningState> ApplyWarningWithSeverity(IUser user, Warning[] history, Warning warning,
                                                                   Embed tempEmbed)
        {
            var state = WarningState.FromDatabase(history);

            warning.Amount = await RequestSeverity(user, history,
                                                   AddWarningsToEmbed(tempEmbed.ToEmbedBuilder(), state).Build());

            if (history.Contains(warning))
            {
                state = WarningState.FromDatabase(history);
            }
            else
            {
                state.Add(warning.Amount, warning.IssueDate);
            }

            if (state.MutedUntil.HasValue)
            {
                await MuteWatcher.MuteUser(
                    new Mute
                {
                    UserId     = user.Id,
                    IssuerId   = Context.Client.GetGuild(DiscordSettings.GuildId).CurrentUser.Id,
                    IssueDate  = DateTime.UtcNow,
                    ExpiryDate = state.MutedUntil.Value.UtcDateTime
                }, "You got a strike!", true, true);
            }
            else
            {
                await MuteWatcher.UnmuteUser(user.Id, Context.Client.GetGuild(DiscordSettings.GuildId).CurrentUser.Id);
            }

            return(state);
        }
Пример #2
0
 public static Task <Mute> MuteUser(IUser issuer, IUser user, DateTimeOffset expiry, string reason, bool shorten,
                                    bool sameAuthorShorten)
 {
     return(MuteWatcher.MuteUser(
                new Mute
     {
         UserId = user.Id,
         IssuerId = issuer.Id,
         ExpiryDate = expiry.UtcDateTime,
         IssueDate = DateTime.UtcNow
     }, reason, shorten, sameAuthorShorten));
 }