mirror of
https://github.com/TeamOctolings/Octobot.git
synced 2025-04-19 16:33:36 +03:00
resolved all requested changes finally №2
This commit is contained in:
parent
9c3144a42e
commit
71ec6d003c
2 changed files with 21 additions and 26 deletions
|
@ -26,22 +26,20 @@ namespace Octobot.Commands;
|
|||
[UsedImplicitly]
|
||||
public class RemindCommandGroup : CommandGroup
|
||||
{
|
||||
private readonly ICommandContext _context;
|
||||
private readonly IInteractionCommandContext _context;
|
||||
private readonly IFeedbackService _feedback;
|
||||
private readonly GuildDataService _guildData;
|
||||
private readonly IDiscordRestUserAPI _userApi;
|
||||
private readonly IInteractionCommandContext _interactionContext;
|
||||
private readonly IDiscordRestInteractionAPI _interactionApi;
|
||||
|
||||
public RemindCommandGroup(
|
||||
ICommandContext context, GuildDataService guildData, IFeedbackService feedback,
|
||||
IDiscordRestUserAPI userApi, IInteractionCommandContext interactionContext, IDiscordRestInteractionAPI interactionApi)
|
||||
IInteractionCommandContext context, GuildDataService guildData, IFeedbackService feedback,
|
||||
IDiscordRestUserAPI userApi, IDiscordRestInteractionAPI interactionApi)
|
||||
{
|
||||
_context = context;
|
||||
_guildData = guildData;
|
||||
_feedback = feedback;
|
||||
_userApi = userApi;
|
||||
_interactionContext = interactionContext;
|
||||
_interactionApi = interactionApi;
|
||||
}
|
||||
|
||||
|
@ -138,12 +136,10 @@ public class RemindCommandGroup : CommandGroup
|
|||
return Result.FromError(executorResult);
|
||||
}
|
||||
|
||||
var interactionToken = _interactionContext.Interaction.Token;
|
||||
var applicationId = _interactionContext.Interaction.ApplicationID;
|
||||
|
||||
var data = await _guildData.GetData(guildId, CancellationToken);
|
||||
Messages.Culture = GuildSettings.Language.Get(data.Settings);
|
||||
|
||||
var interactionToken = _context.Interaction.Token;
|
||||
var applicationId = _context.Interaction.ApplicationID;
|
||||
return await AddReminderAsync(@in, text, data, channelId, executor, interactionToken, applicationId, CancellationToken);
|
||||
}
|
||||
|
||||
|
@ -157,6 +153,21 @@ public class RemindCommandGroup : CommandGroup
|
|||
Messages.ReminderText, Markdown.InlineCode(text)))
|
||||
.AppendBulletPoint(string.Format(Messages.ReminderTime, Markdown.Timestamp(remindAt)));
|
||||
|
||||
var responseResult = await _interactionApi.GetOriginalInteractionResponseAsync(applicationId, interactionToken, ct);
|
||||
if (!responseResult.IsDefined(out var response))
|
||||
{
|
||||
return (Result)responseResult;
|
||||
}
|
||||
|
||||
var interactionValue = response.ID;
|
||||
memberData.Reminders.Add(
|
||||
new Reminder
|
||||
{
|
||||
At = remindAt,
|
||||
ChannelId = channelId.Value,
|
||||
Text = text,
|
||||
MessageId = interactionValue.Value
|
||||
});
|
||||
var embed = new EmbedBuilder().WithSmallTitle(
|
||||
string.Format(Messages.ReminderCreated, executor.GetTag()), executor)
|
||||
.WithDescription(builder.ToString())
|
||||
|
@ -169,22 +180,6 @@ public class RemindCommandGroup : CommandGroup
|
|||
return (Result)messageResult;
|
||||
}
|
||||
|
||||
var a = await _interactionApi.GetOriginalInteractionResponseAsync(applicationId, interactionToken, ct);
|
||||
if (!a.IsDefined(out var interaction))
|
||||
{
|
||||
return (Result)a;
|
||||
}
|
||||
|
||||
var interactionValue = interaction.Interaction.Value.ID;
|
||||
memberData.Reminders.Add(
|
||||
new Reminder
|
||||
{
|
||||
At = remindAt,
|
||||
ChannelId = channelId.Value,
|
||||
Text = text,
|
||||
MessageId = interactionValue.Value
|
||||
});
|
||||
|
||||
return (Result)messageResult;
|
||||
}
|
||||
|
||||
|
|
|
@ -232,7 +232,7 @@ public sealed partial class MemberUpdateService : BackgroundService
|
|||
|
||||
var embed = new EmbedBuilder().WithSmallTitle(
|
||||
string.Format(Messages.Reminder, user.GetTag()), user)
|
||||
.WithDescription(string.Format(builder.ToString()))
|
||||
.WithDescription(builder.ToString())
|
||||
.WithColour(ColorsList.Magenta)
|
||||
.Build();
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue