Compare commits

...

2 commits

Author SHA1 Message Date
8cff234bc6
Upgrade to discord.net 2.0-beta 2018-08-25 21:40:04 +02:00
948c48909e
Allow the same guess after 24h again with !roll 2018-07-22 15:02:53 +02:00
18 changed files with 43 additions and 20 deletions

View file

@ -6,6 +6,7 @@ using Discord.Commands;
using Discord.WebSocket; using Discord.WebSocket;
using Geekbot.net.Lib; using Geekbot.net.Lib;
using Geekbot.net.Lib.ErrorHandling; using Geekbot.net.Lib.ErrorHandling;
using Geekbot.net.Lib.Extensions;
using Geekbot.net.Lib.UserRepository; using Geekbot.net.Lib.UserRepository;
using StackExchange.Redis; using StackExchange.Redis;

View file

@ -4,6 +4,7 @@ using Discord;
using Discord.Commands; using Discord.Commands;
using Geekbot.net.Lib; using Geekbot.net.Lib;
using Geekbot.net.Lib.ErrorHandling; using Geekbot.net.Lib.ErrorHandling;
using Geekbot.net.Lib.Extensions;
using Geekbot.net.Lib.UserRepository; using Geekbot.net.Lib.UserRepository;
using OverwatchAPI; using OverwatchAPI;
using OverwatchAPI.Config; using OverwatchAPI.Config;

View file

@ -5,6 +5,7 @@ using Discord;
using Discord.Commands; using Discord.Commands;
using Geekbot.net.Lib; using Geekbot.net.Lib;
using Geekbot.net.Lib.ErrorHandling; using Geekbot.net.Lib.ErrorHandling;
using Geekbot.net.Lib.Extensions;
using PokeAPI; using PokeAPI;
namespace Geekbot.net.Commands.Games namespace Geekbot.net.Commands.Games

View file

@ -34,15 +34,18 @@ namespace Geekbot.net.Commands.Games
var transDict = _translation.GetDict(Context); var transDict = _translation.GetDict(Context);
if (guess <= 100 && guess > 0) if (guess <= 100 && guess > 0)
{ {
var prevRoll = _redis.HashGet($"{Context.Guild.Id}:RollsPrevious", Context.Message.Author.Id); var prevRoll = _redis.HashGet($"{Context.Guild.Id}:RollsPrevious2", Context.Message.Author.Id).ToString()?.Split('|');
if (!prevRoll.IsNullOrEmpty && prevRoll.ToString() == guess.ToString()) if (prevRoll?.Length == 2)
{ {
await ReplyAsync(string.Format(transDict["NoPrevGuess"], Context.Message.Author.Mention)); if (prevRoll[0] == guess.ToString() && DateTime.Parse(prevRoll[1]) > DateTime.Now.AddDays(-1))
return; {
await ReplyAsync(string.Format(transDict["NoPrevGuess"], Context.Message.Author.Mention));
return;
}
} }
_redis.HashSet($"{Context.Guild.Id}:RollsPrevious", _redis.HashSet($"{Context.Guild.Id}:RollsPrevious2",
new[] {new HashEntry(Context.Message.Author.Id, guess)}); new[] {new HashEntry(Context.Message.Author.Id, $"{guess}|{DateTime.Now}")});
await ReplyAsync(string.Format(transDict["Rolled"], Context.Message.Author.Mention, number, guess)); await ReplyAsync(string.Format(transDict["Rolled"], Context.Message.Author.Mention, number, guess));
if (guess == number) if (guess == number)
{ {

View file

@ -7,6 +7,7 @@ using Discord.Commands;
using Geekbot.net.Lib; using Geekbot.net.Lib;
using Geekbot.net.Lib.Converters; using Geekbot.net.Lib.Converters;
using Geekbot.net.Lib.ErrorHandling; using Geekbot.net.Lib.ErrorHandling;
using Geekbot.net.Lib.Extensions;
using MtgApiManager.Lib.Service; using MtgApiManager.Lib.Service;
namespace Geekbot.net.Commands.Integrations namespace Geekbot.net.Commands.Integrations

View file

@ -6,6 +6,7 @@ using Discord.Commands;
using Geekbot.net.Lib; using Geekbot.net.Lib;
using Geekbot.net.Lib.Clients; using Geekbot.net.Lib.Clients;
using Geekbot.net.Lib.ErrorHandling; using Geekbot.net.Lib.ErrorHandling;
using Geekbot.net.Lib.Extensions;
namespace Geekbot.net.Commands.Integrations namespace Geekbot.net.Commands.Integrations
{ {

View file

@ -6,6 +6,7 @@ using Discord;
using Discord.Commands; using Discord.Commands;
using Geekbot.net.Lib; using Geekbot.net.Lib;
using Geekbot.net.Lib.ErrorHandling; using Geekbot.net.Lib.ErrorHandling;
using Geekbot.net.Lib.Extensions;
using Newtonsoft.Json; using Newtonsoft.Json;
namespace Geekbot.net.Commands.Integrations.UbranDictionary namespace Geekbot.net.Commands.Integrations.UbranDictionary

View file

@ -73,11 +73,9 @@ namespace Geekbot.net.Commands.Randomness
await ReplyAsync("", false, Eb(_mediaProvider.GetFox())); await ReplyAsync("", false, Eb(_mediaProvider.GetFox()));
} }
private EmbedBuilder Eb(string image) private Embed Eb(string image)
{ {
var eb = new EmbedBuilder(); return new EmbedBuilder {ImageUrl = image}.Build();
eb.ImageUrl = image;
return eb;
} }
} }
} }

