Fuck Singletons
This commit is contained in:
parent
2e8d4b6125
commit
3ce207749f
7 changed files with 120 additions and 14 deletions
|
@ -1,8 +1,4 @@
|
|||
using System;
|
||||
using System.Threading.Tasks;
|
||||
using Discord;
|
||||
using Discord.Commands;
|
||||
using RestSharp;
|
||||
using RestSharp;
|
||||
|
||||
namespace Geekbot.net.Modules
|
||||
{
|
||||
|
|
30
Geekbot.net/Lib/RedisClient.cs
Normal file
30
Geekbot.net/Lib/RedisClient.cs
Normal file
|
@ -0,0 +1,30 @@
|
|||
using System;
|
||||
using StackExchange.Redis;
|
||||
|
||||
namespace Geekbot.net.Lib
|
||||
{
|
||||
public sealed class RedisSingleton
|
||||
{
|
||||
private RedisSingleton()
|
||||
{
|
||||
var redis = ConnectionMultiplexer.Connect("localhost:6379");
|
||||
if (redis.IsConnected)
|
||||
{
|
||||
Console.WriteLine("Connection to Redis Enstablished");
|
||||
}
|
||||
else
|
||||
{
|
||||
Console.WriteLine("Connection to Redis Failed");
|
||||
}
|
||||
}
|
||||
private static readonly Lazy<RedisSingleton> lazy = new Lazy<RedisSingleton>(() => new RedisSingleton());
|
||||
public static RedisSingleton Instance
|
||||
{
|
||||
get
|
||||
{
|
||||
return lazy.Value;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -1,6 +1,7 @@
|
|||
using System;
|
||||
using System.Threading.Tasks;
|
||||
using Discord.WebSocket;
|
||||
using Geekbot.net.Lib;
|
||||
|
||||
namespace Geekbot.net.Lib
|
||||
{
|
||||
|
@ -12,18 +13,19 @@ namespace Geekbot.net.Lib
|
|||
public StatsRecorder(SocketMessage message)
|
||||
{
|
||||
this.message = message;
|
||||
var db = new RedisSingleton();
|
||||
}
|
||||
|
||||
public async Task UpdateUserRecordAsync()
|
||||
{
|
||||
Console.WriteLine(message.Author.Username + " earned a point");
|
||||
// Console.WriteLine(message.Author.Username + " earned a point");
|
||||
await Task.FromResult(true);
|
||||
}
|
||||
|
||||
public async Task UpdateGuildRecordAsync()
|
||||
{
|
||||
var channel = (SocketGuildChannel) message.Channel;
|
||||
Console.WriteLine(channel.Guild.Name + " earned a point");
|
||||
// Console.WriteLine(channel.Guild.Name + " earned a point");
|
||||
await Task.FromResult(true);
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue