示例#1
0
        public async Task MuteAsync(
            [Summary("Jimbo#5555")][NoSelf][HigherReputation][NotMutedParam][UserOverride] IUser user,
            [Summary("2c")] Rule rule,
            [Summary("8h")][MinHours(Config.MIN_MUTE_LENGTH)] TimeSpan length,
            [Summary("stop spamming")][Remainder][MaxLength(Config.MAX_REASON_LENGTH)] string reason = null)
        {
            var guildUser = await Context.Guild.GetUserAsync(user.Id);

            if (rule.MaxMuteLength.HasValue && length > rule.MaxMuteLength)
            {
                await Context.ReplyErrorAsync(
                    $"The maximum mute length of this rule is {rule.MaxMuteLength.Value.TotalHours}h.");
            }
            else
            {
                await guildUser?.AddRoleAsync(Context.Guild.GetRole(Context.DbGuild.MutedRoleId.Value));

                await Context.ReplyAsync($"You have successfully muted {user.Bold()}.");

                await _modService.CreateMuteAsync(Context, user, rule, length, reason);
            }
        }