using RegexBot.Data;
using RegexBot.Services.EntityCache;
namespace RegexBot;
partial class RegexbotClient {
private readonly EntityCacheService _svcEntityCache;
///
/// Queries the entity cache for user information. The given search string may contain a user ID
/// or a username with optional discriminator. In case there are multiple results, the most recently
/// cached user will be returned.
///
/// Search string. May be a name with discriminator, a name, or an ID.
/// A instance containing cached information, or null if no result.
public CachedUser? EcQueryUser(string search) => _svcEntityCache.QueryUserCache(search);
///
/// Queries the entity cache for guild-specific user information. The given search string may contain a user ID,
/// nickname, or a username with optional discriminator. In case there are multiple results, the most recently
/// cached user will be returned.
///
/// ID of the corresponding guild in which to search.
/// Search string. May be a name with discriminator, a name, or an ID.
/// A instance containing cached information, or null if no result.
public CachedGuildUser? EcQueryGuildUser(ulong guildId, string search) => _svcEntityCache.QueryGuildUserCache(guildId, search);
///
/// Fired after a message edit, when the message cache is about to be updated with the edited message.
///
///
/// This event serves as an alternative to ,
/// pulling the previous state of the message from the entity cache instead of the library's cache.
///
public event EcMessageUpdateHandler? EcOnMessageUpdate {
add { _svcEntityCache.OnCachePreUpdate += value; }
remove { _svcEntityCache.OnCachePreUpdate -= value; }
}
///
/// Delegate used for the event.
///
///
/// The previous state of the message prior to being updated, as known by the entity cache.
/// The new, updated incoming message.
///
public delegate Task EcMessageUpdateHandler(CachedGuildMessage? oldMsg, SocketMessage newMsg);
}