public async Task TempmuteAsync( [Summary("The user to mute.")] GuildUserProxy user, [Summary("The duration for the mute."), OverrideTypeReader(typeof(AbbreviatedTimeSpanTypeReader))] TimeSpan duration, [Summary("The reason why to mute the user."), Remainder] string reason = DefaultReason) { if (!user.HasValue) { throw new ArgumentException($"User with ID {user.ID} is not in the server!"); } bool unlimitedTime = (Context.User as IGuildUser).GetPermissionLevel(Data.Configuration) >= PermissionLevel.Moderator; double givenDuration = duration.TotalMilliseconds; int maxHelperMuteDuration = Data.Configuration.HelperMuteMaxDuration; if (!unlimitedTime && givenDuration > maxHelperMuteDuration) { duration = TimeSpan.FromMilliseconds(maxHelperMuteDuration); } await user.GuildUser.MuteAsync(Context); SetUserMuted(user.ID, true); Infraction infraction = Moderation.AddTemporaryInfraction(TemporaryInfractionType.TempMute, user.GuildUser, Context.User, duration, reason); await ModerationLog.CreateEntry(ModerationLogEntry.New .WithInfractionId(infraction.ID) .WithDefaultsFromContext(Context) .WithActionType(ModerationActionType.TempMute) .WithTarget(user) .WithDuration(duration) .WithReason(reason), Context.Channel); }
public async Task BanAsync( [Summary("The user to ban")] GuildUserProxy user, [Summary("The duration for the ban."), OverrideTypeReader(typeof(AbbreviatedTimeSpanTypeReader))] TimeSpan duration, [Summary("The reason why to ban the user."), Remainder] string reason = DefaultReason) { // Since the user cannot be found (we are using the GuildUserProxy) we don't need to attempt to message him await Context.Guild.AddBanAsync(user.ID, _pruneDays, reason); Moderation.AddTemporaryInfraction(TemporaryInfractionType.TempBan, user.ID, Context.User, duration, reason); await ModerationLog.CreateEntry(ModerationLogEntry.New .WithDefaultsFromContext(Context) .WithActionType(ModerationActionType.TempBan) .WithTarget(user.ID) .WithDuration(duration) .WithReason(reason), Context.Channel); }
public async Task TempbanAsync( [Summary("The user to temporarily ban.")] SocketGuildUser user, [Summary("The duration for the ban."), OverrideTypeReader(typeof(AbbreviatedTimeSpanTypeReader))] TimeSpan duration, [Summary("The reason why to ban the user."), Remainder] string reason = DefaultReason) { await user.TrySendMessageAsync($"You were banned from **{Context.Guild.Name}** for {duration.Humanize(7)} because of **{reason}**."); await user.BanAsync(_pruneDays, reason); Moderation.AddTemporaryInfraction(TemporaryInfractionType.TempBan, user, Context.User, duration, reason); await ModerationLog.CreateEntry(ModerationLogEntry.New .WithDefaultsFromContext(Context) .WithActionType(ModerationActionType.TempBan) .WithTarget(user) .WithDuration(duration) .WithReason(reason), Context.Channel); }
public async Task TempmuteAsync( [Summary("The user to mute.")] SocketGuildUser user, [Summary("The duration for the mute."), OverrideTypeReader(typeof(AbbreviatedTimeSpanTypeReader))] TimeSpan duration, [Summary("The reason why to mute the user."), Remainder] string reason = DefaultReason) { await user.MuteAsync(Context); SetUserMuted(user.Id, true); Moderation.AddTemporaryInfraction(TemporaryInfractionType.TempMute, user, Context.User, duration, reason); await ModerationLog.CreateEntry(ModerationLogEntry.New .WithDefaultsFromContext(Context) .WithActionType(ModerationActionType.TempMute) .WithTarget(user) .WithDuration(duration) .WithReason(reason), Context.Channel); }