mirror of
https://github.com/TeamOctolings/Octobot.git
synced 2025-01-31 00:19:00 +03:00
Add failed embed for /listremind (#88)
Without this embed, if there are no reminders created by the user, the bot will endlessly think because StringBuilder will be empty and normal embed will not be shown.
This commit is contained in:
parent
87dbb07dec
commit
da2a88246c
5 changed files with 32 additions and 2 deletions
|
@ -591,4 +591,7 @@
|
|||
<data name="ReminderDeleted" xml:space="preserve">
|
||||
<value>Reminder deleted</value>
|
||||
</data>
|
||||
<data name="NoRemindersFound" xml:space="preserve">
|
||||
<value>You don't have any reminders created!</value>
|
||||
</data>
|
||||
</root>
|
||||
|
|
|
@ -591,4 +591,7 @@
|
|||
<data name="ReminderDeleted" xml:space="preserve">
|
||||
<value>Напоминание удалено</value>
|
||||
</data>
|
||||
<data name="NoRemindersFound" xml:space="preserve">
|
||||
<value>У вас нет созданных напоминаний!</value>
|
||||
</data>
|
||||
</root>
|
||||
|
|
|
@ -591,4 +591,7 @@
|
|||
<data name="ReminderDeleted" xml:space="preserve">
|
||||
<value>напоминалка уничтожена</value>
|
||||
</data>
|
||||
<data name="NoRemindersFound" xml:space="preserve">
|
||||
<value>ты еще не крафтил напоминалки</value>
|
||||
</data>
|
||||
</root>
|
||||
|
|
|
@ -61,14 +61,29 @@ public class RemindCommandGroup : CommandGroup
|
|||
return Result.FromError(userResult);
|
||||
}
|
||||
|
||||
var currentUserResult = await _userApi.GetCurrentUserAsync(CancellationToken);
|
||||
if (!currentUserResult.IsDefined(out var currentUser))
|
||||
{
|
||||
return Result.FromError(currentUserResult);
|
||||
}
|
||||
|
||||
var data = await _guildData.GetData(guildId, CancellationToken);
|
||||
Messages.Culture = GuildSettings.Language.Get(data.Settings);
|
||||
|
||||
return await ListRemindersAsync(data.GetOrCreateMemberData(userId), user, CancellationToken);
|
||||
return await ListRemindersAsync(data.GetOrCreateMemberData(userId), user, currentUser, CancellationToken);
|
||||
}
|
||||
|
||||
private async Task<Result> ListRemindersAsync(MemberData data, IUser user, CancellationToken ct)
|
||||
private async Task<Result> ListRemindersAsync(MemberData data, IUser user, IUser currentUser, CancellationToken ct)
|
||||
{
|
||||
if (data.Reminders.Count == 0)
|
||||
{
|
||||
var failedEmbed = new EmbedBuilder().WithSmallTitle(Messages.NoRemindersFound, currentUser)
|
||||
.WithColour(ColorsList.Red)
|
||||
.Build();
|
||||
|
||||
return await _feedback.SendContextualEmbedResultAsync(failedEmbed, ct);
|
||||
}
|
||||
|
||||
var builder = new StringBuilder();
|
||||
for (var i = 0; i < data.Reminders.Count; i++)
|
||||
{
|
||||
|
|
6
src/Messages.Designer.cs
generated
6
src/Messages.Designer.cs
generated
|
@ -995,5 +995,11 @@ namespace Boyfriend {
|
|||
return ResourceManager.GetString("ReminderDeleted", resourceCulture);
|
||||
}
|
||||
}
|
||||
|
||||
internal static string NoRemindersFound {
|
||||
get {
|
||||
return ResourceManager.GetString("NoRemindersFound", resourceCulture);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue