//
// FeedbackService.cs
//
// Copyright (c) František Boháček. All rights reserved.
// Licensed under the MIT license. See LICENSE file in the project root for full license information.
using NosSmooth.Core.Client;
using NosSmooth.Packets.Enums;
using NosSmooth.Packets.Enums.Chat;
using NosSmooth.Packets.Server.Chat;
using Remora.Results;
namespace NosSmooth.ChatCommands;
///
/// Feedback for chat commands.
///
public class FeedbackService
{
private readonly INostaleClient _client;
///
/// Initializes a new instance of the class.
///
/// The nostale client.
public FeedbackService(INostaleClient client)
{
_client = client;
}
///
/// Send message error.
///
/// The message to send.
/// The cancellation token for cancelling the operation.
/// A result that may or may not have succeeded.
public Task SendErrorMessageAsync(string message, CancellationToken ct = default)
=> SendMessageAsync(message, SayColor.Red, ct);
///
/// Send message success.
///
/// The message to send.
/// The cancellation token for cancelling the operation.
/// A result that may or may not have succeeded.
public Task SendSuccessMessageAsync(string message, CancellationToken ct = default)
=> SendMessageAsync(message, SayColor.Green, ct);
///
/// Send message info.
///
/// The message to send.
/// The cancellation token for cancelling the operation.
/// A result that may or may not have succeeded.
public Task SendInfoMessageAsync(string message, CancellationToken ct = default)
=> SendMessageAsync(message, SayColor.Default, ct);
///
/// Send message with the given color.
///
/// The message to send.
/// The color.
/// The cancellation token for cancelling the operation.
/// A result that may or may not have succeeded.
public Task SendMessageAsync(string message, SayColor color, CancellationToken ct = default)
=> _client.ReceivePacketAsync(new SayPacket(EntityType.Map, 0, color, message), ct);
}