mirror of
https://gitlab.com/Kwoth/nadekobot.git
synced 2025-09-11 17:58:26 -04:00
- More code cleanup and codestyle updates
- Fixed some possible nullref exceptions - Methods signatures now have up to 3 parameters before breakaing down each parameter in a separate line - Method invocations have the same rule, except the first parameter will be in the same line as the invocation to prevent some ugliness when passing lambas as arguments - Applied many more codestyles - Extensions folder fully reformatted
This commit is contained in:
@@ -12,9 +12,7 @@ public sealed class BehaviorExecutor : IBehaviourExecutor, INService
|
||||
private IEnumerable<IInputTransformer> _transformers;
|
||||
|
||||
public BehaviorExecutor(IServiceProvider services)
|
||||
{
|
||||
_services = services;
|
||||
}
|
||||
=> _services = services;
|
||||
|
||||
public void Initialize()
|
||||
{
|
||||
|
@@ -60,9 +60,7 @@ public class CurrencyService : ICurrencyService, INService
|
||||
}
|
||||
|
||||
public Task AddAsync(ulong userId, string reason, long amount, bool gamble = false)
|
||||
{
|
||||
return InternalAddAsync(userId, null, null, null, reason, amount, gamble);
|
||||
}
|
||||
=> InternalAddAsync(userId, null, null, null, reason, amount, gamble);
|
||||
|
||||
public async Task AddAsync(IUser user, string reason, long amount, bool sendMessage = false, bool gamble = false)
|
||||
{
|
||||
@@ -141,12 +139,8 @@ public class CurrencyService : ICurrencyService, INService
|
||||
}
|
||||
|
||||
public Task<bool> RemoveAsync(ulong userId, string reason, long amount, bool gamble = false)
|
||||
{
|
||||
return InternalRemoveAsync(userId, null, null, null, reason, amount, gamble);
|
||||
}
|
||||
=> InternalRemoveAsync(userId, null, null, null, reason, amount, gamble);
|
||||
|
||||
public Task<bool> RemoveAsync(IUser user, string reason, long amount, bool sendMessage = false, bool gamble = false)
|
||||
{
|
||||
return InternalRemoveAsync(user.Id, user.Username, user.Discriminator, user.AvatarId, reason, amount, gamble);
|
||||
}
|
||||
=> InternalRemoveAsync(user.Id, user.Username, user.Discriminator, user.AvatarId, reason, amount, gamble);
|
||||
}
|
@@ -74,12 +74,10 @@ public class Localization : ILocalization, INService
|
||||
}
|
||||
|
||||
public void SetDefaultCulture(CultureInfo ci)
|
||||
{
|
||||
_bss.ModifyConfig(bs =>
|
||||
=> _bss.ModifyConfig(bs =>
|
||||
{
|
||||
bs.DefaultLocale = ci;
|
||||
});
|
||||
}
|
||||
|
||||
public void ResetDefaultCulture() =>
|
||||
SetDefaultCulture(CultureInfo.CurrentCulture);
|
||||
|
@@ -69,11 +69,8 @@ public sealed class RedisImagesCache : IImageCache, IReadyExecutor
|
||||
=> GetByteData(ImageKeys.RipOverlay);
|
||||
|
||||
public byte[] GetCard(string key)
|
||||
{
|
||||
// since cards are always local for now, don't cache them
|
||||
return File.ReadAllBytes(Path.Join(_cardsPath, key + ".jpg"));
|
||||
|
||||
}
|
||||
=> File.ReadAllBytes(Path.Join(_cardsPath, key + ".jpg"));
|
||||
|
||||
public async Task OnReadyAsync()
|
||||
{
|
||||
|
@@ -82,12 +82,8 @@ public class RedisLocalDataCache : ILocalDataCache
|
||||
}
|
||||
|
||||
private T Get<T>(string key) where T : class
|
||||
{
|
||||
return JsonConvert.DeserializeObject<T>(_db.StringGet($"{_creds.RedisKey()}_localdata_{key}"));
|
||||
}
|
||||
=> JsonConvert.DeserializeObject<T>(_db.StringGet($"{_creds.RedisKey()}_localdata_{key}"));
|
||||
|
||||
private void Set(string key, object obj)
|
||||
{
|
||||
_db.StringSet($"{_creds.RedisKey()}_localdata_{key}", JsonConvert.SerializeObject(obj));
|
||||
}
|
||||
=> _db.StringSet($"{_creds.RedisKey()}_localdata_{key}", JsonConvert.SerializeObject(obj));
|
||||
}
|
@@ -31,12 +31,10 @@ public class RemoteGrpcCoordinator : ICoordinator, IReadyExecutor
|
||||
}
|
||||
|
||||
public void Die(bool graceful)
|
||||
{
|
||||
_coordClient.Die(new()
|
||||
=> _coordClient.Die(new()
|
||||
{
|
||||
Graceful = graceful
|
||||
});
|
||||
}
|
||||
|
||||
public bool RestartShard(int shardId)
|
||||
{
|
||||
@@ -71,9 +69,7 @@ public class RemoteGrpcCoordinator : ICoordinator, IReadyExecutor
|
||||
}
|
||||
|
||||
public async Task Reload()
|
||||
{
|
||||
await _coordClient.ReloadAsync(new());
|
||||
}
|
||||
=> await _coordClient.ReloadAsync(new());
|
||||
|
||||
public Task OnReadyAsync()
|
||||
{
|
||||
|
@@ -31,18 +31,13 @@ public class SingleProcessCoordinator : ICoordinator
|
||||
}
|
||||
|
||||
public void Die(bool graceful = false)
|
||||
{
|
||||
Environment.Exit(5);
|
||||
}
|
||||
=> Environment.Exit(5);
|
||||
|
||||
public bool RestartShard(int shardId)
|
||||
{
|
||||
return RestartBot();
|
||||
}
|
||||
=> RestartBot();
|
||||
|
||||
public IList<ShardStatus> GetAllShardStatuses()
|
||||
{
|
||||
return new[]
|
||||
=> new[]
|
||||
{
|
||||
new ShardStatus()
|
||||
{
|
||||
@@ -52,15 +47,10 @@ public class SingleProcessCoordinator : ICoordinator
|
||||
ShardId = _client.ShardId
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
public int GetGuildCount()
|
||||
{
|
||||
return _client.Guilds.Count;
|
||||
}
|
||||
=> _client.Guilds.Count;
|
||||
|
||||
public Task Reload()
|
||||
{
|
||||
return Task.CompletedTask;
|
||||
}
|
||||
=> Task.CompletedTask;
|
||||
}
|
@@ -7,9 +7,7 @@ public class SoundCloudApiService : INService
|
||||
private readonly IHttpClientFactory _httpFactory;
|
||||
|
||||
public SoundCloudApiService(IHttpClientFactory factory)
|
||||
{
|
||||
_httpFactory = factory;
|
||||
}
|
||||
=> _httpFactory = factory;
|
||||
|
||||
public async Task<SoundCloudVideo> ResolveVideoAsync(string url)
|
||||
{
|
||||
|
@@ -8,9 +8,7 @@ public class StartingGuildsService : IEnumerable<ulong>, INService
|
||||
private readonly ImmutableList<ulong> _guilds;
|
||||
|
||||
public StartingGuildsService(DiscordSocketClient client)
|
||||
{
|
||||
this._guilds = client.Guilds.Select(x => x.Id).ToImmutableList();
|
||||
}
|
||||
=> this._guilds = client.Guilds.Select(x => x.Id).ToImmutableList();
|
||||
|
||||
public IEnumerator<ulong> GetEnumerator() =>
|
||||
_guilds.GetEnumerator();
|
||||
|
@@ -9,9 +9,7 @@ public class YtdlOperation
|
||||
private readonly string _baseArgString;
|
||||
|
||||
public YtdlOperation(string baseArgString)
|
||||
{
|
||||
_baseArgString = baseArgString;
|
||||
}
|
||||
=> _baseArgString = baseArgString;
|
||||
|
||||
private Process CreateProcess(string[] args)
|
||||
{
|
||||
|
Reference in New Issue
Block a user