PluralKit/PluralKit.Core/Database/Repository/ModelRepository.CommandMessage.cs

39 lines
1.1 KiB
C#
Raw Normal View History

using System.Threading.Tasks;
using SqlKata;
namespace PluralKit.Core
{
public partial class ModelRepository
2021-08-27 15:03:47 +00:00
{
public Task SaveCommandMessage(ulong messageId, ulong channelId, ulong authorId)
{
var query = new Query("command_messages").AsInsert(new
{
message_id = messageId,
channel_id = channelId,
author_id = authorId,
});
return _db.ExecuteQuery(query);
}
public Task<CommandMessage?> GetCommandMessage(ulong messageId)
{
var query = new Query("command_messages").Where("message_id", messageId);
return _db.QueryFirst<CommandMessage?>(query);
}
2020-10-23 10:18:28 +00:00
public Task<int> DeleteCommandMessagesBefore(ulong messageIdThreshold)
{
var query = new Query("command_messages").AsDelete().Where("message_id", "<", messageIdThreshold);
return _db.QueryFirst<int>(query);
}
2020-10-23 10:18:28 +00:00
}
2021-08-27 15:03:47 +00:00
public class CommandMessage
{
2020-10-23 10:18:28 +00:00
public ulong AuthorId { get; set; }
public ulong MessageId { get; set; }
public ulong ChannelId { get; set; }
2021-08-27 15:03:47 +00:00
}
}