mirror of
https://gitlab.com/Kwoth/nadekobot.git
synced 2025-09-12 02:08:27 -04:00
More target-typed new and redundant paranthesis cleanup
This commit is contained in:
@@ -45,7 +45,7 @@ public class SearchesService : INService
|
||||
_cache = cache;
|
||||
_fonts = fonts;
|
||||
_creds = creds;
|
||||
_rng = new NadekoRandom();
|
||||
_rng = new();
|
||||
|
||||
//joke commands
|
||||
if (File.Exists("data/wowjokes.json"))
|
||||
@@ -70,7 +70,7 @@ public class SearchesService : INService
|
||||
}
|
||||
else
|
||||
{
|
||||
_yomamaJokes = new List<string>();
|
||||
_yomamaJokes = new();
|
||||
Log.Warning("data/yomama.txt is missing. .yomama command won't work");
|
||||
}
|
||||
}
|
||||
@@ -86,7 +86,7 @@ public class SearchesService : INService
|
||||
}
|
||||
|
||||
private void DrawAvatar(Image bg, Image avatarImage)
|
||||
=> bg.Mutate(x => x.Grayscale().DrawImage(avatarImage, new Point(83, 139), new GraphicsOptions()));
|
||||
=> bg.Mutate(x => x.Grayscale().DrawImage(avatarImage, new(83, 139), new GraphicsOptions()));
|
||||
|
||||
public async Task<byte[]> GetRipPictureFactory((string text, Uri avatarUrl) arg)
|
||||
{
|
||||
@@ -119,7 +119,7 @@ public class SearchesService : INService
|
||||
}
|
||||
|
||||
bg.Mutate(x => x.DrawText(
|
||||
new TextGraphicsOptions()
|
||||
new()
|
||||
{
|
||||
TextOptions = new TextOptions
|
||||
{
|
||||
@@ -130,12 +130,12 @@ public class SearchesService : INService
|
||||
text,
|
||||
_fonts.RipFont,
|
||||
SixLabors.ImageSharp.Color.Black,
|
||||
new PointF(25, 225)));
|
||||
new(25, 225)));
|
||||
|
||||
//flowa
|
||||
using (var flowers = Image.Load(_imgs.RipOverlay.ToArray()))
|
||||
{
|
||||
bg.Mutate(x => x.DrawImage(flowers, new Point(0, 0), new GraphicsOptions()));
|
||||
bg.Mutate(x => x.DrawImage(flowers, new(0, 0), new GraphicsOptions()));
|
||||
}
|
||||
|
||||
return bg.ToStream().ToArray();
|
||||
@@ -362,7 +362,7 @@ public class SearchesService : INService
|
||||
}
|
||||
catch { storeUrl = "<url can't be found>"; }
|
||||
|
||||
return new MtgData
|
||||
return new()
|
||||
{
|
||||
Description = card.Text,
|
||||
Name = card.Name,
|
||||
@@ -573,7 +573,7 @@ public class SearchesService : INService
|
||||
}
|
||||
}
|
||||
|
||||
private static readonly HtmlParser _googleParser = new HtmlParser(new HtmlParserOptions()
|
||||
private static readonly HtmlParser _googleParser = new HtmlParser(new()
|
||||
{
|
||||
IsScripting = false,
|
||||
IsEmbedded = false,
|
||||
@@ -630,7 +630,7 @@ public class SearchesService : INService
|
||||
.Where(x => x != null)
|
||||
.ToList();
|
||||
|
||||
return new GoogleSearchResultData(
|
||||
return new(
|
||||
results.AsReadOnly(),
|
||||
fullQueryLink,
|
||||
totalResults);
|
||||
@@ -681,7 +681,7 @@ public class SearchesService : INService
|
||||
.Where(x => x != null)
|
||||
.ToList();
|
||||
|
||||
return new GoogleSearchResultData(
|
||||
return new(
|
||||
results.AsReadOnly(),
|
||||
fullQueryLink,
|
||||
"0");
|
||||
|
@@ -61,7 +61,7 @@ public sealed class StreamNotificationService : INService
|
||||
_creds = creds;
|
||||
_pubSub = pubSub;
|
||||
_eb = eb;
|
||||
_streamTracker = new NotifChecker(httpFactory, redis, creds.RedisKey(), client.ShardId == 0);
|
||||
_streamTracker = new(httpFactory, redis, creds.RedisKey(), client.ShardId == 0);
|
||||
|
||||
_streamsOnlineKey = new("streams.online");
|
||||
_streamsOfflineKey = new("streams.offline");
|
||||
@@ -78,7 +78,7 @@ public sealed class StreamNotificationService : INService
|
||||
.Where(x => ids.Contains(x.GuildId))
|
||||
.ToList();
|
||||
|
||||
_offlineNotificationServers = new ConcurrentHashSet<ulong>(guildConfigs
|
||||
_offlineNotificationServers = new(guildConfigs
|
||||
.Where(gc => gc.NotifyStreamOffline)
|
||||
.Select(x => x.GuildId)
|
||||
.ToList());
|
||||
@@ -125,7 +125,7 @@ public sealed class StreamNotificationService : INService
|
||||
_streamTracker.OnStreamsOffline += OnStreamsOffline;
|
||||
_streamTracker.OnStreamsOnline += OnStreamsOnline;
|
||||
_ = _streamTracker.RunAsync();
|
||||
_notifCleanupTimer = new Timer(_ =>
|
||||
_notifCleanupTimer = new(_ =>
|
||||
{
|
||||
try
|
||||
{
|
||||
@@ -155,7 +155,7 @@ public sealed class StreamNotificationService : INService
|
||||
uow.SaveChanges();
|
||||
|
||||
foreach(var loginToDelete in kvp.Value)
|
||||
_streamTracker.UntrackStreamByKey(new StreamDataKey(kvp.Key, loginToDelete));
|
||||
_streamTracker.UntrackStreamByKey(new(kvp.Key, loginToDelete));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -191,7 +191,7 @@ public sealed class StreamNotificationService : INService
|
||||
}
|
||||
else
|
||||
{
|
||||
_trackCounter[key] = new HashSet<ulong>()
|
||||
_trackCounter[key] = new()
|
||||
{
|
||||
info.GuildId
|
||||
};
|
||||
@@ -405,7 +405,7 @@ public sealed class StreamNotificationService : INService
|
||||
var gc = uow.GuildConfigsForId(guildId, set => set.Include(x => x.FollowedStreams));
|
||||
|
||||
// add it to the database
|
||||
fs = new FollowedStream()
|
||||
fs = new()
|
||||
{
|
||||
Type = data.StreamType,
|
||||
Username = data.UniqueName,
|
||||
@@ -504,14 +504,14 @@ public sealed class StreamNotificationService : INService
|
||||
}
|
||||
else
|
||||
{
|
||||
return map[guildId] = new HashSet<FollowedStream>();
|
||||
return map[guildId] = new();
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
_shardTrackedStreams[key] = new Dictionary<ulong, HashSet<FollowedStream>>()
|
||||
_shardTrackedStreams[key] = new()
|
||||
{
|
||||
{guildId, new HashSet<FollowedStream>()}
|
||||
{guildId, new()}
|
||||
};
|
||||
return _shardTrackedStreams[key][guildId];
|
||||
}
|
||||
|
@@ -56,7 +56,7 @@ public sealed class TranslateService : ITranslateService, ILateExecutor, IReadyE
|
||||
if (string.IsNullOrWhiteSpace(msg.Content))
|
||||
return;
|
||||
|
||||
if (msg is IUserMessage { Channel: ITextChannel tch } um)
|
||||
if (msg is { Channel: ITextChannel tch } um)
|
||||
{
|
||||
if (!_atcs.TryGetValue(tch.Id, out var autoDelete))
|
||||
return;
|
||||
|
Reference in New Issue
Block a user