mirror of
https://github.com/TeamOctolings/Octobot.git
synced 2025-01-31 00:19:00 +03:00
/remind: Switch away from zero-based numbering and rename index
(#155)
Signed-off-by: Macintosh II <mctaylxrs@outlook.com>
This commit is contained in:
parent
a70c228bc4
commit
d1e3558bc6
5 changed files with 26 additions and 24 deletions
|
@ -453,8 +453,8 @@
|
|||
<data name="ReminderList" xml:space="preserve">
|
||||
<value>{0}'s reminders</value>
|
||||
</data>
|
||||
<data name="InvalidReminderIndex" xml:space="preserve">
|
||||
<value>There's no reminder with that index!</value>
|
||||
<data name="InvalidReminderPosition" xml:space="preserve">
|
||||
<value>There's no reminder in this position!</value>
|
||||
</data>
|
||||
<data name="ReminderDeleted" xml:space="preserve">
|
||||
<value>Reminder deleted</value>
|
||||
|
@ -474,8 +474,8 @@
|
|||
<data name="DescriptionActionJumpToChannel" xml:space="preserve">
|
||||
<value>Jump to channel: {0}</value>
|
||||
</data>
|
||||
<data name="ReminderIndex" xml:space="preserve">
|
||||
<value>Index: {0}</value>
|
||||
<data name="ReminderPosition" xml:space="preserve">
|
||||
<value>Position in list: {0}</value>
|
||||
</data>
|
||||
<data name="ReminderWillBeSentOn" xml:space="preserve">
|
||||
<value>The reminder will be sent on: {0}</value>
|
||||
|
|
|
@ -453,8 +453,8 @@
|
|||
<data name="ReminderList" xml:space="preserve">
|
||||
<value>Напоминания {0}</value>
|
||||
</data>
|
||||
<data name="InvalidReminderIndex" xml:space="preserve">
|
||||
<value>У тебя нет напоминания с указанным индексом!</value>
|
||||
<data name="InvalidReminderPosition" xml:space="preserve">
|
||||
<value>У тебя нет напоминания на этой позиции!</value>
|
||||
</data>
|
||||
<data name="ReminderDeleted" xml:space="preserve">
|
||||
<value>Напоминание удалено</value>
|
||||
|
@ -474,8 +474,8 @@
|
|||
<data name="DescriptionActionJumpToChannel" xml:space="preserve">
|
||||
<value>Перейти к каналу: {0}</value>
|
||||
</data>
|
||||
<data name="ReminderIndex" xml:space="preserve">
|
||||
<value>Индекс: {0}</value>
|
||||
<data name="ReminderPosition" xml:space="preserve">
|
||||
<value>Позиция в списке: {0}</value>
|
||||
</data>
|
||||
<data name="ReminderWillBeSentOn" xml:space="preserve">
|
||||
<value>Напоминание будет отправлено: {0}</value>
|
||||
|
|
|
@ -453,8 +453,8 @@
|
|||
<data name="ReminderList" xml:space="preserve">
|
||||
<value>напоминалки {0}</value>
|
||||
</data>
|
||||
<data name="InvalidReminderIndex" xml:space="preserve">
|
||||
<value>у тебя нет напоминалки с этим индексом!</value>
|
||||
<data name="InvalidReminderPosition" xml:space="preserve">
|
||||
<value>у тебя нет напоминалки на этом номере!</value>
|
||||
</data>
|
||||
<data name="ReminderDeleted" xml:space="preserve">
|
||||
<value>напоминалка уничтожена</value>
|
||||
|
@ -474,8 +474,8 @@
|
|||
<data name="DescriptionActionJumpToChannel" xml:space="preserve">
|
||||
<value>чекнуть канал: {0}</value>
|
||||
</data>
|
||||
<data name="ReminderIndex" xml:space="preserve">
|
||||
<value>индекс: {0}</value>
|
||||
<data name="ReminderPosition" xml:space="preserve">
|
||||
<value>номер в списке: {0}</value>
|
||||
</data>
|
||||
<data name="ReminderWillBeSentOn" xml:space="preserve">
|
||||
<value>я пну тебе это: {0}</value>
|
||||
|
|
|
@ -88,7 +88,7 @@ public class RemindCommandGroup : CommandGroup
|
|||
for (var i = 0; i < data.Reminders.Count; i++)
|
||||
{
|
||||
var reminder = data.Reminders[i];
|
||||
builder.Append("- ").AppendLine(string.Format(Messages.ReminderIndex, Markdown.InlineCode(i.ToString())))
|
||||
builder.Append("- ").AppendLine(string.Format(Messages.ReminderPosition, Markdown.InlineCode((i + 1).ToString())))
|
||||
.Append(" - ").AppendLine(string.Format(Messages.ReminderText, Markdown.InlineCode(reminder.Text)))
|
||||
.Append(" - ")
|
||||
.AppendLine(string.Format(Messages.ReminderWillBeSentOn, Markdown.Timestamp(reminder.At)));
|
||||
|
@ -142,8 +142,9 @@ public class RemindCommandGroup : CommandGroup
|
|||
Snowflake channelId, IUser executor, CancellationToken ct = default)
|
||||
{
|
||||
var remindAt = DateTimeOffset.UtcNow.Add(@in);
|
||||
var memberData = data.GetOrCreateMemberData(executor.ID);
|
||||
|
||||
data.GetOrCreateMemberData(executor.ID).Reminders.Add(
|
||||
memberData.Reminders.Add(
|
||||
new Reminder
|
||||
{
|
||||
At = remindAt,
|
||||
|
@ -159,15 +160,16 @@ public class RemindCommandGroup : CommandGroup
|
|||
string.Format(Messages.ReminderCreated, executor.GetTag()), executor)
|
||||
.WithDescription(builder.ToString())
|
||||
.WithColour(ColorsList.Green)
|
||||
.WithFooter(string.Format(Messages.ReminderPosition, memberData.Reminders.Count))
|
||||
.Build();
|
||||
|
||||
return await _feedback.SendContextualEmbedResultAsync(embed, ct);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// A slash command that deletes a reminder using its index.
|
||||
/// A slash command that deletes a reminder using its list position.
|
||||
/// </summary>
|
||||
/// <param name="index">The index of the reminder to delete.</param>
|
||||
/// <param name="position">The list position of the reminder to delete.</param>
|
||||
/// <returns>A feedback sending result which may or may not have succeeded.</returns>
|
||||
[Command("delremind")]
|
||||
[Description("Delete one of your reminders")]
|
||||
|
@ -175,8 +177,8 @@ public class RemindCommandGroup : CommandGroup
|
|||
[RequireContext(ChannelContext.Guild)]
|
||||
[UsedImplicitly]
|
||||
public async Task<Result> ExecuteDeleteReminderAsync(
|
||||
[Description("Index of reminder to delete")] [MinValue(0)]
|
||||
int index)
|
||||
[Description("Position in list")] [MinValue(1)]
|
||||
int position)
|
||||
{
|
||||
if (!_context.TryGetContextIDs(out var guildId, out _, out var executorId))
|
||||
{
|
||||
|
@ -192,7 +194,7 @@ public class RemindCommandGroup : CommandGroup
|
|||
var data = await _guildData.GetData(guildId, CancellationToken);
|
||||
Messages.Culture = GuildSettings.Language.Get(data.Settings);
|
||||
|
||||
return await DeleteReminderAsync(data.GetOrCreateMemberData(executorId), index, bot, CancellationToken);
|
||||
return await DeleteReminderAsync(data.GetOrCreateMemberData(executorId), position - 1, bot, CancellationToken);
|
||||
}
|
||||
|
||||
private async Task<Result> DeleteReminderAsync(MemberData data, int index, IUser bot,
|
||||
|
@ -200,7 +202,7 @@ public class RemindCommandGroup : CommandGroup
|
|||
{
|
||||
if (index >= data.Reminders.Count)
|
||||
{
|
||||
var failedEmbed = new EmbedBuilder().WithSmallTitle(Messages.InvalidReminderIndex, bot)
|
||||
var failedEmbed = new EmbedBuilder().WithSmallTitle(Messages.InvalidReminderPosition, bot)
|
||||
.WithColour(ColorsList.Red)
|
||||
.Build();
|
||||
|
||||
|
|
8
src/Messages.Designer.cs
generated
8
src/Messages.Designer.cs
generated
|
@ -738,9 +738,9 @@ namespace Octobot {
|
|||
}
|
||||
}
|
||||
|
||||
internal static string InvalidReminderIndex {
|
||||
internal static string InvalidReminderPosition {
|
||||
get {
|
||||
return ResourceManager.GetString("InvalidReminderIndex", resourceCulture);
|
||||
return ResourceManager.GetString("InvalidReminderPosition", resourceCulture);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -780,9 +780,9 @@ namespace Octobot {
|
|||
}
|
||||
}
|
||||
|
||||
internal static string ReminderIndex {
|
||||
internal static string ReminderPosition {
|
||||
get {
|
||||
return ResourceManager.GetString("ReminderIndex", resourceCulture);
|
||||
return ResourceManager.GetString("ReminderPosition", resourceCulture);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue