Browse Source

Remove unnecessary null checks

pull/1189/head
Кормилицын Андрей Владиславович 6 years ago
parent
commit
c21682a091
3 changed files with 5 additions and 5 deletions
  1. +1
    -1
      src/Discord.Net.Commands/Map/CommandMapNode.cs
  2. +2
    -2
      src/Discord.Net.Core/Utils/MentionUtils.cs
  3. +2
    -2
      src/Discord.Net.WebSocket/Entities/Guilds/SocketGuild.cs

+ 1
- 1
src/Discord.Net.Commands/Map/CommandMapNode.cs View File

@@ -106,7 +106,7 @@ namespace Discord.Commands
name = text.Substring(index, nextSegment - index); name = text.Substring(index, nextSegment - index);
if (_nodes.TryGetValue(name, out nextNode)) 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; yield return cmd;
} }
} }


+ 2
- 2
src/Discord.Net.Core/Utils/MentionUtils.cs View File

@@ -173,12 +173,12 @@ namespace Discord
{ {
case TagHandling.Name: case TagHandling.Name:
if (user != null) if (user != null)
return $"@{guildUser?.Nickname ?? user?.Username}";
return $"@{guildUser?.Nickname ?? user.Username}";
else else
return ""; return "";
case TagHandling.NameNoPrefix: case TagHandling.NameNoPrefix:
if (user != null) if (user != null)
return $"{guildUser?.Nickname ?? user?.Username}";
return $"{guildUser?.Nickname ?? user.Username}";
else else
return ""; return "";
case TagHandling.FullName: case TagHandling.FullName:


+ 2
- 2
src/Discord.Net.WebSocket/Entities/Guilds/SocketGuild.cs View File

@@ -816,7 +816,7 @@ namespace Discord.WebSocket
{ {
if (model.UserId == CurrentUser.Id) 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; _audioClient.ChannelId = after.VoiceChannel.Id;
await RepopulateAudioStreamsAsync().ConfigureAwait(false); await RepopulateAudioStreamsAsync().ConfigureAwait(false);
@@ -825,7 +825,7 @@ namespace Discord.WebSocket
else else
{ {
await _audioClient.RemoveInputStreamAsync(model.UserId).ConfigureAwait(false); //User changed channels, end their stream 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); await _audioClient.CreateInputStreamAsync(model.UserId).ConfigureAwait(false);
} }
} }


Loading…
Cancel
Save