using System.Collections.Generic;
using System.Text.Json.Serialization;
using Geekbot.Core.Interactions.ApplicationCommand;
using Geekbot.Core.Interactions.MessageComponents;
namespace Geekbot.Core.Interactions.Request
{
///
public class InteractionData
{
///
/// the ID of the invoked command
///
///
/// For: Application Command
///
[JsonPropertyName("id")]
public string Id { get; init; }
///
/// the name of the invoked command
///
///
/// For: Application Command
///
[JsonPropertyName("name")]
public string Name { get; init; }
///
/// the type of the invoked command
///
///
/// For: Application Command
///
[JsonPropertyName("type")]
public CommandType Type { get; init; }
///
/// converted users + roles + channels
///
///
/// For: Application Command
///
[JsonPropertyName("resolved")]
public InteractionResolvedData Resolved { get; init; }
///
/// of application command interaction data option the params + values from the user
///
///
/// For: Application Command
///
[JsonPropertyName("options")]
public List Options { get; init; }
///
/// the custom_id of the component
///
///
/// For: Component
///
[JsonPropertyName("custom_id")]
public string CustomId { get; init; }
///
/// the type of the component
///
///
/// For: Component
///
[JsonPropertyName("component_type")]
public ComponentType ComponentType { get; init; }
///
/// of select option values the values the user selected
///
///
/// Component (Select)
///
[JsonPropertyName("values")]
public string Values { get; init; }
///
/// id the of user or message targetted by a user or message command
///
///
/// For: Application Command
/// Present in: User Command, Message Command
///
[JsonPropertyName("target_id")]
public string TargetId { get; init; }
public string GetTargetNickname()
{
return GetUserNickename(TargetId);
}
public string GetUserNickename(string userId)
{
var username = Resolved.Members[userId].Nick;
if (string.IsNullOrEmpty(username))
{
username = Resolved.Users[userId].Username;
}
return username;
}
}
}