Bugfix in rank, updated migration script
This commit is contained in:
parent
29c181ddda
commit
a4cbc03202
3 changed files with 26 additions and 10 deletions
|
@ -18,7 +18,7 @@ namespace Geekbot.net.Lib
|
||||||
public void HandleCommandException(Exception e, ICommandContext Context)
|
public void HandleCommandException(Exception e, ICommandContext Context)
|
||||||
{
|
{
|
||||||
var errorMsg =
|
var errorMsg =
|
||||||
$"Error Occured while executing \"{Context.Message.Content}\", executed by \"{Context.User.Username}\"";
|
$"Error Occured while executing \"{Context.Message.Content}\", executed by \"{Context.User.Username}\", complete message was \"{Context.Message}\"";
|
||||||
logger.Error(e, errorMsg);
|
logger.Error(e, errorMsg);
|
||||||
// await botOwnerDmChannel.SendMessageAsync($"{errorMsg}```{e.StackTrace}```");
|
// await botOwnerDmChannel.SendMessageAsync($"{errorMsg}```{e.StackTrace}```");
|
||||||
// await Context.Channel.SendMessageAsync("Something went wrong...");
|
// await Context.Channel.SendMessageAsync("Something went wrong...");
|
||||||
|
|
|
@ -1,5 +1,8 @@
|
||||||
using System;
|
using System;
|
||||||
|
using System.Collections;
|
||||||
|
using System.Collections.Generic;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
|
using System.Runtime.InteropServices.ComTypes;
|
||||||
using System.Text;
|
using System.Text;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
using Discord;
|
using Discord;
|
||||||
|
@ -70,19 +73,33 @@ namespace Geekbot.net.Modules
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
var messageList = redis.HashGetAll($"{Context.Guild.Id}:Messages");
|
var messageList = redis.HashGetAll($"{Context.Guild.Id}:Messages");
|
||||||
var sortedList = messageList.OrderByDescending(e => e.Value).ToList().Take(11).ToList();
|
var sortedList = messageList.OrderByDescending(e => e.Value).ToList();
|
||||||
var guildMessages = (int) sortedList.First().Value;
|
var guildMessages = (int) sortedList.First().Value;
|
||||||
sortedList.RemoveAt(0);
|
sortedList.RemoveAt(0);
|
||||||
var highScore = new StringBuilder();
|
|
||||||
highScore.AppendLine($":bar_chart: **Highscore for {Context.Guild.Name}**");
|
var highscoreUsers = new Dictionary<IGuildUser, int>();
|
||||||
var counter = 1;
|
var listLimiter = 1;
|
||||||
foreach (var user in sortedList)
|
foreach (var user in sortedList)
|
||||||
{
|
{
|
||||||
|
if (listLimiter > 10) break;
|
||||||
|
|
||||||
var guildUser = Context.Guild.GetUserAsync((ulong) user.Name).Result;
|
var guildUser = Context.Guild.GetUserAsync((ulong) user.Name).Result;
|
||||||
var percent = Math.Round((double) (100 * (int) user.Value) / guildMessages, 2);
|
if (guildUser != null)
|
||||||
|
{
|
||||||
|
highscoreUsers.Add(guildUser, (int)user.Value);
|
||||||
|
listLimiter++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
var highScore = new StringBuilder();
|
||||||
|
highScore.AppendLine($":bar_chart: **Highscore for {Context.Guild.Name}**");
|
||||||
|
var highscorePlace = 1;
|
||||||
|
foreach (var user in highscoreUsers)
|
||||||
|
{
|
||||||
|
var percent = Math.Round((double) (100 * user.Value) / guildMessages, 2);
|
||||||
highScore.AppendLine(
|
highScore.AppendLine(
|
||||||
$"{NumerToEmoji(counter)} **{guildUser.Username}#{guildUser.Discriminator}** - {percent}% of total - {user.Value} messages");
|
$"{NumerToEmoji(highscorePlace)} **{user.Key.Username}#{user.Key.Discriminator}** - {percent}% of total - {user.Value} messages");
|
||||||
counter++;
|
highscorePlace++;
|
||||||
}
|
}
|
||||||
await ReplyAsync(highScore.ToString());
|
await ReplyAsync(highScore.ToString());
|
||||||
}
|
}
|
||||||
|
|
|
@ -273,9 +273,8 @@ namespace Geekbot.net
|
||||||
redis.HashSet($"{guildId}:Settings", new HashEntry[] { new HashEntry("WelcomeMsg", val) });
|
redis.HashSet($"{guildId}:Settings", new HashEntry[] { new HashEntry("WelcomeMsg", val) });
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
//redis.KeyDelete(key);
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
redis.KeyDelete(key);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return Task.CompletedTask;
|
return Task.CompletedTask;
|
||||||
|
|
Loading…
Reference in a new issue