From c21682a0914512951db8d0409a30074c6ec30e92 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=9A=D0=BE=D1=80=D0=BC=D0=B8=D0=BB=D0=B8=D1=86=D1=8B?= =?UTF-8?q?=D0=BD=20=D0=90=D0=BD=D0=B4=D1=80=D0=B5=D0=B9=20=D0=92=D0=BB?= =?UTF-8?q?=D0=B0=D0=B4=D0=B8=D1=81=D0=BB=D0=B0=D0=B2=D0=BE=D0=B2=D0=B8?= =?UTF-8?q?=D1=87?= Date: Tue, 6 Nov 2018 02:06:52 +0300 Subject: [PATCH] Remove unnecessary null checks --- src/Discord.Net.Commands/Map/CommandMapNode.cs | 2 +- src/Discord.Net.Core/Utils/MentionUtils.cs | 4 ++-- src/Discord.Net.WebSocket/Entities/Guilds/SocketGuild.cs | 4 ++-- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/src/Discord.Net.Commands/Map/CommandMapNode.cs b/src/Discord.Net.Commands/Map/CommandMapNode.cs index 16f469cde..61ca8e2d2 100644 --- a/src/Discord.Net.Commands/Map/CommandMapNode.cs +++ b/src/Discord.Net.Commands/Map/CommandMapNode.cs @@ -106,7 +106,7 @@ namespace Discord.Commands name = text.Substring(index, nextSegment - index); if (_nodes.TryGetValue(name, out nextNode)) { - foreach (var cmd in nextNode.GetCommands(service, nextSegment == -1 ? "" : text, nextSegment + 1, false)) + foreach (var cmd in nextNode.GetCommands(service, text, nextSegment + 1, false)) yield return cmd; } } diff --git a/src/Discord.Net.Core/Utils/MentionUtils.cs b/src/Discord.Net.Core/Utils/MentionUtils.cs index 6ffb7eee6..d731fadfa 100644 --- a/src/Discord.Net.Core/Utils/MentionUtils.cs +++ b/src/Discord.Net.Core/Utils/MentionUtils.cs @@ -173,12 +173,12 @@ namespace Discord { case TagHandling.Name: if (user != null) - return $"@{guildUser?.Nickname ?? user?.Username}"; + return $"@{guildUser?.Nickname ?? user.Username}"; else return ""; case TagHandling.NameNoPrefix: if (user != null) - return $"{guildUser?.Nickname ?? user?.Username}"; + return $"{guildUser?.Nickname ?? user.Username}"; else return ""; case TagHandling.FullName: diff --git a/src/Discord.Net.WebSocket/Entities/Guilds/SocketGuild.cs b/src/Discord.Net.WebSocket/Entities/Guilds/SocketGuild.cs index ce8cd08de..91af01c88 100644 --- a/src/Discord.Net.WebSocket/Entities/Guilds/SocketGuild.cs +++ b/src/Discord.Net.WebSocket/Entities/Guilds/SocketGuild.cs @@ -816,7 +816,7 @@ namespace Discord.WebSocket { if (model.UserId == CurrentUser.Id) { - if (after.VoiceChannel != null && _audioClient.ChannelId != after.VoiceChannel?.Id) + if (_audioClient.ChannelId != after.VoiceChannel?.Id) { _audioClient.ChannelId = after.VoiceChannel.Id; await RepopulateAudioStreamsAsync().ConfigureAwait(false); @@ -825,7 +825,7 @@ namespace Discord.WebSocket else { await _audioClient.RemoveInputStreamAsync(model.UserId).ConfigureAwait(false); //User changed channels, end their stream - if (CurrentUser.VoiceChannel != null && after.VoiceChannel?.Id == CurrentUser.VoiceChannel?.Id) + if (after.VoiceChannel?.Id == CurrentUser.VoiceChannel?.Id) await _audioClient.CreateInputStreamAsync(model.UserId).ConfigureAwait(false); } }