mirror of
https://gitlab.com/Kwoth/nadekobot.git
synced 2025-09-11 17:58:26 -04:00
More target-typed new and redundant paranthesis cleanup
This commit is contained in:
@@ -51,7 +51,7 @@ public sealed class BotCredsProvider : IBotCredsProvider
|
||||
{
|
||||
if (Environment.OSVersion.Platform == PlatformID.Unix)
|
||||
{
|
||||
_creds.RestartCommand = new RestartConfig()
|
||||
_creds.RestartCommand = new()
|
||||
{
|
||||
Args = "dotnet",
|
||||
Cmd = "NadekoBot.dll -- {0}",
|
||||
@@ -59,7 +59,7 @@ public sealed class BotCredsProvider : IBotCredsProvider
|
||||
}
|
||||
else
|
||||
{
|
||||
_creds.RestartCommand = new RestartConfig()
|
||||
_creds.RestartCommand = new()
|
||||
{
|
||||
Args = "NadekoBot.exe",
|
||||
Cmd = "{0}",
|
||||
@@ -141,7 +141,7 @@ public sealed class BotCredsProvider : IBotCredsProvider
|
||||
OsuApiKey = oldCreds.OsuApiKey,
|
||||
CleverbotApiKey = oldCreds.CleverbotApiKey,
|
||||
TotalShards = oldCreds.TotalShards <= 1 ? 1 : oldCreds.TotalShards,
|
||||
Patreon = new Creds.PatreonSettings(oldCreds.PatreonAccessToken,
|
||||
Patreon = new(oldCreds.PatreonAccessToken,
|
||||
null,
|
||||
null,
|
||||
oldCreds.PatreonCampaignId),
|
||||
|
@@ -9,12 +9,12 @@ public class FontProvider : INService
|
||||
|
||||
public FontProvider()
|
||||
{
|
||||
_fonts = new FontCollection();
|
||||
_fonts = new();
|
||||
|
||||
NotoSans = _fonts.Install("data/fonts/NotoSans-Bold.ttf");
|
||||
UniSans = _fonts.Install("data/fonts/Uni Sans.ttf");
|
||||
|
||||
FallBackFonts = new List<FontFamily>();
|
||||
FallBackFonts = new();
|
||||
|
||||
//FallBackFonts.Add(_fonts.Install("data/fonts/OpenSansEmoji.ttf"));
|
||||
|
||||
|
@@ -33,9 +33,9 @@ public class GoogleApiService : IGoogleApiService, INService
|
||||
ApiKey = _creds.GoogleApiKey,
|
||||
};
|
||||
|
||||
yt = new YouTubeService(bcs);
|
||||
sh = new UrlshortenerService(bcs);
|
||||
cs = new CustomsearchService(bcs);
|
||||
yt = new(bcs);
|
||||
sh = new(bcs);
|
||||
cs = new(bcs);
|
||||
}
|
||||
private static readonly Regex plRegex = new Regex("(?:youtu\\.be\\/|list=)(?<id>[\\da-zA-Z\\-_]*)", RegexOptions.Compiled);
|
||||
public async Task<IEnumerable<string>> GetPlaylistIdsByKeywordsAsync(string keywords, int count = 1)
|
||||
@@ -126,7 +126,7 @@ public class GoogleApiService : IGoogleApiService, INService
|
||||
|
||||
try
|
||||
{
|
||||
var response = await sh.Url.Insert(new Url { LongUrl = url }).ExecuteAsync().ConfigureAwait(false);
|
||||
var response = await sh.Url.Insert(new() { LongUrl = url }).ExecuteAsync().ConfigureAwait(false);
|
||||
return response.Id;
|
||||
}
|
||||
catch (GoogleApiException ex) when (ex.HttpStatusCode == HttpStatusCode.Forbidden)
|
||||
@@ -219,7 +219,7 @@ public class GoogleApiService : IGoogleApiService, INService
|
||||
|
||||
var search = await req.ExecuteAsync().ConfigureAwait(false);
|
||||
|
||||
return new ImageResult(search.Items[0].Image, search.Items[0].Link);
|
||||
return new(search.Items[0].Image, search.Items[0].Link);
|
||||
}
|
||||
|
||||
public IReadOnlyDictionary<string, string> Languages { get; } = new Dictionary<string, string>() {
|
||||
|
@@ -28,14 +28,14 @@ public class Localization : ILocalization, INService
|
||||
var cultureInfoNames = bot.AllGuildConfigs
|
||||
.ToDictionary(x => x.GuildId, x => x.Locale);
|
||||
|
||||
GuildCultureInfos = new ConcurrentDictionary<ulong, CultureInfo>(cultureInfoNames.ToDictionary(x => x.Key, x =>
|
||||
GuildCultureInfos = new(cultureInfoNames.ToDictionary(x => x.Key, x =>
|
||||
{
|
||||
CultureInfo cultureInfo = null;
|
||||
try
|
||||
{
|
||||
if (x.Value is null)
|
||||
return null;
|
||||
cultureInfo = new CultureInfo(x.Value);
|
||||
cultureInfo = new(x.Value);
|
||||
}
|
||||
catch { }
|
||||
return cultureInfo;
|
||||
@@ -107,7 +107,7 @@ public class Localization : ILocalization, INService
|
||||
_commandData.TryGetValue(key, out var toReturn);
|
||||
|
||||
if (toReturn is null)
|
||||
return new CommandData
|
||||
return new()
|
||||
{
|
||||
Cmd = key,
|
||||
Desc = key,
|
||||
|
@@ -92,7 +92,7 @@ public sealed class RedisImagesCache : IImageCache, IReadyExecutor
|
||||
{
|
||||
_con = con;
|
||||
_creds = creds;
|
||||
_http = new HttpClient();
|
||||
_http = new();
|
||||
_imagesPath = Path.Combine(_basePath, "images.yml");
|
||||
|
||||
Migrate();
|
||||
@@ -115,7 +115,7 @@ public sealed class RedisImagesCache : IImageCache, IReadyExecutor
|
||||
{
|
||||
var newData = new ImageUrls()
|
||||
{
|
||||
Coins = new ImageUrls.CoinData()
|
||||
Coins = new()
|
||||
{
|
||||
Heads = oldData.Coins.Heads.Length == 1 &&
|
||||
oldData.Coins.Heads[0].ToString() == "https://nadeko-pictures.nyc3.digitaloceanspaces.com/other/coins/heads.png"
|
||||
@@ -128,19 +128,19 @@ public sealed class RedisImagesCache : IImageCache, IReadyExecutor
|
||||
},
|
||||
Dice = oldData.Dice.Map(x => x.ToNewCdn()),
|
||||
Currency = oldData.Currency.Map(x => x.ToNewCdn()),
|
||||
Rategirl = new ImageUrls.RategirlData()
|
||||
Rategirl = new()
|
||||
{
|
||||
Dot = oldData.Rategirl.Dot.ToNewCdn(),
|
||||
Matrix = oldData.Rategirl.Matrix.ToNewCdn()
|
||||
},
|
||||
Rip = new ImageUrls.RipData()
|
||||
Rip = new()
|
||||
{
|
||||
Bg = oldData.Rip.Bg.ToNewCdn(),
|
||||
Overlay = oldData.Rip.Overlay.ToNewCdn(),
|
||||
},
|
||||
Slots = new ImageUrls.SlotData()
|
||||
Slots = new()
|
||||
{
|
||||
Bg = new Uri("https://cdn.nadeko.bot/slots/slots_bg.png"),
|
||||
Bg = new("https://cdn.nadeko.bot/slots/slots_bg.png"),
|
||||
Emojis = new[]
|
||||
{
|
||||
"https://cdn.nadeko.bot/slots/0.png",
|
||||
@@ -151,7 +151,7 @@ public sealed class RedisImagesCache : IImageCache, IReadyExecutor
|
||||
"https://cdn.nadeko.bot/slots/5.png"
|
||||
}.Map(x => new Uri(x))
|
||||
},
|
||||
Xp = new ImageUrls.XpData()
|
||||
Xp = new()
|
||||
{
|
||||
Bg = oldData.Xp.Bg.ToNewCdn(),
|
||||
},
|
||||
|
@@ -26,7 +26,7 @@ public class RemoteGrpcCoordinator : ICoordinator, IReadyExecutor
|
||||
|
||||
public bool RestartBot()
|
||||
{
|
||||
_coordClient.RestartAllShards(new RestartAllRequest
|
||||
_coordClient.RestartAllShards(new()
|
||||
{
|
||||
|
||||
});
|
||||
@@ -36,7 +36,7 @@ public class RemoteGrpcCoordinator : ICoordinator, IReadyExecutor
|
||||
|
||||
public void Die(bool graceful)
|
||||
{
|
||||
_coordClient.Die(new DieRequest()
|
||||
_coordClient.Die(new()
|
||||
{
|
||||
Graceful = graceful
|
||||
});
|
||||
@@ -44,7 +44,7 @@ public class RemoteGrpcCoordinator : ICoordinator, IReadyExecutor
|
||||
|
||||
public bool RestartShard(int shardId)
|
||||
{
|
||||
_coordClient.RestartShard(new RestartShardRequest
|
||||
_coordClient.RestartShard(new()
|
||||
{
|
||||
ShardId = shardId,
|
||||
});
|
||||
@@ -54,7 +54,7 @@ public class RemoteGrpcCoordinator : ICoordinator, IReadyExecutor
|
||||
|
||||
public IList<ShardStatus> GetAllShardStatuses()
|
||||
{
|
||||
var res = _coordClient.GetAllStatuses(new GetAllStatusesRequest());
|
||||
var res = _coordClient.GetAllStatuses(new());
|
||||
|
||||
return res.Statuses
|
||||
.ToArray()
|
||||
@@ -69,7 +69,7 @@ public class RemoteGrpcCoordinator : ICoordinator, IReadyExecutor
|
||||
|
||||
public int GetGuildCount()
|
||||
{
|
||||
var res = _coordClient.GetAllStatuses(new GetAllStatusesRequest());
|
||||
var res = _coordClient.GetAllStatuses(new());
|
||||
|
||||
return res.Statuses.Sum(x => x.GuildCount);
|
||||
}
|
||||
@@ -88,7 +88,7 @@ public class RemoteGrpcCoordinator : ICoordinator, IReadyExecutor
|
||||
{
|
||||
try
|
||||
{
|
||||
var reply = await _coordClient.HeartbeatAsync(new HeartbeatRequest
|
||||
var reply = await _coordClient.HeartbeatAsync(new()
|
||||
{
|
||||
State = ToCoordConnState(_client.ConnectionState),
|
||||
GuildCount = _client.ConnectionState == ConnectionState.Connected ? _client.Guilds.Count : 0,
|
||||
|
@@ -44,7 +44,7 @@ public class StatsService : IStatsService, IReadyExecutor, INService, IDisposabl
|
||||
_client.MessageReceived += _ => Task.FromResult(Interlocked.Increment(ref _messageCounter));
|
||||
cmdHandler.CommandExecuted += (_, e) => Task.FromResult(Interlocked.Increment(ref _commandsRan));
|
||||
|
||||
_client.ChannelCreated += (c) =>
|
||||
_client.ChannelCreated += c =>
|
||||
{
|
||||
var _ = Task.Run(() =>
|
||||
{
|
||||
@@ -57,7 +57,7 @@ public class StatsService : IStatsService, IReadyExecutor, INService, IDisposabl
|
||||
return Task.CompletedTask;
|
||||
};
|
||||
|
||||
_client.ChannelDestroyed += (c) =>
|
||||
_client.ChannelDestroyed += c =>
|
||||
{
|
||||
var _ = Task.Run(() =>
|
||||
{
|
||||
@@ -70,7 +70,7 @@ public class StatsService : IStatsService, IReadyExecutor, INService, IDisposabl
|
||||
return Task.CompletedTask;
|
||||
};
|
||||
|
||||
_client.GuildAvailable += (g) =>
|
||||
_client.GuildAvailable += g =>
|
||||
{
|
||||
var _ = Task.Run(() =>
|
||||
{
|
||||
@@ -82,7 +82,7 @@ public class StatsService : IStatsService, IReadyExecutor, INService, IDisposabl
|
||||
return Task.CompletedTask;
|
||||
};
|
||||
|
||||
_client.JoinedGuild += (g) =>
|
||||
_client.JoinedGuild += g =>
|
||||
{
|
||||
var _ = Task.Run(() =>
|
||||
{
|
||||
@@ -94,7 +94,7 @@ public class StatsService : IStatsService, IReadyExecutor, INService, IDisposabl
|
||||
return Task.CompletedTask;
|
||||
};
|
||||
|
||||
_client.GuildUnavailable += (g) =>
|
||||
_client.GuildUnavailable += g =>
|
||||
{
|
||||
var _ = Task.Run(() =>
|
||||
{
|
||||
@@ -107,7 +107,7 @@ public class StatsService : IStatsService, IReadyExecutor, INService, IDisposabl
|
||||
return Task.CompletedTask;
|
||||
};
|
||||
|
||||
_client.LeftGuild += (g) =>
|
||||
_client.LeftGuild += g =>
|
||||
{
|
||||
var _ = Task.Run(() =>
|
||||
{
|
||||
@@ -120,7 +120,7 @@ public class StatsService : IStatsService, IReadyExecutor, INService, IDisposabl
|
||||
return Task.CompletedTask;
|
||||
};
|
||||
|
||||
_botlistTimer = new Timer(async (state) =>
|
||||
_botlistTimer = new(async state =>
|
||||
{
|
||||
if (string.IsNullOrWhiteSpace(_creds.BotListToken))
|
||||
return;
|
||||
|
@@ -18,9 +18,9 @@ public class YtdlOperation
|
||||
private Process CreateProcess(string[] args)
|
||||
{
|
||||
args = args.Map(arg => arg.Replace("\"", ""));
|
||||
return new Process()
|
||||
return new()
|
||||
{
|
||||
StartInfo = new ProcessStartInfo()
|
||||
StartInfo = new()
|
||||
{
|
||||
FileName = "youtube-dl",
|
||||
Arguments = string.Format(_baseArgString, args),
|
||||
|
Reference in New Issue
Block a user