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

36 lines
1022 B
C#
Raw Normal View History

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