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 Geekbot.net.Lib;
using Geekbot.net.Lib.ErrorHandling;
using Geekbot.net.Lib.Extensions;
using Geekbot.net.Lib.UserRepository;
using StackExchange.Redis;

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

@ -15,7 +15,7 @@
<ItemGroup>
<PackageReference Include="CommandLineParser" Version="2.2.1" />
<PackageReference Include="Discord.Net">
<Version>1.0.2</Version>
<Version>2.0.0-beta</Version>
</PackageReference>
<PackageReference Include="Google.Apis.YouTube.v3" Version="1.33.0.1202" />
<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"
},
"NoPrevGuess": {
"EN": ":red_circle: {0}, you can't guess the same number again",
"CHDE": ":red_circle: {0}, du chasch nid nomol es gliche rate"
"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 innerhalb vo 24 stund"
}
}
}

View file

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