public async Task TestCommand(string time = null) { //var time = ""; var reason = ""; var IsPermanent = false; var EndTime = MiXLib.tick(); if (time == null) { EndTime += 604800; } else if (time == "inf" || time == "perm" || time == "permanent" || time == "forever" || time == "0" || time == "-1") { IsPermanent = true; EndTime = -1; } else { double length = 0; try { length = Convert.ToDouble(time.Substring(0, time.Length - 1)); } catch (Exception ex) { length = Convert.ToDouble(time); } var suf = ""; try { suf = time.Substring(time.Length - 1); } catch (Exception ex) { suf = "m"; } if (suf == "y") { length = (((length * 60) * 60) * 24) * 365; } else if (suf == "d") { length = ((length * 60) * 60) * 24; } else if (suf == "h") { length = (length * 60) * 60; } else if (suf == "m") { length = length * 60; } else if (suf == "s") { length = length; } if (length <= 0) { IsPermanent = true; EndTime = -1; } else { EndTime += length; } } var LengthString = MiXLib.FormatTime(Convert.ToInt32(EndTime - MiXLib.tick())); if (IsPermanent) { LengthString = "**forever**"; } if (reason == null) { reason = ""; } await ReplyAsync("", false, MiXLib.GetEmbed(LengthString)); }
public async Task GetWarns(SocketUser user) { var Guild = Core.Guilds[Context.Guild.Id]; if (!Guild.Warns.ContainsKey(user.Id) || Guild.Warns[user.Id].Count <= 0) { await ReplyAsync("", false, MiXLib.GetEmbed("User has no active warnings!", color: new Color(255, 140, 0))); return; } var Warns = Guild.Warns[user.Id]; var str = ""; foreach (Warn w in Warns) { var DateTimeFormat = @"MM\/dd\/yyyy hh:mm tt"; var Issuer = Context.Guild.GetUser(w.Issuer); str = str + $"{MiXLib.UnixTimeStampToDateTime(Convert.ToInt64(w.Starts)).ToString(DateTimeFormat)}\n" + $" Reason: **{w.Reason}**\n" + $" Issuer: **{Issuer.Username}#{Issuer.Discriminator}** ({Issuer.Id})\n" + $" Expired: **{MiXLib.BoolToYesNo(w.Expired)}**\n" + $" Expires: **{MiXLib.UnixTimeStampToDateTime(Convert.ToInt64(w.Ends)).ToString(DateTimeFormat)}** (in **{MiXLib.FormatTime(Convert.ToInt32(w.Ends - MiXLib.tick()))}**)\n\n"; } await ReplyAsync("", false, MiXLib.GetEmbed(str, $"Warnings for {user.Username}#{user.Discriminator}", new Color(255, 140, 0))); }