using System.Text.Json; using HermesSocketLibrary.db; using HermesSocketLibrary.Requests; using HermesSocketLibrary.Requests.Messages; using ILogger = Serilog.ILogger; namespace HermesSocketServer.Requests { public class GetEmotes : IRequest { public string Name => "get_emotes"; private Database _database; private ILogger _logger; public GetEmotes(Database database, ILogger logger) { _database = database; _logger = logger; } public async Task Grant(string sender, IDictionary data) { IList emotes = new List(); string sql = $"SELECT id, name FROM \"Emote\""; await _database.Execute(sql, data, (r) => emotes.Add(new EmoteInfo() { Id = r.GetString(0), Name = r.GetString(1) })); _logger.Information($"Fetched all emotes."); return new RequestResult(true, emotes, notifyClientsOnAccount: false); } } }