Get guilds from existing redis keys instead of the client
This commit is contained in:
parent
8b5e52c8e0
commit
926a632641
2 changed files with 22 additions and 2 deletions
|
@ -31,7 +31,27 @@ namespace Geekbot.net.Database
|
||||||
public async Task Migrate()
|
public async Task Migrate()
|
||||||
{
|
{
|
||||||
_logger.Information(LogSource.Geekbot, "Starting migration process");
|
_logger.Information(LogSource.Geekbot, "Starting migration process");
|
||||||
foreach (var guild in _client.Guilds)
|
|
||||||
|
var keys = _redis.GetAllKeys().Where(e => e.ToString().EndsWith("Messages"));
|
||||||
|
var guilds = new List<SocketGuild>();
|
||||||
|
|
||||||
|
foreach (var key in keys)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
var g = _client.GetGuild(ulong.Parse(key.ToString().Split(':').First()));
|
||||||
|
Console.WriteLine(g.Name);
|
||||||
|
guilds.Add(g);
|
||||||
|
}
|
||||||
|
catch (Exception e)
|
||||||
|
{
|
||||||
|
// ignore
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
_logger.Information(LogSource.Geekbot, $"Found {guilds.Count} guilds in redis");
|
||||||
|
|
||||||
|
foreach (var guild in guilds)
|
||||||
{
|
{
|
||||||
if (guild.MemberCount > 10000)
|
if (guild.MemberCount > 10000)
|
||||||
{
|
{
|
||||||
|
|
|
@ -29,7 +29,7 @@ namespace Geekbot.net.Lib.AlmostRedis
|
||||||
|
|
||||||
public IEnumerable<RedisKey> GetAllKeys()
|
public IEnumerable<RedisKey> GetAllKeys()
|
||||||
{
|
{
|
||||||
return Connection.GetServer($"{_runParameters.RedisHost}:{_runParameters.RedisPort}", int.Parse(_runParameters.RedisDatabase)).Keys();
|
return Connection.GetServer($"{_runParameters.RedisHost}:{_runParameters.RedisPort}").Keys(int.Parse(_runParameters.RedisDatabase));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
Loading…
Reference in a new issue