mirror of
https://gitlab.com/Deukhoofd/DeukBot4.git
synced 2026-04-03 11:10:05 +00:00
made reminders a bit cooler
This commit is contained in:
@@ -11,15 +11,15 @@ namespace DeukBot4.Database
|
||||
public static ConnectionMultiplexer Redis = ConnectionMultiplexer.Connect("127.0.0.1");
|
||||
|
||||
|
||||
public void AddReminder(TimeSpan time, string message, ulong channel, ulong author, ulong recipient)
|
||||
public async Task AddReminder(TimeSpan time, string message, ulong channel, ulong author, ulong recipient)
|
||||
{
|
||||
try
|
||||
{
|
||||
var db = Redis.GetDatabase();
|
||||
var id = Guid.NewGuid().ToString();
|
||||
var expectedTime = DateTime.UtcNow.Add(time);
|
||||
db.SortedSetAdd("deukbot_reminders", (RedisValue)id, expectedTime.ToBinary());
|
||||
db.HashSet((RedisKey) id, new[]
|
||||
db.SortedSetAddAsync("deukbot_reminders", (RedisValue)id, expectedTime.ToBinary());
|
||||
db.HashSetAsync((RedisKey) id, new[]
|
||||
{
|
||||
new HashEntry("channel", channel),
|
||||
new HashEntry("message", message),
|
||||
@@ -62,7 +62,7 @@ namespace DeukBot4.Database
|
||||
db.KeyDelete(val);
|
||||
}
|
||||
|
||||
db.SortedSetRemoveRangeByScore("deukbot_reminders", Double.MinValue, desiredTopScore);
|
||||
db.SortedSetRemoveRangeByScoreAsync("deukbot_reminders", Double.MinValue, desiredTopScore);
|
||||
|
||||
await Task.Delay(checkTime);
|
||||
await CheckReminders();
|
||||
|
||||
Reference in New Issue
Block a user