2017-10-27 00:18:58 +02:00
|
|
|
|
using System;
|
|
|
|
|
using System.Text;
|
|
|
|
|
using System.Threading.Tasks;
|
|
|
|
|
using Discord;
|
|
|
|
|
using Discord.Commands;
|
2017-10-30 18:35:08 +01:00
|
|
|
|
using Discord.WebSocket;
|
2018-05-03 00:56:06 +02:00
|
|
|
|
using Geekbot.net.Lib.ErrorHandling;
|
|
|
|
|
using Geekbot.net.Lib.UserRepository;
|
2017-10-27 00:18:58 +02:00
|
|
|
|
|
2018-05-03 00:56:06 +02:00
|
|
|
|
namespace Geekbot.net.Commands.Admin
|
2017-10-27 00:18:58 +02:00
|
|
|
|
{
|
|
|
|
|
[Group("mod")]
|
|
|
|
|
[RequireUserPermission(GuildPermission.KickMembers)]
|
|
|
|
|
[RequireUserPermission(GuildPermission.ManageMessages)]
|
|
|
|
|
[RequireUserPermission(GuildPermission.ManageRoles)]
|
|
|
|
|
public class Mod : ModuleBase
|
|
|
|
|
{
|
2017-12-29 01:53:50 +01:00
|
|
|
|
private readonly DiscordSocketClient _client;
|
2017-10-27 00:18:58 +02:00
|
|
|
|
private readonly IErrorHandler _errorHandler;
|
2017-12-29 01:53:50 +01:00
|
|
|
|
private readonly IUserRepository _userRepository;
|
|
|
|
|
|
2018-05-13 17:49:13 +02:00
|
|
|
|
public Mod(IUserRepository userRepositry, IErrorHandler errorHandler, DiscordSocketClient client)
|
2017-10-27 00:18:58 +02:00
|
|
|
|
{
|
|
|
|
|
_userRepository = userRepositry;
|
|
|
|
|
_errorHandler = errorHandler;
|
2017-10-30 18:35:08 +01:00
|
|
|
|
_client = client;
|
2017-10-27 00:18:58 +02:00
|
|
|
|
}
|
2017-12-29 01:53:50 +01:00
|
|
|
|
|
2017-10-27 00:18:58 +02:00
|
|
|
|
[Command("namehistory", RunMode = RunMode.Async)]
|
|
|
|
|
[Summary("See past usernames of an user")]
|
2018-04-30 23:44:19 +02:00
|
|
|
|
public async Task UsernameHistory([Summary("@user")] IUser user)
|
2017-10-27 00:18:58 +02:00
|
|
|
|
{
|
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
var userRepo = _userRepository.Get(user.Id);
|
|
|
|
|
var sb = new StringBuilder();
|
|
|
|
|
sb.AppendLine($":bust_in_silhouette: {user.Username} has been known as:");
|
2018-05-19 10:49:01 +02:00
|
|
|
|
foreach (var name in userRepo.UsedNames) sb.AppendLine($"- `{name.Name}`");
|
2017-10-27 00:18:58 +02:00
|
|
|
|
await ReplyAsync(sb.ToString());
|
|
|
|
|
}
|
|
|
|
|
catch (Exception e)
|
|
|
|
|
{
|
2018-06-13 22:18:57 +02:00
|
|
|
|
await _errorHandler.HandleCommandException(e, Context,
|
2018-05-04 00:55:32 +02:00
|
|
|
|
$"I don't have enough permissions do that");
|
2017-10-30 18:35:08 +01:00
|
|
|
|
}
|
|
|
|
|
}
|
2017-10-27 00:18:58 +02:00
|
|
|
|
}
|
|
|
|
|
}
|