mirror of
https://gitlab.com/Kwoth/nadekobot.git
synced 2025-09-11 09:48:26 -04:00
Changed all == null to is null and all !(* == null) to * is not null
This commit is contained in:
@@ -24,7 +24,7 @@ namespace NadekoBot.Modules.Searches
|
||||
|
||||
var novelData = await _service.GetNovelData(query).ConfigureAwait(false);
|
||||
|
||||
if (novelData == null)
|
||||
if (novelData is null)
|
||||
{
|
||||
await ReplyErrorLocalizedAsync("failed_finding_novel").ConfigureAwait(false);
|
||||
return;
|
||||
@@ -63,7 +63,7 @@ namespace NadekoBot.Modules.Searches
|
||||
var favorites = document.QuerySelectorAll("div.user-favorites > div.di-tc");
|
||||
|
||||
var favAnime = GetText("anime_no_fav");
|
||||
if (favorites.Length > 0 && favorites[0].QuerySelector("p") == null)
|
||||
if (favorites.Length > 0 && favorites[0].QuerySelector("p") is null)
|
||||
favAnime = string.Join("\n", favorites[0].QuerySelectorAll("ul > li > div.di-tc.va-t > a")
|
||||
.Shuffle()
|
||||
.Take(3)
|
||||
@@ -144,7 +144,7 @@ namespace NadekoBot.Modules.Searches
|
||||
|
||||
var animeData = await _service.GetAnimeData(query).ConfigureAwait(false);
|
||||
|
||||
if (animeData == null)
|
||||
if (animeData is null)
|
||||
{
|
||||
await ReplyErrorLocalizedAsync("failed_finding_anime").ConfigureAwait(false);
|
||||
return;
|
||||
@@ -172,7 +172,7 @@ namespace NadekoBot.Modules.Searches
|
||||
|
||||
var mangaData = await _service.GetMangaData(query).ConfigureAwait(false);
|
||||
|
||||
if (mangaData == null)
|
||||
if (mangaData is null)
|
||||
{
|
||||
await ReplyErrorLocalizedAsync("failed_finding_manga").ConfigureAwait(false);
|
||||
return;
|
||||
|
@@ -32,7 +32,7 @@ namespace NadekoBot.Modules.Searches
|
||||
}
|
||||
}
|
||||
|
||||
if (crypto == null)
|
||||
if (crypto is null)
|
||||
{
|
||||
await ReplyErrorLocalizedAsync("crypto_not_found").ConfigureAwait(false);
|
||||
return;
|
||||
|
@@ -51,7 +51,7 @@ namespace NadekoBot.Modules.Searches
|
||||
public async Task Rip([Leftover] IGuildUser usr)
|
||||
{
|
||||
var av = usr.RealAvatarUrl(128);
|
||||
if (av == null)
|
||||
if (av is null)
|
||||
return;
|
||||
using (var picStream = await _service.GetRipPictureAsync(usr.Nickname ?? usr.Username, av).ConfigureAwait(false))
|
||||
{
|
||||
@@ -73,7 +73,7 @@ namespace NadekoBot.Modules.Searches
|
||||
var embed = new EmbedBuilder();
|
||||
var data = await _service.GetWeatherDataAsync(query).ConfigureAwait(false);
|
||||
|
||||
if (data == null)
|
||||
if (data is null)
|
||||
{
|
||||
embed.WithDescription(GetText("city_not_found"))
|
||||
.WithErrorColor();
|
||||
@@ -115,7 +115,7 @@ namespace NadekoBot.Modules.Searches
|
||||
await ctx.Channel.TriggerTypingAsync().ConfigureAwait(false);
|
||||
|
||||
var (data, err) = await _service.GetTimeDataAsync(query).ConfigureAwait(false);
|
||||
if (!(err is null))
|
||||
if (err is not null)
|
||||
{
|
||||
string errorKey;
|
||||
switch (err)
|
||||
@@ -177,7 +177,7 @@ namespace NadekoBot.Modules.Searches
|
||||
await ctx.Channel.TriggerTypingAsync().ConfigureAwait(false);
|
||||
|
||||
var movie = await _service.GetMovieDataAsync(query).ConfigureAwait(false);
|
||||
if (movie == null)
|
||||
if (movie is null)
|
||||
{
|
||||
await ReplyErrorLocalizedAsync("imdb_fail").ConfigureAwait(false);
|
||||
return;
|
||||
@@ -247,7 +247,7 @@ namespace NadekoBot.Modules.Searches
|
||||
|
||||
var img = (elems.ElementAtOrDefault(new NadekoRandom().Next(0, elems.Count))?.Children?.FirstOrDefault() as IHtmlImageElement);
|
||||
|
||||
if (img?.Source == null)
|
||||
if (img?.Source is null)
|
||||
return;
|
||||
|
||||
var source = img.Source.Replace("b.", ".", StringComparison.InvariantCulture);
|
||||
@@ -406,7 +406,7 @@ namespace NadekoBot.Modules.Searches
|
||||
await ctx.Channel.TriggerTypingAsync().ConfigureAwait(false);
|
||||
var card = await _service.GetMtgCardAsync(search).ConfigureAwait(false);
|
||||
|
||||
if (card == null)
|
||||
if (card is null)
|
||||
{
|
||||
await ReplyErrorLocalizedAsync("card_not_found").ConfigureAwait(false);
|
||||
return;
|
||||
@@ -439,7 +439,7 @@ namespace NadekoBot.Modules.Searches
|
||||
await ctx.Channel.TriggerTypingAsync().ConfigureAwait(false);
|
||||
var card = await _service.GetHearthstoneCardDataAsync(name).ConfigureAwait(false);
|
||||
|
||||
if (card == null)
|
||||
if (card is null)
|
||||
{
|
||||
await ReplyErrorLocalizedAsync("card_not_found").ConfigureAwait(false);
|
||||
return;
|
||||
@@ -560,7 +560,7 @@ namespace NadekoBot.Modules.Searches
|
||||
using (var http = _httpFactory.CreateClient())
|
||||
{
|
||||
var response = await http.GetStringAsync("https://catfact.ninja/fact").ConfigureAwait(false);
|
||||
if (response == null)
|
||||
if (response is null)
|
||||
return;
|
||||
|
||||
var fact = JObject.Parse(response)["fact"].ToString();
|
||||
@@ -573,11 +573,11 @@ namespace NadekoBot.Modules.Searches
|
||||
[RequireContext(ContextType.Guild)]
|
||||
public async Task Revav([Leftover] IGuildUser usr = null)
|
||||
{
|
||||
if (usr == null)
|
||||
if (usr is null)
|
||||
usr = (IGuildUser)ctx.User;
|
||||
|
||||
var av = usr.RealAvatarUrl();
|
||||
if (av == null)
|
||||
if (av is null)
|
||||
return;
|
||||
|
||||
await ctx.Channel.SendConfirmAsync($"https://images.google.com/searchbyimage?image_url={av}").ConfigureAwait(false);
|
||||
@@ -649,12 +649,12 @@ namespace NadekoBot.Modules.Searches
|
||||
[RequireContext(ContextType.Guild)]
|
||||
public async Task Avatar([Leftover] IGuildUser usr = null)
|
||||
{
|
||||
if (usr == null)
|
||||
if (usr is null)
|
||||
usr = (IGuildUser)ctx.User;
|
||||
|
||||
var avatarUrl = usr.RealAvatarUrl(2048);
|
||||
|
||||
if (avatarUrl == null)
|
||||
if (avatarUrl is null)
|
||||
{
|
||||
await ReplyErrorLocalizedAsync("avatar_none", usr.ToString()).ConfigureAwait(false);
|
||||
return;
|
||||
@@ -725,7 +725,7 @@ namespace NadekoBot.Modules.Searches
|
||||
catch
|
||||
{
|
||||
}
|
||||
if (obj.Error != null || obj.Verses == null || obj.Verses.Length == 0)
|
||||
if (obj.Error != null || obj.Verses is null || obj.Verses.Length == 0)
|
||||
await ctx.Channel.SendErrorAsync(obj.Error ?? "No verse found.").ConfigureAwait(false);
|
||||
else
|
||||
{
|
||||
@@ -773,7 +773,7 @@ namespace NadekoBot.Modules.Searches
|
||||
|
||||
var imgObj = await _service.DapiSearch(tag, type, ctx.Guild?.Id).ConfigureAwait(false);
|
||||
|
||||
if (imgObj == null)
|
||||
if (imgObj is null)
|
||||
await channel.SendErrorAsync(umsg.Author.Mention + " " + GetText("no_results")).ConfigureAwait(false);
|
||||
else
|
||||
await channel.EmbedAsync(new EmbedBuilder().WithOkColor()
|
||||
|
@@ -67,7 +67,7 @@ namespace NadekoBot.Modules.Searches.Services
|
||||
using (var document = await BrowsingContext.New(config).OpenAsync(link).ConfigureAwait(false))
|
||||
{
|
||||
var imageElem = document.QuerySelector("div.seriesimg > img");
|
||||
if (imageElem == null)
|
||||
if (imageElem is null)
|
||||
return null;
|
||||
var imageUrl = ((IHtmlImageElement)imageElem).Source;
|
||||
|
||||
|
@@ -40,7 +40,7 @@ namespace NadekoBot.Modules.Searches.Services
|
||||
|| x.Symbol.ToUpperInvariant() == name);
|
||||
|
||||
(CryptoResponseData Elem, int Distance)? nearest = null;
|
||||
if (crypto == null)
|
||||
if (crypto is null)
|
||||
{
|
||||
nearest = cryptos.Select(x => (x, Distance: x.Name.ToUpperInvariant().LevenshteinDistance(name)))
|
||||
.OrderBy(x => x.Distance)
|
||||
|
@@ -118,7 +118,7 @@ namespace NadekoBot.Modules.Searches.Services
|
||||
var previewElement = afi.Element.Elements()
|
||||
.FirstOrDefault(x => x.Name.LocalName == "preview");
|
||||
|
||||
if (previewElement == null)
|
||||
if (previewElement is null)
|
||||
{
|
||||
previewElement = afi.Element.Elements()
|
||||
.FirstOrDefault(x => x.Name.LocalName == "thumbnail");
|
||||
|
@@ -226,7 +226,7 @@ namespace NadekoBot.Modules.Searches.Services
|
||||
$"appid=42cd627dd60debf25a5739e50a217d74&" +
|
||||
$"units=metric").ConfigureAwait(false);
|
||||
|
||||
if (data == null)
|
||||
if (data is null)
|
||||
return null;
|
||||
|
||||
return JsonConvert.DeserializeObject<WeatherData>(data);
|
||||
@@ -504,7 +504,7 @@ namespace NadekoBot.Modules.Searches.Services
|
||||
search,
|
||||
TimeSpan.FromDays(1)).ConfigureAwait(false);
|
||||
|
||||
if (data == null || data.Length == 0)
|
||||
if (data is null || data.Length == 0)
|
||||
return null;
|
||||
|
||||
return data[_rng.Next(0, data.Length)];
|
||||
@@ -543,7 +543,7 @@ namespace NadekoBot.Modules.Searches.Services
|
||||
.ConfigureAwait(false);
|
||||
|
||||
var responseObject = JsonConvert.DeserializeObject<MtgResponse>(response);
|
||||
if (responseObject == null)
|
||||
if (responseObject is null)
|
||||
return new MtgData[0];
|
||||
|
||||
var cards = responseObject.Cards.Take(5).ToArray();
|
||||
@@ -582,12 +582,12 @@ namespace NadekoBot.Modules.Searches.Services
|
||||
var response = await http.GetStringAsync($"https://omgvamp-hearthstone-v1.p.rapidapi.com/" +
|
||||
$"cards/search/{Uri.EscapeUriString(name)}").ConfigureAwait(false);
|
||||
var objs = JsonConvert.DeserializeObject<HearthstoneCardData[]>(response);
|
||||
if (objs == null || objs.Length == 0)
|
||||
if (objs is null || objs.Length == 0)
|
||||
return null;
|
||||
var data = objs.FirstOrDefault(x => x.Collectible)
|
||||
?? objs.FirstOrDefault(x => !string.IsNullOrEmpty(x.PlayerClass))
|
||||
?? objs.FirstOrDefault();
|
||||
if (data == null)
|
||||
if (data is null)
|
||||
return null;
|
||||
if (!string.IsNullOrWhiteSpace(data.Img))
|
||||
{
|
||||
@@ -624,7 +624,7 @@ namespace NadekoBot.Modules.Searches.Services
|
||||
var res = await http.GetStringAsync(string.Format("https://omdbapi.nadeko.bot/?t={0}&y=&plot=full&r=json",
|
||||
name.Trim().Replace(' ', '+'))).ConfigureAwait(false);
|
||||
var movie = JsonConvert.DeserializeObject<OmdbMovie>(res);
|
||||
if (movie?.Title == null)
|
||||
if (movie?.Title is null)
|
||||
return null;
|
||||
movie.Poster = await _google.ShortenUrl(movie.Poster).ConfigureAwait(false);
|
||||
return movie;
|
||||
@@ -671,7 +671,7 @@ namespace NadekoBot.Modules.Searches.Services
|
||||
}
|
||||
}, default(string), TimeSpan.FromHours(24));
|
||||
|
||||
if (gamesMap == null)
|
||||
if (gamesMap is null)
|
||||
return -1;
|
||||
|
||||
|
||||
@@ -780,7 +780,7 @@ namespace NadekoBot.Modules.Searches.Services
|
||||
var href = (children[0].QuerySelector("a") as IHtmlAnchorElement)?.Href;
|
||||
var name = children[0].QuerySelector("h3")?.TextContent;
|
||||
|
||||
if (href == null || name == null)
|
||||
if (href is null || name is null)
|
||||
return null;
|
||||
|
||||
var txt = children[1].TextContent;
|
||||
|
@@ -94,7 +94,7 @@ namespace NadekoBot.Modules.Searches.Services
|
||||
// var oldObj = gc.YtFollowedChannels
|
||||
// .FirstOrDefault(x => x.ChannelId == channelId && x.YtChannelId == ytChannelId);
|
||||
//
|
||||
// if(!(oldObj is null))
|
||||
// if(oldObj is not null)
|
||||
// {
|
||||
// return false;
|
||||
// }
|
||||
|
Reference in New Issue
Block a user