public async Task <Result> Execute(CommandMetadata data, string username) { IUser user = ParentPlugin.GuildHandler.GetUser(username); var karma = ParentPlugin.GetKarma(user.Id); return(new Result(await GetKarmaEmbed(karma, user.GetShownName(), 3, ParentPlugin.GuildHandler), string.Empty)); }
public Task <Result> Execute(CommandMetadata data, int amount) { var allKarma = ParentPlugin.GetKarmaDictionary(); List <SocketGuildUser> inGuild = new List <SocketGuildUser> (); foreach (var entry in allKarma) // Man I'm getting lazy with dictionary type naming. All those generic parameters yo. { SocketGuildUser user = data.Message.GetGuild()?.GetUser(entry.Key); if (user == null) { continue; } inGuild.Add(user); } inGuild.OrderByDescending(x => ParentPlugin.GetKarma(x.Id).Total); inGuild = inGuild.GetRange(0, Math.Min(amount, inGuild.Count)); string result = "```"; foreach (SocketGuildUser user in inGuild) { result += StringExtensions.UniformStrings(user.GetShownName(), ParentPlugin.GetKarma(user.Id).ToString()) + "\n"; } result += "```"; return(TaskResult(inGuild, result)); }
public async Task <Result> Execute(CommandMetadata data, ulong channelId, ulong messageId) { ITextChannel channel = ParentPlugin.GuildHandler.FindTextChannel(channelId); IMessage message = await channel?.GetMessageAsync(messageId); if (channel == null) { throw new ArgumentException("The channel could not be found."); } if (message == null) { throw new ArgumentException("The message could not be found."); } var karma = ParentPlugin.GetKarma(message.Author.Id); var karmaMessage = karma.GetMessages().FirstOrDefault(x => x.Id == message.Id); if (karmaMessage == null) { throw new ArgumentException("The message given has neither upvotes or downvotes."); } var upvoters = karmaMessage.GetUpvotes().Select(x => ParentPlugin.GuildHandler.FindUser(x)); var downvoters = karmaMessage.GetDownvotes().Select(x => ParentPlugin.GuildHandler.FindUser(x)); string ups = string.Join(", ", upvoters.Select(x => UserToString(x))); string downs = string.Join(", ", downvoters.Select(x => UserToString(x))); string UserToString(IUser user) => user == null ? "*Missing User*" : user.GetShownName(); return(new Result(new EmbedBuilder().WithTitle("Voters of Message") .WithDescription($"> [{message.Content.Replace('\n', ' ')}]({message.GetJumpUrl ()}) - {karmaMessage.ToString()}") .AddField("The following people upvoted the message..", upvoters.Count() == 0 ? "```No one :(```" : $"```{ups}```") .AddField("The following people downvoted the message..", downvoters.Count() == 0 ? "```No one! :)```" : $"```{downs}```") .Build(), string.Empty)); }
public Task <Result> Execute(CommandMetadata data, IUser user) { KarmaPlugin.Selfworth karma = ParentPlugin.GetKarma(user.Id); return(TaskResult(karma.Total, $"User {user.GetShownName ()} has {karma.Total} karma! (+{karma.upvotes} / -{karma.downvotes})")); }