geekbot/Geekbot.net/Lib/StatsRecorder.cs

34 lines
949 B
C#
Raw Normal View History

2017-04-13 00:03:03 +02:00
using System;
using System.Threading.Tasks;
using Discord.WebSocket;
2017-04-14 21:36:01 +02:00
using StackExchange.Redis;
2017-04-13 00:03:03 +02:00
namespace Geekbot.net.Lib
{
public class StatsRecorder
{
2017-04-14 21:36:01 +02:00
private readonly SocketMessage message;
private readonly IDatabase redis;
2017-04-13 13:22:30 +02:00
public StatsRecorder(SocketMessage message, IRedisClient redisClient)
2017-04-13 00:03:03 +02:00
{
2017-04-13 13:22:30 +02:00
this.message = message;
redis = redisClient.Client;
2017-04-13 00:03:03 +02:00
}
2017-04-13 13:22:30 +02:00
public async Task UpdateUserRecordAsync()
2017-04-13 00:03:03 +02:00
{
2017-04-14 21:36:01 +02:00
var guildId = ((SocketGuildChannel) message.Channel).Guild.Id;
var key = guildId + "-" + message.Author.Id + "-messages";
await redis.StringIncrementAsync(key);
2017-04-13 00:03:03 +02:00
}
2017-04-13 13:22:30 +02:00
public async Task UpdateGuildRecordAsync()
2017-04-13 00:03:03 +02:00
{
2017-04-14 21:36:01 +02:00
var guildId = ((SocketGuildChannel) message.Channel).Guild.Id;
var key = guildId + "-messages";
await redis.StringIncrementAsync(key);
2017-04-13 00:03:03 +02:00
}
}
}