public async Task RemoveWarnAsync([RequireInvokerHierarchy("remove warnings from")] SocketGuildUser user, string id) { if (!ulong.TryParse(id, out ulong ID)) { await Context.Channel.SendMessageAsync($"Our security team has informed us that {id} is not a valid Mod Log ID."); return; } if (!await modLogsDatabase.Warnings.GetWarningAsync(user, ID)) { await Context.Channel.SendMessageAsync($"Our security team has informed us that the given warning does not exist."); return; } EmbedBuilder embed = new EmbedBuilder() .WithColor(new Color(12, 156, 24)) .WithDescription($"The given warning has been pardoned."); await Task.WhenAll ( Context.Channel.SendMessageAsync(embed: embed.Build()), RemoveWarningModLog.SendToModLogAsync(Context.User as SocketGuildUser, user, id), modLogsDatabase.Warnings.RemoveWarningAsync(user, ID) ); }
public async Task TempWarnAsync([RequireInvokerHierarchy("warn")] SocketGuildUser user, string length, [Remainder] string reason = null) { ulong id = await modLogsDatabase.ModLogs.GetNextModLogID(Context.Guild); EmbedBuilder embed = new EmbedBuilder() .WithColor(new Color(255, 213, 31)) .WithDescription($"{user.Mention} stop protesting capitalism."); if (double.TryParse(length, out double h)) { EmbedFieldBuilder lengthField = new EmbedFieldBuilder() .WithIsInline(false) .WithName("Length") .WithValue(h < 1 ? $"{h * 60} minutes" : $"{h} hours"); embed.AddField(lengthField); } EmbedFieldBuilder reasonField = new EmbedFieldBuilder() .WithIsInline(false) .WithName("Reason") .WithValue($"{reason ?? "[none given]"}"); embed.AddField(reasonField); await Task.WhenAll ( Context.Channel.SendMessageAsync(embed: embed.Build()), WarnModLog.SendToModLogAsync(Context.User as SocketGuildUser, user, length, reason), modLogsDatabase.Warnings.AddWarningAsync(user, id) ); if (double.TryParse(length, out double hours)) { await Task.Delay((int)(hours * 60 * 60 * 1000)); if (!await modLogsDatabase.Warnings.GetWarningAsync(user, id)) { return; } await Task.WhenAll ( RemoveWarningModLog.SendToModLogAsync(Context.Guild.CurrentUser, user, id.ToString()), modLogsDatabase.Warnings.RemoveWarningAsync(user, id) ); } }