View file

@ -5,6 +5,7 @@ using Discord;
using Discord.Commands; using Discord.Commands;
using Geekbot.net.Lib; using Geekbot.net.Lib;
using Geekbot.net.Lib.ErrorHandling; using Geekbot.net.Lib.ErrorHandling;
using Geekbot.net.Lib.Extensions;
using Geekbot.net.Lib.Levels; using Geekbot.net.Lib.Levels;
using StackExchange.Redis; using StackExchange.Redis;

View file

@ -4,6 +4,7 @@ using Discord;
using Discord.Commands; using Discord.Commands;
using Geekbot.net.Lib; using Geekbot.net.Lib;
using Geekbot.net.Lib.ErrorHandling; using Geekbot.net.Lib.ErrorHandling;
using Geekbot.net.Lib.Extensions;
using Geekbot.net.Lib.Localization; using Geekbot.net.Lib.Localization;
using StackExchange.Redis; using StackExchange.Redis;

View file

@ -4,6 +4,7 @@ using Discord;
using Discord.Commands; using Discord.Commands;
using Geekbot.net.Lib; using Geekbot.net.Lib;
using Geekbot.net.Lib.ErrorHandling; using Geekbot.net.Lib.ErrorHandling;
using Geekbot.net.Lib.Extensions;
using Geekbot.net.Lib.Levels; using Geekbot.net.Lib.Levels;
using StackExchange.Redis; using StackExchange.Redis;

View file

@ -7,6 +7,7 @@ using Discord.Commands;
using Discord.WebSocket; using Discord.WebSocket;
using Geekbot.net.Lib; using Geekbot.net.Lib;
using Geekbot.net.Lib.ErrorHandling; using Geekbot.net.Lib.ErrorHandling;
using Geekbot.net.Lib.Extensions;
using StackExchange.Redis; using StackExchange.Redis;
namespace Geekbot.net.Commands.Utils namespace Geekbot.net.Commands.Utils

View file

@ -8,6 +8,7 @@ using Discord.Commands;
using Geekbot.net.Lib; using Geekbot.net.Lib;
using Geekbot.net.Lib.Converters; using Geekbot.net.Lib.Converters;
using Geekbot.net.Lib.ErrorHandling; using Geekbot.net.Lib.ErrorHandling;
using Geekbot.net.Lib.Extensions;
using Geekbot.net.Lib.UserRepository; using Geekbot.net.Lib.UserRepository;
using Newtonsoft.Json; using Newtonsoft.Json;
using StackExchange.Redis; using StackExchange.Redis;

View file

@ -189,12 +189,11 @@ namespace Geekbot.net.Commands.Utils.Quote
try try
{ {
var list = Context.Channel.GetMessagesAsync().Flatten(); var list = Context.Channel.GetMessagesAsync().Flatten();
await list; return await list.FirstOrDefault(msg =>
return list.Result msg.Author.Id == user.Id &&
.First(msg => msg.Author.Id == user.Id msg.Embeds.Count == 0 &&
&& msg.Embeds.Count == 0 msg.Id != Context.Message.Id &&
&& msg.Id != Context.Message.Id !msg.Content.ToLower().StartsWith("!"));
&& !msg.Content.ToLower().StartsWith("!"));
} }
catch catch
{ {

View file

@ -15,7 +15,7 @@
<ItemGroup> <ItemGroup>
<PackageReference Include="CommandLineParser" Version="2.2.1" /> <PackageReference Include="CommandLineParser" Version="2.2.1" />
<PackageReference Include="Discord.Net"> <PackageReference Include="Discord.Net">
<Version>1.0.2</Version> <Version>2.0.0-beta</Version>
</PackageReference> </PackageReference>
<PackageReference Include="Google.Apis.YouTube.v3" Version="1.33.0.1202" /> <PackageReference Include="Google.Apis.YouTube.v3" Version="1.33.0.1202" />
<PackageReference Include="HtmlAgilityPack" Version="1.8.1" /> <PackageReference Include="HtmlAgilityPack" Version="1.8.1" />

View file

@ -0,0 +1,12 @@
using Discord;
namespace Geekbot.net.Lib.Extensions
{
public static class EmbedBuilderExtensions
{
public static EmbedBuilder AddInlineField(this EmbedBuilder builder, string name, object value)
{
return builder.AddField(new EmbedFieldBuilder().WithIsInline(true).WithName(name).WithValue(value));
}
}
}

View file

@ -93,8 +93,8 @@
"CHDE": "{0}, du hesch {1} grollt" "CHDE": "{0}, du hesch {1} grollt"
}, },
"NoPrevGuess": { "NoPrevGuess": {
"EN": ":red_circle: {0}, you can't guess the same number again", "EN": ":red_circle: {0}, you can't guess the same number again within 24 hours",
"CHDE": ":red_circle: {0}, du chasch nid nomol es gliche rate" "CHDE": ":red_circle: {0}, du chasch nid nomol es gliche rate innerhalb vo 24 stund"
} }
} }
} }

View file

@ -9,7 +9,7 @@ namespace Geekbot.net.Lib.Polyfills
public ulong Id { get; set; } public ulong Id { get; set; }
public DateTimeOffset CreatedAt { get; set; } public DateTimeOffset CreatedAt { get; set; }
public string Mention { get; set; } public string Mention { get; set; }
public Game? Game { get; set; } public IActivity Activity { get; }
public UserStatus Status { get; set; } public UserStatus Status { get; set; }
public string AvatarId { get; set; } public string AvatarId { get; set; }
public string Discriminator { get; set; } public string Discriminator { get; set; }