cs-codex-dist-tests/Tools/BiblioTech/TokenCommands/GetBalanceCommand.cs

37 lines
1.2 KiB
C#
Raw Normal View History

2023-10-20 07:49:23 +00:00
using CodexContractsPlugin;
using CodexPlugin;
using Core;
using Discord.WebSocket;
using GethPlugin;
namespace BiblioTech.TokenCommands
{
public class GetBalanceCommand : BaseNetCommand
{
private readonly EthAddressOption ethOption = new EthAddressOption();
public GetBalanceCommand(DeploymentsFilesMonitor monitor, CoreInterface ci)
2023-10-20 08:14:56 +00:00
: base(monitor, ci)
2023-10-20 07:49:23 +00:00
{
}
2023-10-22 07:32:03 +00:00
// connect users to eth address!
2023-10-20 07:49:23 +00:00
public override string Name => "balance";
public override string StartingMessage => "Fetching balance...";
2023-10-20 07:49:23 +00:00
public override string Description => "Shows Eth and TestToken balance of an eth address.";
public override CommandOption[] Options => new[] { ethOption };
2023-10-20 08:14:56 +00:00
protected override async Task Execute(SocketSlashCommand command, IGethNode gethNode, ICodexContracts contracts)
2023-10-20 07:49:23 +00:00
{
var addr = await ethOption.Parse(command);
if (addr == null) return;
var eth = gethNode.GetEthBalance(addr);
var testTokens = contracts.GetTestTokenBalance(gethNode, addr);
await command.RespondAsync($"Address '{addr.Address}' has {eth} and {testTokens}.");
}
}
}