private async Task MessageCounter(SocketMessage arg) { // Check if we are in a guild if (arg.Channel is SocketTextChannel channel) // Liege fat { if (arg.Author.IsBot) { return; } if (channel.Guild.Id != Global.SwissGuildId) { return; } // Check if author cuck is staff var user = await Global.GetSwissbotUser(arg.Author.Id); if (user == null) { return; } if (user.Hierarchy >= Global.ModeratorRole.Position) { if (ChannelBlacklists.Any(x => x == arg.Channel.Id)) { return; } var member = StaffMember.GetOrCreateStaffMember(user); member.AddMessageRecord(arg); } } }
private async Task Client_InteractionCreated(SocketInteraction arg) { if (arg.Data.Name == "staff-activity") { if (!Program.UserHasPerm(arg.Member)) { await arg.FollowupAsync("No... Bad!"); return; } if (arg.Data.Options.Count == 1) { var opt = arg.Data.Options.First(); switch (opt.Name) { case "blacklist": { if (!(arg.Member.Roles.Any(x => x.Id == 592464345322094593) || arg.Member.Id == 259053800755691520)) { await arg.FollowupAsync("No... Bad!"); return; } var sub = opt.Options.First(); switch (sub.Name) { case "add": { var channel = ulong.Parse(sub.Options.First().Value.ToString()); if (ChannelBlacklists.Any(x => x == channel)) { await arg.FollowupAsync("", false, new EmbedBuilder() { Title = "Can't do that!", Description = $"The channel <#{channel}> is already in the blacklist.", Color = Color.Red }.Build()); return; } ChannelBlacklists.Add(channel); SaveBlacklist(); await arg.FollowupAsync("", false, new EmbedBuilder() { Title = "Done!", Description = $"The channel <#{channel}> is now in the blacklist.", Color = Color.Green, }.Build()); return; } case "remove": { var channel = ulong.Parse(sub.Options.First().Value.ToString()); if (!ChannelBlacklists.Any(x => x == channel)) { await arg.FollowupAsync("", false, new EmbedBuilder() { Title = "Can't do that!", Description = $"The channel <#{channel}> is not in the blacklist.", Color = Color.Red }.Build()); return; } ChannelBlacklists.Remove(channel); SaveBlacklist(); await arg.FollowupAsync("", false, new EmbedBuilder() { Title = "Done!", Description = $"The channel <#{channel}> is now removed from the blacklist.", Color = Color.Green, }.Build()); return; } case "list": List <string> channels = new List <string>(); foreach (var item in ChannelBlacklists) { var chan = Global.SwissGuild.GetChannel(item); if (chan == null) { channels.Add($"{item} - #unknown"); } else { channels.Add($"{item} - #{chan.Name}"); } } await arg.FollowupAsync("", false, new EmbedBuilder() { Title = "Blacklist", Description = channels.Count > 0 ? $"Here's the channel blacklist:\n```\n{string.Join("\n", channels)}```" : "There are no blacklisted channels", }.Build()); break; } } break; case "check": { var id = ulong.Parse(opt.Options.First().Value.ToString()); var user = await Global.GetSwissbotUser(id); var record = StaffMember.GetStaffMember(id); if (record == null || user == null) { await arg.FollowupAsync("", false, new EmbedBuilder() { Title = "404, suck me off", Description = $"The user <@{id}> does not have any messages on record. Either they are not staff or they have 0 messages :/", Color = Color.Red }.Build()); return; } var av = user.GetAvatarUrl(); if (av == null) { av = user.GetDefaultAvatarUrl(); } await arg.RespondAsync("", false, new EmbedBuilder() { Author = new EmbedAuthorBuilder() { Name = user.ToString(), Url = av }, Title = "Message count", Description = $"Here's the message count for <@{id}>", Fields = new List <EmbedFieldBuilder>() { new EmbedFieldBuilder() { Name = "Past 24 Hours:", Value = $"> {record.GetMessageCount(DateTime.UtcNow.AddDays(-1))}" }, new EmbedFieldBuilder() { Name = "Past 7 Days:", Value = $"> {record.GetMessageCount(DateTime.UtcNow.AddDays(-7))}" }, new EmbedFieldBuilder() { Name = "Past 31 Days:", Value = $"> {record.GetMessageCount(DateTime.UtcNow.AddDays(-31))}" }, new EmbedFieldBuilder() { Name = "Infractions", Value = $"{(record.Infractions.Any() ? $"```\n{string.Join("\n", record.Infractions.Select(x => $"{x.Date.ToString("R")} - {x.Count}/{x.MinimumAtTime}"))}```" : "none")}" } }, Color = Color.Green }.WithCurrentTimestamp().Build()); } break; case "settings": { if (!(arg.Member.Roles.Any(x => x.Id == 592464345322094593) || arg.Member.Id == 259053800755691520)) { await arg.FollowupAsync("No... Bad!"); return; } var sub = opt.Options.First(); switch (sub.Name) { case "minimum-messages": if (sub.Options == null) { await arg.FollowupAsync("", false, new EmbedBuilder() { Title = "Minimum Messages", Description = $"The minimum messages per week is currently set at {Settings.MinimumMessages}", Color = Color.Green, }.Build()); return; } else { var c = int.Parse(sub.Options.First().Value.ToString()); Settings.MinimumMessages = c; SaveSettings(); await arg.FollowupAsync("", false, new EmbedBuilder() { Title = "Success!", Description = $"The minimum messages per week is now set at {Settings.MinimumMessages}", Color = Color.Green, }.Build()); return; } } break; } } } } }