cs-codex-dist-tests/Tools/BiblioTech/Commands/ClearUserAssociationCommand.cs

36 lines
1.2 KiB
C#
Raw Normal View History

2023-10-22 08:10:52 +00:00
using Discord.WebSocket;
2023-10-22 08:38:46 +00:00
namespace BiblioTech.Commands
2023-10-22 08:10:52 +00:00
{
public class ClearUserAssociationCommand : BaseCommand
{
private readonly UserOption user = new UserOption(
description: "User to clear Eth address for.",
isRequired: true);
public override string Name => "clear";
public override string StartingMessage => "Hold on...";
public override string Description => "Admin only. Clears current Eth address for a user, allowing them to set a new one.";
2023-10-22 09:10:45 +00:00
public override CommandOption[] Options => new[] { user };
2023-10-22 08:10:52 +00:00
protected override async Task Invoke(SocketSlashCommand command)
{
if (!IsSenderAdmin(command))
{
await command.FollowupAsync("You're not an admin.");
return;
}
var userId = user.GetOptionUserId(command);
if (userId == null)
{
await command.FollowupAsync("Failed to get user ID");
return;
}
Program.UserRepo.ClearUserAssociatedAddress(userId.Value);
await command.FollowupAsync("Done."); ;
}
}
}