Replace About message; remove zone option in set command

Regarding the latter, it led to a lot of confusion whenever anyone got the command wrong.
This commit is contained in:
Noi 2021-10-13 19:29:24 -07:00
parent 665c767cea
commit b0fcd19710
2 changed files with 10 additions and 37 deletions

View file

@ -171,9 +171,9 @@ namespace BirthdayBot.UserInterface
// TODO this message needs an overhaul // TODO this message needs an overhaul
Description = "For more information regarding support, data retention, privacy, and other details, please refer to: " Description = "For more information regarding support, data retention, privacy, and other details, please refer to: "
+ "https://github.com/NoiTheCat/BirthdayBot/blob/master/Readme.md" + "\n\n" + "https://github.com/NoiTheCat/BirthdayBot/blob/master/Readme.md" + "\n\n"
+ "This bot is provided for free, without any intention to add premium, pay-only features. " + "This bot is provided for free, without any paywalled 'premium' features. "
+ "If you find this bot helpful, please consider contributing towards my operating costs " + "If you've found this bot useful, please consider contributing via the "
+ "via Patreon: https://www.patreon.com/noibots." + "bot author's page on Ko-fi: https://ko-fi.com/noithecat."
}.AddField(new EmbedFieldBuilder() }.AddField(new EmbedFieldBuilder()
{ {
Name = "Statistics", Name = "Statistics",

View file

@ -118,8 +118,8 @@ namespace BirthdayBot.UserInterface
#region Documentation #region Documentation
public static readonly CommandDocumentation DocSet = public static readonly CommandDocumentation DocSet =
new CommandDocumentation(new string[] { "set (date) [zone]" }, "Registers your birth date. Time zone is optional.", new CommandDocumentation(new string[] { "set (date)" }, "Registers your birth month and day.",
$"`{CommandPrefix}set jan-31`, `{CommandPrefix}set 15-aug America/Los_Angeles`."); $"`{CommandPrefix}set jan-31`, `{CommandPrefix}set 15 may`.");
public static readonly CommandDocumentation DocZone = public static readonly CommandDocumentation DocZone =
new CommandDocumentation(new string[] { "zone (zone)" }, "Sets your local time zone. " new CommandDocumentation(new string[] { "zone (zone)" }, "Sets your local time zone. "
+ $"See also `{CommandPrefix}help-tzdata`.", null); + $"See also `{CommandPrefix}help-tzdata`.", null);
@ -130,35 +130,16 @@ namespace BirthdayBot.UserInterface
private async Task CmdSet(ShardInstance instance, GuildConfiguration gconf, private async Task CmdSet(ShardInstance instance, GuildConfiguration gconf,
string[] param, SocketTextChannel reqChannel, SocketGuildUser reqUser) string[] param, SocketTextChannel reqChannel, SocketGuildUser reqUser)
{ {
// Requires *some* parameter.
if (param.Length < 2) if (param.Length < 2)
{ {
await reqChannel.SendMessageAsync(ParameterError, embed: DocSet.UsageEmbed).ConfigureAwait(false); await reqChannel.SendMessageAsync(ParameterError, embed: DocSet.UsageEmbed).ConfigureAwait(false);
return; return;
} }
// Date format accepts spaces, and then we look for an additional parameter. // Date format accepts spaces. Must coalesce parameters to a single string.
// This is weird. Gotta compensate.
var fullinput = ""; var fullinput = "";
for (int i = 1; i < param.Length; i++) foreach (var p in param[1..]) fullinput += " " + p;
{ fullinput = fullinput[1..]; // trim leading space
fullinput += " " + param[i];
}
fullinput = fullinput[1..];
// Attempt to get last "parameter"; check if it's a time zone value
string timezone = null;
var fli = fullinput.LastIndexOf(' ');
if (fli != -1)
{
var tzstring = fullinput[(fli+1)..];
try
{
timezone = ParseTimeZone(tzstring);
// If we got here, last parameter was indeed a time zone. Trim it away for what comes next.
fullinput = fullinput[0..fli];
}
catch (FormatException) { } // Was not a time zone name. Do nothing.
}
int bmonth, bday; int bmonth, bday;
try try
@ -178,7 +159,7 @@ namespace BirthdayBot.UserInterface
{ {
var user = await GuildUserConfiguration.LoadAsync(gconf.GuildId, reqUser.Id).ConfigureAwait(false); var user = await GuildUserConfiguration.LoadAsync(gconf.GuildId, reqUser.Id).ConfigureAwait(false);
known = user.IsKnown; known = user.IsKnown;
await user.UpdateAsync(bmonth, bday, timezone).ConfigureAwait(false); await user.UpdateAsync(bmonth, bday, user.TimeZone).ConfigureAwait(false);
} }
catch (Exception ex) catch (Exception ex)
{ {
@ -187,16 +168,8 @@ namespace BirthdayBot.UserInterface
reqChannel.SendMessageAsync(InternalError).Wait(); reqChannel.SendMessageAsync(InternalError).Wait();
return; return;
} }
if (known) await reqChannel.SendMessageAsync($":white_check_mark: Your birthday has been { (known ? "updated" : "recorded") }.")
{
await reqChannel.SendMessageAsync(":white_check_mark: Your information has been updated.")
.ConfigureAwait(false); .ConfigureAwait(false);
}
else
{
await reqChannel.SendMessageAsync(":white_check_mark: Your birthday has been recorded.")
.ConfigureAwait(false);
}
} }
private async Task CmdZone(ShardInstance instance, GuildConfiguration gconf, private async Task CmdZone(ShardInstance instance, GuildConfiguration gconf,