Reorganize help strings

This commit is contained in:
Noi 2022-03-10 15:37:34 -08:00
parent a58cedad88
commit ccb56ed243
4 changed files with 27 additions and 23 deletions

View file

@ -5,23 +5,23 @@ using System.Text;
namespace BirthdayBot.ApplicationCommands;
[RequireContext(ContextType.Guild)]
[Group("birthday", "Commands relating to birthdays.")]
[Group("birthday", HelpCmdBirthday)]
public class BirthdayModule : BotModuleBase {
public const string HelpExport = "Generates a text file with all known and available birthdays.";
public const string HelpGet = "Gets a user's birthday.";
public const string HelpRecentUpcoming = "Get a list of users who recently had or will have a birthday.";
public const string HelpRemove = "Removes your birthday information from this bot.";
public const string HelpCmdBirthday = "Commands relating to birthdays.";
public const string HelpCmdSetDate = "Sets or updates your birthday.";
public const string HelpCmdSetZone = "Sets or updates your time zone if your birthday is already set.";
public const string HelpCmdRemove = "Removes your birthday information from this bot.";
public const string HelpCmdGet = "Gets a user's birthday.";
public const string HelpCmdNearest = "Get a list of users who recently had or will have a birthday.";
public const string HelpCmdExport = "Generates a text file with all known and available birthdays.";
// Note that these methods have largely been copied to BirthdayOverrideModule. Changes here should be reflected there as needed.
[Group("set", "Subcommands for setting birthday information.")]
public class SubCmdsBirthdaySet : BotModuleBase {
public const string HelpSetBday = "Sets or updates your birthday.";
public const string HelpSetZone = "Sets or updates your time zone, when your birthday is already set.";
[SlashCommand("date", HelpSetBday)]
[SlashCommand("date", HelpCmdSetDate)]
public async Task CmdSetBday([Summary(description: HelpOptDate)] string date,
[Summary(description: HelpOptPfxOptional + HelpOptZone)] string? zone = null) {
[Summary(description: HelpOptZone)] string? zone = null) {
int inmonth, inday;
try {
(inmonth, inday) = ParseDate(date);
@ -48,7 +48,7 @@ public class BirthdayModule : BotModuleBase {
(inzone == null ? "" : $", with time zone {inzone}") + ".").ConfigureAwait(false);
}
[SlashCommand("zone", HelpSetZone)]
[SlashCommand("timezone", HelpCmdSetZone)]
public async Task CmdSetZone([Summary(description: HelpOptZone)] string zone) {
var user = await ((SocketGuildUser)Context.User).GetConfigAsync().ConfigureAwait(false);
if (!user.IsKnown) {
@ -68,7 +68,7 @@ public class BirthdayModule : BotModuleBase {
}
}
[SlashCommand("remove", HelpRemove)]
[SlashCommand("remove", HelpCmdRemove)]
public async Task CmdRemove() {
var user = await ((SocketGuildUser)Context.User).GetConfigAsync().ConfigureAwait(false);
if (user.IsKnown) {
@ -100,7 +100,7 @@ public class BirthdayModule : BotModuleBase {
// "Recent and upcoming birthdays"
// The 'recent' bit removes time zone ambiguity and spares us from extra time zone processing here
// TODO stop being lazy
[SlashCommand("show-nearest", HelpRecentUpcoming)]
[SlashCommand("show-nearest", HelpCmdNearest)]
public async Task CmdShowNearest() {
if (!await HasMemberCacheAsync(Context.Guild).ConfigureAwait(false)) {
await RespondAsync(MemberCacheEmptyError, ephemeral: true);
@ -175,7 +175,7 @@ public class BirthdayModule : BotModuleBase {
}
[RequireBotModerator]
[SlashCommand("export", HelpPfxModOnly + HelpExport)]
[SlashCommand("export", HelpPfxModOnly + HelpCmdGet)]
public async Task CmdExport([Summary(description: "Specify whether to export the list in CSV format.")] bool asCsv = false) {
if (!await HasMemberCacheAsync(Context.Guild)) {
await RespondAsync(MemberCacheEmptyError).ConfigureAwait(false);
@ -229,7 +229,7 @@ public class BirthdayModule : BotModuleBase {
return result;
}
private Stream ListExportNormal(SocketGuild guild, IEnumerable<ListItem> list) {
private static Stream ListExportNormal(SocketGuild guild, IEnumerable<ListItem> list) {
// Output: "● Mon-dd: (user ID) Username [ - Nickname: (nickname)]"
var result = new MemoryStream();
var writer = new StreamWriter(result, Encoding.UTF8);
@ -250,7 +250,7 @@ public class BirthdayModule : BotModuleBase {
return result;
}
private Stream ListExportCsv(SocketGuild guild, IEnumerable<ListItem> list) {
private static Stream ListExportCsv(SocketGuild guild, IEnumerable<ListItem> list) {
// Output: User ID, Username, Nickname, Month-Day, Month, Day
var result = new MemoryStream();
var writer = new StreamWriter(result, Encoding.UTF8);

View file

@ -5,8 +5,9 @@ namespace BirthdayBot.ApplicationCommands;
[RequireContext(ContextType.Guild)]
[RequireBotModerator]
[Group("override", "Run certain commands on behalf of other users.")]
[Group("override", HelpCmdOverride)]
public class BirthdayOverrideModule : BotModuleBase {
public const string HelpCmdOverride = "Commands to set options for other users.";
const string HelpOptOvTarget = "The user whose data to modify.";
// Note that these methods have largely been copied from BirthdayModule. Changes there should be reflected here as needed.

View file

@ -17,7 +17,6 @@ public abstract class BotModuleBase : InteractionModuleBase<SocketInteractionCon
protected const string MemberCacheEmptyError = ":warning: Please try the command again.";
public const string AccessDeniedError = ":warning: You are not allowed to run this command.";
protected const string HelpOptPfxOptional = "Optional: ";
protected const string HelpOptDate = "A date, including the month and day. For example, \"15 January\".";
protected const string HelpOptZone = "A 'tzdata'-compliant time zone name. See help for more details.";

View file

@ -6,13 +6,18 @@ namespace BirthdayBot.ApplicationCommands;
[RequireContext(ContextType.Guild)]
[RequireBotModerator]
[Group("config", "Configure basic settings for the bot.")]
[Group("config", HelpCmdConfig)]
public class ConfigModule : BotModuleBase {
public const string HelpCmdConfig = "Configure basic settings for the bot.";
public const string HelpCmdAnnounce = "Settings regarding birthday announcements.";
public const string HelpCmdRole = "Settings for roles used by this bot.";
public const string HelpCmdCheck = "Test the bot's current configuration and show the results.";
const string HelpPofxBlankUnset = " Leave blank to unset.";
const string HelpOptChannel = "The corresponding channel to use.";
const string HelpOptRole = "The corresponding role to use.";
[Group("announce", HelpPfxModOnly + "Configure settings regarding birthday announcements.")]
[Group("announce", HelpPfxModOnly + HelpCmdAnnounce)]
public class SubCmdsConfigAnnounce : BotModuleBase {
[SlashCommand("help", "Show information regarding announcement messages.")]
public async Task CmdAnnounceHelp() {
@ -33,7 +38,6 @@ public class ConfigModule : BotModuleBase {
[SlashCommand("set-message", HelpPfxModOnly + "Modify the announcement message.")]
public async Task CmdSetMessage() {
// TODO fully implement this
// idea: ephemeral message prints on command use, then a modal appears. though maybe this isn't really possible...
await RespondAsync("Sorry, changing the announcement message via slash commands is not yet available. " +
"Please use the corresponding text command.", ephemeral: true);
}
@ -47,7 +51,7 @@ public class ConfigModule : BotModuleBase {
}
}
[Group("role", HelpPfxModOnly + "Configure settings regarding roles used by this bot.")]
[Group("role", HelpPfxModOnly + HelpCmdRole)]
public class SubCmdsConfigRole : BotModuleBase {
[SlashCommand("set-birthday-role", HelpPfxModOnly + "Set the role given to users having a birthday.")]
public async Task CmdSetBRole([Summary(description: HelpOptRole)] SocketRole role) {
@ -67,7 +71,7 @@ public class ConfigModule : BotModuleBase {
}
}
[SlashCommand("check", HelpPfxModOnly + "Test the bot's current configuration and show the results.")]
[SlashCommand("check", HelpPfxModOnly + HelpCmdCheck)]
public async Task CmdCheck() {
static string DoTestFor(string label, Func<bool> test) => $"{label}: { (test() ? ":white_check_mark: Yes" : ":x: No") }";
var result = new StringBuilder();