mirror of
https://github.com/NoiTheCat/BirthdayBot.git
synced 2024-11-24 01:14:12 +00:00
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:
parent
665c767cea
commit
b0fcd19710
2 changed files with 10 additions and 37 deletions
|
@ -171,9 +171,9 @@ namespace BirthdayBot.UserInterface
|
|||
// TODO this message needs an overhaul
|
||||
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"
|
||||
+ "This bot is provided for free, without any intention to add premium, pay-only features. "
|
||||
+ "If you find this bot helpful, please consider contributing towards my operating costs "
|
||||
+ "via Patreon: https://www.patreon.com/noibots."
|
||||
+ "This bot is provided for free, without any paywalled 'premium' features. "
|
||||
+ "If you've found this bot useful, please consider contributing via the "
|
||||
+ "bot author's page on Ko-fi: https://ko-fi.com/noithecat."
|
||||
}.AddField(new EmbedFieldBuilder()
|
||||
{
|
||||
Name = "Statistics",
|
||||
|
|
|
@ -118,8 +118,8 @@ namespace BirthdayBot.UserInterface
|
|||
|
||||
#region Documentation
|
||||
public static readonly CommandDocumentation DocSet =
|
||||
new CommandDocumentation(new string[] { "set (date) [zone]" }, "Registers your birth date. Time zone is optional.",
|
||||
$"`{CommandPrefix}set jan-31`, `{CommandPrefix}set 15-aug America/Los_Angeles`.");
|
||||
new CommandDocumentation(new string[] { "set (date)" }, "Registers your birth month and day.",
|
||||
$"`{CommandPrefix}set jan-31`, `{CommandPrefix}set 15 may`.");
|
||||
public static readonly CommandDocumentation DocZone =
|
||||
new CommandDocumentation(new string[] { "zone (zone)" }, "Sets your local time zone. "
|
||||
+ $"See also `{CommandPrefix}help-tzdata`.", null);
|
||||
|
@ -130,35 +130,16 @@ namespace BirthdayBot.UserInterface
|
|||
private async Task CmdSet(ShardInstance instance, GuildConfiguration gconf,
|
||||
string[] param, SocketTextChannel reqChannel, SocketGuildUser reqUser)
|
||||
{
|
||||
// Requires *some* parameter.
|
||||
if (param.Length < 2)
|
||||
{
|
||||
await reqChannel.SendMessageAsync(ParameterError, embed: DocSet.UsageEmbed).ConfigureAwait(false);
|
||||
return;
|
||||
}
|
||||
|
||||
// Date format accepts spaces, and then we look for an additional parameter.
|
||||
// This is weird. Gotta compensate.
|
||||
// Date format accepts spaces. Must coalesce parameters to a single string.
|
||||
var fullinput = "";
|
||||
for (int i = 1; i < param.Length; i++)
|
||||
{
|
||||
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.
|
||||
}
|
||||
foreach (var p in param[1..]) fullinput += " " + p;
|
||||
fullinput = fullinput[1..]; // trim leading space
|
||||
|
||||
int bmonth, bday;
|
||||
try
|
||||
|
@ -178,7 +159,7 @@ namespace BirthdayBot.UserInterface
|
|||
{
|
||||
var user = await GuildUserConfiguration.LoadAsync(gconf.GuildId, reqUser.Id).ConfigureAwait(false);
|
||||
known = user.IsKnown;
|
||||
await user.UpdateAsync(bmonth, bday, timezone).ConfigureAwait(false);
|
||||
await user.UpdateAsync(bmonth, bday, user.TimeZone).ConfigureAwait(false);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
|
@ -187,17 +168,9 @@ namespace BirthdayBot.UserInterface
|
|||
reqChannel.SendMessageAsync(InternalError).Wait();
|
||||
return;
|
||||
}
|
||||
if (known)
|
||||
{
|
||||
await reqChannel.SendMessageAsync(":white_check_mark: Your information has been updated.")
|
||||
await reqChannel.SendMessageAsync($":white_check_mark: Your birthday has been { (known ? "updated" : "recorded") }.")
|
||||
.ConfigureAwait(false);
|
||||
}
|
||||
else
|
||||
{
|
||||
await reqChannel.SendMessageAsync(":white_check_mark: Your birthday has been recorded.")
|
||||
.ConfigureAwait(false);
|
||||
}
|
||||
}
|
||||
|
||||
private async Task CmdZone(ShardInstance instance, GuildConfiguration gconf,
|
||||
string[] param, SocketTextChannel reqChannel, SocketGuildUser reqUser)
|
||||
|
|
Loading…
Reference in a new issue