using System.Collections.ObjectModel; using System.Drawing; using VpSharp.Entities; namespace VpSharp.Commands; /// /// Provides metadata about a command invocation. /// public sealed class CommandContext { internal CommandContext(VirtualParadiseClient client, IAvatar avatar, string commandName, string alias, string rawArguments) { Client = client; Avatar = avatar; CommandName = commandName; Alias = alias; RawArguments = rawArguments; Arguments = new ReadOnlyCollection(rawArguments.Split()); } /// /// Gets the alias that was used to invoke the command. /// /// The alias used. public string Alias { get; } /// /// Gets the arguments of the command. /// /// The arguments passed by the avatar. public IReadOnlyList Arguments { get; } /// /// Gets the avatar who executed the command. /// /// The executing avatar. public IAvatar Avatar { get; } /// /// Gets the client which raised the event. /// /// The Virtual Paradise client. public VirtualParadiseClient Client { get; } /// /// Gets the command name. /// /// The name of the command being executed. public string CommandName { get; } /// /// Gets the raw argument string as sent by the avatar. /// /// The raw argument string. public string RawArguments { get; } /// /// Sends a response message to the command. /// /// The message to send. /// /// to respond only to the avatar which sent the command; to send a /// regular chat message. /// /// The message which was sent. public async Task RespondAsync(string message, bool ephemeral = false) { return ephemeral ? await Avatar.SendMessageAsync(Client.CurrentAvatar?.Name, message, FontStyle.Regular, Color.Black) .ConfigureAwait(false) : await Client.SendMessageAsync(message).ConfigureAwait(false); } }