Merge pull request #2 from runebaas/master

Karma system now uses embed and less mentioning
This commit is contained in:
Daan Boerlage 2017-07-12 17:52:12 +02:00 committed by GitHub
commit d0f019eb8d

View file

@ -30,10 +30,22 @@ namespace Geekbot.net.Modules
{ {
var key = Context.Guild.Id + "-" + user.Id + "-karma"; var key = Context.Guild.Id + "-" + user.Id + "-karma";
var badJokes = (int)redis.Client.StringGet(key); var badJokes = (int)redis.Client.StringGet(key);
redis.Client.StringSet(key, (badJokes + 1).ToString()); var newBadJokes = badJokes + 1;
redis.Client.StringSet(key, newBadJokes.ToString());
var lastKey = Context.Guild.Id + "-" + Context.User.Id + "-karma-timeout"; var lastKey = Context.Guild.Id + "-" + Context.User.Id + "-karma-timeout";
redis.Client.StringSet(lastKey, GetNewLastKarma()); redis.Client.StringSet(lastKey, GetNewLastKarma());
await ReplyAsync($"{Context.User.Username} gave {user.Mention} karma");
var eb = new EmbedBuilder();
eb.WithAuthor(new EmbedAuthorBuilder()
.WithIconUrl(user.GetAvatarUrl())
.WithName(user.Username));
eb.WithColor(new Color(138, 219, 146));
eb.Title = "Karma Increased";
eb.AddInlineField("By", Context.User.Username);
eb.AddInlineField("amount", "+1");
eb.AddInlineField("Current Karma",newBadJokes);
await ReplyAsync("", false, eb.Build());
} }
} }
@ -53,10 +65,22 @@ namespace Geekbot.net.Modules
{ {
var key = Context.Guild.Id + "-" + user.Id + "-karma"; var key = Context.Guild.Id + "-" + user.Id + "-karma";
var badJokes = (int)redis.Client.StringGet(key); var badJokes = (int)redis.Client.StringGet(key);
redis.Client.StringSet(key, (badJokes - 1).ToString()); var newBadJokes = badJokes - 1;
redis.Client.StringSet(key, newBadJokes.ToString());
var lastKey = Context.Guild.Id + "-" + Context.User.Id + "-karma-timeout"; var lastKey = Context.Guild.Id + "-" + Context.User.Id + "-karma-timeout";
redis.Client.StringSet(lastKey, GetNewLastKarma()); redis.Client.StringSet(lastKey, GetNewLastKarma());
await ReplyAsync($"{Context.User.Username} lowered {user.Mention}'s karma");
var eb = new EmbedBuilder();
eb.WithAuthor(new EmbedAuthorBuilder()
.WithIconUrl(user.GetAvatarUrl())
.WithName(user.Username));
eb.WithColor(new Color(138, 219, 146));
eb.Title = "Karma Decreased";
eb.AddInlineField("By", Context.User.Username);
eb.AddInlineField("amount", "-1");
eb.AddInlineField("Current Karma",newBadJokes);
await ReplyAsync("", false, eb.Build());
} }
} }