protected override void OnTick() { try { Console.WriteLine("Warning: {0} bad spawns detected, logged: 'badspawn.log'", m_List.Count); using (StreamWriter op = new StreamWriter("badspawn.log", true)) { op.WriteLine("# Bad spawns : {0}", DateTime.UtcNow); op.WriteLine("# Format: X Y Z F Name"); op.WriteLine(); for (var index = 0; index < m_List.Count; index++) { WarnEntry e = m_List[index]; op.WriteLine("{0}\t{1}\t{2}\t{3}\t{4}", e.m_Point.X, e.m_Point.Y, e.m_Point.Z, e.m_Map, e.m_Name); } op.WriteLine(); op.WriteLine(); } } catch (Exception e) { ExceptionLogging.LogException(e); } }
public async Task <RuntimeResult> WarnAsync(IGuildUser user, [Optional][Remainder] string reason) { var warningsChannel = Context.Guild.GetTextChannel(Global.PostTargets[PostTarget.WARN_LOG]); var monitor = Context.Message.Author; var entry = new WarnEntry { WarnedUser = user.Username + '#' + user.Discriminator, WarnedUserID = user.Id, WarnedBy = monitor.Username + '#' + monitor.Discriminator, WarnedByID = monitor.Id, Reason = reason, Date = Context.Message.Timestamp.DateTime, }; using (var db = new Database()) { db.Warnings.Add(entry); db.SaveChanges(); } var builder = new EmbedBuilder(); builder.Title = "...a new warning has emerged from outer space!"; builder.Color = new Color(0x3E518); builder.Timestamp = Context.Message.Timestamp; builder.WithFooter(footer => { footer .WithText("Case #" + entry.ID) .WithIconUrl("https://a.kyot.me/0WPy.png"); }); builder.ThumbnailUrl = user.GetAvatarUrl(); builder.WithAuthor(author => { author .WithName("Woah...") .WithIconUrl("https://a.kyot.me/cno0.png"); }); const string discordUrl = "https://discordapp.com/channels/{0}/{1}/{2}"; builder.AddField("Warned User", Extensions.FormatMentionDetailed(user)) .AddField("Warned by", Extensions.FormatMentionDetailed(monitor)) .AddField( "Location of the incident", $"[#{Context.Message.Channel.Name}]({string.Format(discordUrl, Context.Guild.Id, Context.Channel.Id, Context.Message.Id)})") .AddField("Reason", reason ?? "No reason was provided."); var embed = builder.Build(); await warningsChannel.SendMessageAsync(null, embed : embed).ConfigureAwait(false); return(CustomResult.FromSuccess()); }
public async Task <RuntimeResult> WarnAsync(IGuildUser user, [Optional][Remainder] string reason) { if (CommandHandler.FeatureFlagDisabled(FeatureFlag.MODERATION)) { return(CustomResult.FromIgnored()); } var warningsChannel = Context.Guild.GetTextChannel(Global.PostTargets[PostTarget.WARN_LOG]); var monitor = Context.Message.Author; if (reason == null) { reason = "No reason provided"; } var entry = new WarnEntry { WarnedUserID = user.Id, WarnedByID = monitor.Id, Reason = reason, Date = Context.Message.Timestamp.DateTime, }; using (var db = new Database()) { db.Warnings.Add(entry); db.SaveChanges(); } try { const string muteMessage = "You were warned on r/OnePlus for the following reason: {0}"; await user.SendMessageAsync(string.Format(muteMessage, reason)); } catch (HttpException) { await Context.Channel.SendMessageAsync("Seems like user disabled DMs, cannot send message about the warn."); } var builder = new EmbedBuilder(); builder.Title = "...a new warning has emerged from outer space!"; builder.Color = new Color(0x3E518); builder.Timestamp = Context.Message.Timestamp; builder.WithFooter(footer => { footer .WithText("Case #" + entry.ID) .WithIconUrl("https://a.kyot.me/0WPy.png"); }); builder.ThumbnailUrl = user.GetAvatarUrl(); builder.WithAuthor(author => { author .WithName("Woah...") .WithIconUrl("https://a.kyot.me/cno0.png"); }); const string discordUrl = "https://discord.com/channels/{0}/{1}/{2}"; builder.AddField("Warned User", Extensions.FormatMentionDetailed(user)) .AddField("Warned by", Extensions.FormatMentionDetailed(monitor)) .AddField( "Location of the incident", $"[#{Context.Message.Channel.Name}]({string.Format(discordUrl, Context.Guild.Id, Context.Channel.Id, Context.Message.Id)})") .AddField("Reason", reason ?? "No reason was provided."); var embed = builder.Build(); await warningsChannel.SendMessageAsync(null, embed : embed).ConfigureAwait(false); return(CustomResult.FromSuccess()); }