public async Task <ActionResult> DeleteAsync(ulong messageId) { var target = await Context.Channel.GetMessageAsync(messageId); if (target is null) { return(BadRequest("That message doesn't exist in this channel.")); } await target.DeleteAsync(new RequestOptions { AuditLogReason = $"Message deleted by Moderator {Context.User}." }); return(Ok($"{EmojiService.BallotBoxWithCheck} Deleted that message.", async m => { _ = Executor.ExecuteAfterDelayAsync(TimeSpan.FromSeconds(3), async() => { await Context.Message.DeleteAsync(); await m.DeleteAsync(); }); await ModLogService.DoAsync(ModActionEventArgs.New .WithDefaultsFromContext(Context) .WithActionType(ModActionType.Delete) .WithTarget(messageId) ); })); }
public async Task <ActionResult> KickAsync([CheckHierarchy] SocketGuildUser user, [Remainder] string reason = "Kicked by a Moderator.") { if (!await user.TrySendMessageAsync( embed: Context.CreateEmbed($"You've been kicked from **{Context.Guild.Name}** for **{reason}**."))) { Logger.Warn(LogSource.Volte, $"encountered a 403 when trying to message {user}!"); } try { await user.KickAsync(reason); return(Ok($"Successfully kicked **{user.Username}#{user.Discriminator}** from this guild.", _ => ModLogService.DoAsync(ModActionEventArgs.New .WithDefaultsFromContext(Context) .WithActionType(ModActionType.Kick) .WithTarget(user) .WithReason(reason)) )); } catch { return(BadRequest("An error occurred kicking that user. Do I have permission; or are they higher than me in the role list?")); } }
public async Task <ActionResult> SoftBanAsync([CheckHierarchy] SocketGuildUser user, int daysToDelete, [Remainder] string reason = "Softbanned by a Moderator.") { try { await Context.CreateEmbed($"You've been softbanned from **{Context.Guild.Name}** for **{reason}**.") .SendToAsync(user); } catch (Discord.Net.HttpException e) when(e.HttpCode == HttpStatusCode.Forbidden) { Logger.Warn(LogSource.Volte, $"encountered a 403 when trying to message {user}!", e); } await user.BanAsync(daysToDelete, reason); await Context.Guild.RemoveBanAsync(user); return(Ok($"Successfully softbanned **{user.Username}#{user.Discriminator}**.", _ => ModLogService.DoAsync(ModActionEventArgs.New .WithDefaultsFromContext(Context) .WithTarget(user) .WithReason(reason)) )); }
public async Task <ActionResult> ClearWarnsAsync(SocketGuildUser user) { var newWarnList = Context.GuildData.Extras.Warns.Where(x => x.User != user.Id).ToList(); Context.GuildData.Extras.Warns = newWarnList; Db.UpdateData(Context.GuildData); try { await Context.CreateEmbed($"Your warns in **{Context.Guild.Name}** have been cleared. Hooray!") .SendToAsync(user); } catch (HttpException e) when(e.HttpCode == HttpStatusCode.Forbidden) { Logger.Warn(LogSource.Volte, $"encountered a 403 when trying to message {user}!", e); } return(Ok($"Cleared **{newWarnList.Count}** warnings for **{user}**.", _ => ModLogService.DoAsync(ModActionEventArgs.New .WithDefaultsFromContext(Context) .WithActionType(ModActionType.ClearWarns) .WithTarget(user)) )); }
public async Task <ActionResult> WarnAsync([CheckHierarchy] SocketGuildUser user, [Remainder] string reason) { Context.GuildData.Extras.Warns.Add(new Warn { User = user.Id, Reason = reason, Issuer = Context.User.Id, Date = Context.Now }); Db.UpdateData(Context.GuildData); if (!await user.TrySendMessageAsync( embed: Context.CreateEmbed($"You've been warned in **{Context.Guild.Name}** for **{reason}**."))) { Logger.Warn(LogSource.Volte, $"encountered a 403 when trying to message {user}!"); } return(Ok($"Successfully warned **{user}** for **{reason}**.", _ => ModLogService.DoAsync(ModActionEventArgs.New .WithDefaultsFromContext(Context) .WithActionType(ModActionType.Warn) .WithTarget(user) .WithReason(reason)) )); }
public async Task <ActionResult> WarnAsync([CheckHierarchy] SocketGuildUser user, [Remainder] string reason) { await WarnAsync(Context.User, Context.GuildData, user, Db, Logger, reason); return(Ok($"Successfully warned **{user}** for **{reason}**.", _ => ModLogService.DoAsync(ModActionEventArgs.New .WithDefaultsFromContext(Context) .WithActionType(ModActionType.Warn) .WithTarget(user) .WithReason(reason)) )); }
public async Task <ActionResult> IdBanAsync(ulong user, [Remainder] string reason = "Banned by a Moderator.") { await Context.Guild.AddBanAsync(user, 0, reason); return(Ok("Successfully banned that user from this guild.", async _ => await ModLogService.DoAsync(ModActionEventArgs.New .WithDefaultsFromContext(Context) .WithActionType(ModActionType.IdBan) .WithTarget(user) .WithReason(reason)) )); }
public async Task <ActionResult> BanAsync([CheckHierarchy] SocketGuildUser user, [Remainder] string reason = "Banned by a Moderator.") { if (!await user.TrySendMessageAsync( embed: Context.CreateEmbed($"You've been banned from **{Context.Guild.Name}** for **{reason}**."))) { Logger.Warn(LogSource.Volte, $"encountered a 403 when trying to message {user}!"); } await user.BanAsync(7, reason); return(Ok($"Successfully banned **{user}** from this guild.", _ => ModLogService.DoAsync(ModActionEventArgs.New .WithDefaultsFromContext(Context) .WithActionType(ModActionType.Ban) .WithTarget(user) .WithReason(reason)) )); }
public async Task <ActionResult> SoftBanAsync([CheckHierarchy] SocketGuildUser user, int daysToDelete = 0, [Remainder] string reason = "Softbanned by a Moderator.") { if (!await user.TrySendMessageAsync( embed: Context.CreateEmbed($"You've been softbanned from **{Context.Guild.Name}** for **{reason}**."))) { Logger.Warn(LogSource.Volte, $"encountered a 403 when trying to message {user}!"); } await user.BanAsync(daysToDelete == 0? 7 : daysToDelete, reason); await Context.Guild.RemoveBanAsync(user); return(Ok($"Successfully softbanned **{user.Username}#{user.Discriminator}**.", _ => ModLogService.DoAsync(ModActionEventArgs.New .WithDefaultsFromContext(Context) .WithTarget(user) .WithReason(reason)) )); }