diff --git a/Tools/BiblioTech/BaseCommand.cs b/Tools/BiblioTech/BaseCommand.cs index 144d29f..daa59ed 100644 --- a/Tools/BiblioTech/BaseCommand.cs +++ b/Tools/BiblioTech/BaseCommand.cs @@ -22,12 +22,13 @@ namespace BiblioTech try { - await command.RespondAsync(StartingMessage); + await command.RespondAsync(StartingMessage, ephemeral: true); await Invoke(new CommandContext(command, command.Data.Options)); + await command.DeleteOriginalResponseAsync(); } catch (Exception ex) { - await command.FollowupAsync("Something failed while trying to do that..."); + await command.FollowupAsync("Something failed while trying to do that...", ephemeral: true); Console.WriteLine(ex); } } diff --git a/Tools/BiblioTech/BaseNetCommand.cs b/Tools/BiblioTech/BaseNetCommand.cs index 7294e05..15c0010 100644 --- a/Tools/BiblioTech/BaseNetCommand.cs +++ b/Tools/BiblioTech/BaseNetCommand.cs @@ -21,12 +21,12 @@ namespace BiblioTech var deployments = monitor.GetDeployments(); if (deployments.Length == 0) { - await context.Command.FollowupAsync("No deployments are currently available."); + await context.Followup("No deployments are currently available."); return; } if (deployments.Length > 1) { - await context.Command.FollowupAsync("Multiple deployments are online. I don't know which one to pick!"); + await context.Followup("Multiple deployments are online. I don't know which one to pick!"); return; } diff --git a/Tools/BiblioTech/Commands/AdminCommand.cs b/Tools/BiblioTech/Commands/AdminCommand.cs index e9434ac..7869823 100644 --- a/Tools/BiblioTech/Commands/AdminCommand.cs +++ b/Tools/BiblioTech/Commands/AdminCommand.cs @@ -1,6 +1,5 @@ using BiblioTech.Options; using CodexPlugin; -using Discord.WebSocket; namespace BiblioTech.Commands { @@ -38,13 +37,13 @@ namespace BiblioTech.Commands { if (!IsSenderAdmin(context.Command)) { - await context.Command.FollowupAsync("You're not an admin."); + await context.Followup("You're not an admin."); return; } if (!IsInAdminChannel(context.Command)) { - await context.Command.FollowupAsync("Please use admin commands only in the admin channel."); + await context.Followup("Please use admin commands only in the admin channel."); return; } @@ -71,12 +70,12 @@ namespace BiblioTech.Commands var userId = user.GetOptionUserId(context); if (userId == null) { - await context.Command.FollowupAsync("Failed to get user ID"); + await context.AdminFollowup("Failed to get user ID"); return; } Program.UserRepo.ClearUserAssociatedAddress(userId.Value); - await context.Command.FollowupAsync("Done."); + await context.AdminFollowup("Done."); } } @@ -98,12 +97,12 @@ namespace BiblioTech.Commands var userId = user.GetOptionUserId(context); if (userId == null) { - await context.Command.FollowupAsync("Failed to get user ID"); + await context.AdminFollowup("Failed to get user ID"); return; } var report = Program.UserRepo.GetInteractionReport(userId.Value); - await context.Command.FollowupAsync(string.Join(Environment.NewLine, report)); + await context.AdminFollowup(string.Join(Environment.NewLine, report)); } } @@ -123,11 +122,11 @@ namespace BiblioTech.Commands if (!deployments.Any()) { - await context.Command.FollowupAsync("No deployments available."); + await context.AdminFollowup("No deployments available."); return; } - await context.Command.FollowupAsync($"Deployments: {string.Join(", ", deployments.Select(FormatDeployment))}"); + await context.AdminFollowup($"Deployments: {string.Join(", ", deployments.Select(FormatDeployment))}"); } private string FormatDeployment(CodexDeployment deployment) @@ -161,11 +160,11 @@ namespace BiblioTech.Commands var result = await monitor.DownloadDeployment(file); if (result) { - await context.Command.FollowupAsync("Success!"); + await context.AdminFollowup("Success!"); } else { - await context.Command.FollowupAsync("That didn't work."); + await context.AdminFollowup("That didn't work."); } } } @@ -194,11 +193,11 @@ namespace BiblioTech.Commands var result = monitor.DeleteDeployment(str); if (result) { - await context.Command.FollowupAsync("Success!"); + await context.AdminFollowup("Success!"); } else { - await context.Command.FollowupAsync("That didn't work."); + await context.AdminFollowup("That didn't work."); } } } diff --git a/Tools/BiblioTech/Commands/GetBalanceCommand.cs b/Tools/BiblioTech/Commands/GetBalanceCommand.cs index c1fdf07..3181e8a 100644 --- a/Tools/BiblioTech/Commands/GetBalanceCommand.cs +++ b/Tools/BiblioTech/Commands/GetBalanceCommand.cs @@ -29,14 +29,14 @@ namespace BiblioTech.Commands var addr = Program.UserRepo.GetCurrentAddressForUser(userId); if (addr == null) { - await context.Command.FollowupAsync($"No address has been set for this user. Please use '/{userAssociateCommand.Name}' to set it first."); + await context.Followup($"No address has been set for this user. Please use '/{userAssociateCommand.Name}' to set it first."); return; } var eth = gethNode.GetEthBalance(addr); var testTokens = contracts.GetTestTokenBalance(gethNode, addr); - await context.Command.FollowupAsync($"{context.Command.User.Username} has {eth} and {testTokens}."); + await context.Followup($"{context.Command.User.Username} has {eth} and {testTokens}."); } } } diff --git a/Tools/BiblioTech/Commands/MintCommand.cs b/Tools/BiblioTech/Commands/MintCommand.cs index 0483c84..0696954 100644 --- a/Tools/BiblioTech/Commands/MintCommand.cs +++ b/Tools/BiblioTech/Commands/MintCommand.cs @@ -31,7 +31,7 @@ namespace BiblioTech.Commands var addr = Program.UserRepo.GetCurrentAddressForUser(userId); if (addr == null) { - await context.Command.FollowupAsync($"No address has been set for this user. Please use '/{userAssociateCommand.Name}' to set it first."); + await context.Followup($"No address has been set for this user. Please use '/{userAssociateCommand.Name}' to set it first."); return; } @@ -42,7 +42,7 @@ namespace BiblioTech.Commands Program.UserRepo.AddMintEventForUser(userId, addr, sentEth, mintedTokens); - await context.Command.FollowupAsync(string.Join(Environment.NewLine, report)); + await context.Followup(string.Join(Environment.NewLine, report)); } private TestToken ProcessTokens(IGethNode gethNode, ICodexContracts contracts, EthAddress addr, List report) diff --git a/Tools/BiblioTech/Commands/UserAssociateCommand.cs b/Tools/BiblioTech/Commands/UserAssociateCommand.cs index e7bc7dc..3dae10b 100644 --- a/Tools/BiblioTech/Commands/UserAssociateCommand.cs +++ b/Tools/BiblioTech/Commands/UserAssociateCommand.cs @@ -23,7 +23,7 @@ namespace BiblioTech.Commands var currentAddress = Program.UserRepo.GetCurrentAddressForUser(userId); if (currentAddress != null && !IsSenderAdmin(context.Command)) { - await context.Command.FollowupAsync($"You've already set your Ethereum address to {currentAddress}."); + await context.Followup($"You've already set your Ethereum address to {currentAddress}."); return; } @@ -32,11 +32,11 @@ namespace BiblioTech.Commands var result = Program.UserRepo.AssociateUserWithAddress(userId, data); if (result) { - await context.Command.FollowupAsync("Done! Thank you for joining the test net!"); + await context.Followup("Done! Thank you for joining the test net!"); } else { - await context.Command.FollowupAsync("That didn't work."); + await context.Followup("That didn't work."); } } } diff --git a/Tools/BiblioTech/Options/CommandContext.cs b/Tools/BiblioTech/Options/CommandContext.cs index 5d37087..186bf2f 100644 --- a/Tools/BiblioTech/Options/CommandContext.cs +++ b/Tools/BiblioTech/Options/CommandContext.cs @@ -12,5 +12,15 @@ namespace BiblioTech.Options public SocketSlashCommand Command { get; } public IReadOnlyCollection Options { get; } + + public async Task Followup(string message) + { + await Command.FollowupAsync(message, ephemeral: true); + } + + public async Task AdminFollowup(string message) + { + await Command.FollowupAsync(message); + } } } diff --git a/Tools/BiblioTech/Options/EthAddressOption.cs b/Tools/BiblioTech/Options/EthAddressOption.cs index 3105fd9..e0ac77f 100644 --- a/Tools/BiblioTech/Options/EthAddressOption.cs +++ b/Tools/BiblioTech/Options/EthAddressOption.cs @@ -18,13 +18,13 @@ namespace BiblioTech.Options var ethOptionData = context.Options.SingleOrDefault(o => o.Name == Name); if (ethOptionData == null) { - await context.Command.FollowupAsync("EthAddress option not received."); + await context.Followup("EthAddress option not received."); return null; } var ethAddressStr = ethOptionData.Value as string; if (string.IsNullOrEmpty(ethAddressStr)) { - await context.Command.FollowupAsync("EthAddress is null or empty."); + await context.Followup("EthAddress is null or empty."); return null; } @@ -32,7 +32,7 @@ namespace BiblioTech.Options !AddressUtil.Current.IsValidEthereumAddressHexFormat(ethAddressStr)) // !AddressUtil.Current.IsChecksumAddress(ethAddressStr)) - this might make a good option later, but for now it might just annoy users. { - await context.Command.FollowupAsync("EthAddress is not valid."); + await context.Followup("EthAddress is not valid."); return null; } diff --git a/Tools/BiblioTech/Options/FileAttachementOption.cs b/Tools/BiblioTech/Options/FileAttachementOption.cs index d759811..3745823 100644 --- a/Tools/BiblioTech/Options/FileAttachementOption.cs +++ b/Tools/BiblioTech/Options/FileAttachementOption.cs @@ -14,13 +14,13 @@ namespace BiblioTech.Options var fileOptionData = context.Options.SingleOrDefault(o => o.Name == Name); if (fileOptionData == null) { - await context.Command.FollowupAsync("Attachement option not received."); + await context.Followup("Attachement option not received."); return null; } var attachement = fileOptionData.Value as IAttachment; if (attachement == null) { - await context.Command.FollowupAsync("Attachement is null or empty."); + await context.Followup("Attachement is null or empty."); return null; } diff --git a/Tools/BiblioTech/Options/StringOption.cs b/Tools/BiblioTech/Options/StringOption.cs index 3782035..15e04c9 100644 --- a/Tools/BiblioTech/Options/StringOption.cs +++ b/Tools/BiblioTech/Options/StringOption.cs @@ -14,7 +14,7 @@ namespace BiblioTech.Options var strData = context.Options.SingleOrDefault(o => o.Name == Name); if (strData == null) { - await context.Command.FollowupAsync("String option not received."); + await context.Followup("String option not received."); return null; } return strData.Value as string;