diff --git a/src/NadekoBot/Modules/Gambling/Gambling.cs b/src/NadekoBot/Modules/Gambling/Gambling.cs index 263f3eb7..948bfd82 100644 --- a/src/NadekoBot/Modules/Gambling/Gambling.cs +++ b/src/NadekoBot/Modules/Gambling/Gambling.cs @@ -9,6 +9,7 @@ using NadekoBot.Services; using Discord.WebSocket; using NadekoBot.Services.Database.Models; using System.Collections.Generic; +using NadekoBot.Services.Database; namespace NadekoBot.Modules.Gambling { @@ -31,6 +32,14 @@ namespace NadekoBot.Modules.Gambling } } + public static long GetCurrency(ulong id) + { + using (var uow = DbHandler.UnitOfWork()) + { + return uow.Currency.GetUserCurrency(id); + } + } + [NadekoCommand, Usage, Description, Aliases] [RequireContext(ContextType.Guild)] public async Task Raffle(IUserMessage umsg, [Remainder] IRole role = null) @@ -52,15 +61,8 @@ namespace NadekoBot.Modules.Gambling var channel = umsg.Channel; user = user ?? umsg.Author; - long amount; - BotConfig config; - using (var uow = DbHandler.UnitOfWork()) - { - amount = uow.Currency.GetUserCurrency(user.Id); - config = uow.BotConfig.GetOrCreate(); - } - await channel.SendMessageAsync($"{user.Username} has {amount} {config.CurrencySign}").ConfigureAwait(false); + await channel.SendMessageAsync($"{user.Username} has {GetCurrency(user.Id)} {CurrencySign}").ConfigureAwait(false); } [NadekoCommand, Usage, Description, Aliases] @@ -69,15 +71,7 @@ namespace NadekoBot.Modules.Gambling { var channel = umsg.Channel; - long amount; - BotConfig config; - using (var uow = DbHandler.UnitOfWork()) - { - amount = uow.Currency.GetUserCurrency(userId); - config = uow.BotConfig.GetOrCreate(); - } - - await channel.SendMessageAsync($"`{userId}` has {amount} {config.CurrencySign}").ConfigureAwait(false); + await channel.SendMessageAsync($"`{userId}` has {GetCurrency(userId)} {CurrencySign}").ConfigureAwait(false); } [NadekoCommand, Usage, Description, Aliases] diff --git a/src/NadekoBot/project.json b/src/NadekoBot/project.json index 12c76009..b5fd1cbb 100644 --- a/src/NadekoBot/project.json +++ b/src/NadekoBot/project.json @@ -47,7 +47,8 @@ "System.Xml.XPath": "4.3.0" }, "tools": { - "Microsoft.EntityFrameworkCore.Tools.DotNet": "1.1.0-preview4-final" + "Microsoft.EntityFrameworkCore.Tools.DotNet": "1.1.0-preview4-final", + "Microsoft.DotNet.Watcher.Tools": "1.1.0-preview4-final" }, "frameworks": { "netcoreapp1.0": {