Remove the ability the lookup username history for moderators

This commit is contained in:
runebaas 2020-06-20 03:23:27 +02:00
parent 56f788878a
commit 619f63067c
No known key found for this signature in database
GPG key ID: 2677AF508D0300D6
4 changed files with 3 additions and 44 deletions

View file

@ -1,12 +1,9 @@
using System; using System;
using System.Text;
using System.Threading.Tasks; using System.Threading.Tasks;
using Discord; using Discord;
using Discord.Commands; using Discord.Commands;
using Discord.WebSocket;
using Geekbot.net.Lib.CommandPreconditions; using Geekbot.net.Lib.CommandPreconditions;
using Geekbot.net.Lib.ErrorHandling; using Geekbot.net.Lib.ErrorHandling;
using Geekbot.net.Lib.UserRepository;
namespace Geekbot.net.Commands.Admin namespace Geekbot.net.Commands.Admin
{ {
@ -17,15 +14,11 @@ namespace Geekbot.net.Commands.Admin
[DisableInDirectMessage] [DisableInDirectMessage]
public class Mod : ModuleBase public class Mod : ModuleBase
{ {
private readonly DiscordSocketClient _client;
private readonly IErrorHandler _errorHandler; private readonly IErrorHandler _errorHandler;
private readonly IUserRepository _userRepository;
public Mod(IUserRepository userRepositry, IErrorHandler errorHandler, DiscordSocketClient client) public Mod(IErrorHandler errorHandler)
{ {
_userRepository = userRepositry;
_errorHandler = errorHandler; _errorHandler = errorHandler;
_client = client;
} }
[Command("namehistory", RunMode = RunMode.Async)] [Command("namehistory", RunMode = RunMode.Async)]
@ -34,23 +27,11 @@ namespace Geekbot.net.Commands.Admin
{ {
try try
{ {
var userRepo = _userRepository.Get(user.Id); await Context.Channel.SendMessageAsync("This command has been removed due to low usage and excessively high database usage");
if (userRepo?.UsedNames != null)
{
var sb = new StringBuilder();
sb.AppendLine($":bust_in_silhouette: {user.Username} has been known as:");
foreach (var name in userRepo.UsedNames) sb.AppendLine($"- `{name.Name}`");
await ReplyAsync(sb.ToString());
}
else
{
await ReplyAsync($"No name changes found for {user.Username}");
}
} }
catch (Exception e) catch (Exception e)
{ {
await _errorHandler.HandleCommandException(e, Context, await _errorHandler.HandleCommandException(e, Context);
"I don't have enough permissions do that");
} }
} }
} }

View file

@ -24,7 +24,5 @@ namespace Geekbot.net.Database.Models
public bool IsBot { get; set; } public bool IsBot { get; set; }
public DateTimeOffset Joined { get; set; } public DateTimeOffset Joined { get; set; }
public List<UserUsedNamesModel> UsedNames { get; set; }
} }
} }

View file

@ -1,15 +0,0 @@
using System;
using System.ComponentModel.DataAnnotations;
namespace Geekbot.net.Database.Models
{
public class UserUsedNamesModel
{
[Key]
public int Id { get; set; }
public string Name { get; set; }
public DateTimeOffset FirstSeen { get; set; }
}
}

View file

@ -37,11 +37,6 @@ namespace Geekbot.net.Lib.UserRepository
savedUser.AvatarUrl = user.GetAvatarUrl() ?? ""; savedUser.AvatarUrl = user.GetAvatarUrl() ?? "";
savedUser.IsBot = user.IsBot; savedUser.IsBot = user.IsBot;
savedUser.Joined = user.CreatedAt; savedUser.Joined = user.CreatedAt;
if (savedUser.UsedNames == null) savedUser.UsedNames = new List<UserUsedNamesModel>();
if (!savedUser.UsedNames.Any(e => e.Name.Equals(user.Username)))
{
savedUser.UsedNames.Add(new UserUsedNamesModel { Name = user.Username, FirstSeen = DateTimeOffset.Now });
}
if (isNew) if (isNew)
{ {