2024-06-24 18:21:59 -04:00
|
|
|
using HermesSocketLibrary.db;
|
|
|
|
using HermesSocketLibrary.Requests.Messages;
|
|
|
|
using ILogger = Serilog.ILogger;
|
|
|
|
|
|
|
|
namespace HermesSocketServer.Requests
|
|
|
|
{
|
|
|
|
public class GetEmotes : IRequest
|
|
|
|
{
|
|
|
|
public string Name => "get_emotes";
|
2024-10-20 16:39:13 -04:00
|
|
|
public string[] RequiredKeys => [];
|
2024-06-24 18:21:59 -04:00
|
|
|
private Database _database;
|
|
|
|
private ILogger _logger;
|
|
|
|
|
|
|
|
public GetEmotes(Database database, ILogger logger)
|
|
|
|
{
|
|
|
|
_database = database;
|
|
|
|
_logger = logger;
|
|
|
|
}
|
|
|
|
|
2024-08-10 15:36:32 -04:00
|
|
|
public async Task<RequestResult> Grant(string sender, IDictionary<string, object>? data)
|
2024-06-24 18:21:59 -04:00
|
|
|
{
|
|
|
|
IList<EmoteInfo> emotes = new List<EmoteInfo>();
|
|
|
|
string sql = $"SELECT id, name FROM \"Emote\"";
|
2024-08-10 15:36:32 -04:00
|
|
|
await _database.Execute(sql, (IDictionary<string, object>?) null, (r) => emotes.Add(new EmoteInfo()
|
2024-06-24 18:21:59 -04:00
|
|
|
{
|
|
|
|
Id = r.GetString(0),
|
|
|
|
Name = r.GetString(1)
|
|
|
|
}));
|
2024-08-10 15:36:32 -04:00
|
|
|
_logger.Information($"Fetched all emotes for channel [channel: {sender}]");
|
2024-10-20 16:39:13 -04:00
|
|
|
return RequestResult.Successful(emotes, notifyClientsOnAccount: false);
|
2024-06-24 18:21:59 -04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|