Code Cleanup, thanks resharper

This commit is contained in:
runebaas 2017-12-29 01:53:50 +01:00
parent 00035ac4b1
commit 813698394a
No known key found for this signature in database
GPG key ID: 2677AF508D0300D6
34 changed files with 298 additions and 325 deletions

View file

@ -2,7 +2,6 @@
using System.Threading.Tasks;
using Discord.Commands;
using Geekbot.net.Lib;
using StackExchange.Redis;
namespace Geekbot.net.Commands
{
@ -10,13 +9,11 @@ namespace Geekbot.net.Commands
public class BattleTag : ModuleBase
{
private readonly IErrorHandler _errorHandler;
private readonly IDatabase _redis;
private readonly IUserRepository _userRepository;
public BattleTag(IErrorHandler errorHandler, IDatabase redis, IUserRepository userRepository)
public BattleTag(IErrorHandler errorHandler, IUserRepository userRepository)
{
_errorHandler = errorHandler;
_redis = redis;
_userRepository = userRepository;
}
@ -29,21 +26,16 @@ namespace Geekbot.net.Commands
{
var tag = _userRepository.getUserSetting(Context.User.Id, "BattleTag");
if (!string.IsNullOrEmpty(tag))
{
await ReplyAsync($"Your BattleTag is {tag}");
}
else
{
await ReplyAsync("You haven't set your BattleTag, set it with `!battletag user#1234`");
}
}
catch (Exception e)
{
_errorHandler.HandleCommandException(e, Context);
}
}
[Command(RunMode = RunMode.Async)]
[Remarks(CommandCategories.Games)]
[Summary("Save your battletag")]
@ -71,7 +63,7 @@ namespace Geekbot.net.Commands
{
var splited = tag.Split("#");
if (splited.Length != 2) return false;
if (!int.TryParse(splited[1], out int discriminator)) return false;
if (!int.TryParse(splited[1], out var discriminator)) return false;
if (splited[1].Length == 4 || splited[1].Length == 5) return true;
return false;
}