Browse Source

Added missing ToString and DebuggerDisplays

tags/1.0-rc
RogueException 8 years ago
parent
commit
7df38fea3a
28 changed files with 75 additions and 27 deletions
  1. +0
    -2
      src/Discord.Net.Rest/Entities/Channels/RestChannel.cs
  2. +0
    -1
      src/Discord.Net.Rest/Entities/Channels/RestDMChannel.cs
  3. +3
    -0
      src/Discord.Net.Rest/Entities/Channels/RestGroupChannel.cs
  4. +3
    -3
      src/Discord.Net.Rest/Entities/Channels/RestGuildChannel.cs
  5. +2
    -1
      src/Discord.Net.Rest/Entities/Channels/RestTextChannel.cs
  6. +2
    -1
      src/Discord.Net.Rest/Entities/Channels/RestVoiceChannel.cs
  7. +1
    -0
      src/Discord.Net.Rest/Entities/Guilds/RestBan.cs
  8. +3
    -0
      src/Discord.Net.Rest/Entities/Guilds/RestGuild.cs
  9. +0
    -1
      src/Discord.Net.Rest/Entities/Invites/RestInviteMetadata.cs
  10. +6
    -2
      src/Discord.Net.Rest/Entities/Messages/RestAttachment.cs
  11. +6
    -1
      src/Discord.Net.Rest/Entities/Messages/RestEmbed.cs
  12. +2
    -2
      src/Discord.Net.Rest/Entities/Messages/RestMessage.cs
  13. +2
    -0
      src/Discord.Net.Rest/Entities/Messages/RestSystemMessage.cs
  14. +2
    -0
      src/Discord.Net.Rest/Entities/Messages/RestUserMessage.cs
  15. +5
    -1
      src/Discord.Net.Rest/Entities/RestApplication.cs
  16. +3
    -0
      src/Discord.Net.Rest/Entities/Roles/RestRole.cs
  17. +1
    -1
      src/Discord.Net.Rest/Entities/Users/RestConnection.cs
  18. +4
    -0
      src/Discord.Net.Rest/Entities/Users/RestUser.cs
  19. +2
    -2
      src/Discord.Net.WebSocket/Entities/Messages/SocketMessage.cs
  20. +4
    -3
      src/Discord.Net.WebSocket/Entities/Messages/SocketSystemMessage.cs
  21. +2
    -1
      src/Discord.Net.WebSocket/Entities/Messages/SocketUserMessage.cs
  22. +3
    -1
      src/Discord.Net.WebSocket/Entities/Users/SocketGlobalUser.cs
  23. +2
    -0
      src/Discord.Net.WebSocket/Entities/Users/SocketGuildUser.cs
  24. +6
    -1
      src/Discord.Net.WebSocket/Entities/Users/SocketPresence.cs
  25. +2
    -0
      src/Discord.Net.WebSocket/Entities/Users/SocketSelfUser.cs
  26. +2
    -0
      src/Discord.Net.WebSocket/Entities/Users/SocketSimpleUser.cs
  27. +1
    -1
      src/Discord.Net.WebSocket/Entities/Users/SocketUser.cs
  28. +6
    -2
      src/Discord.Net.WebSocket/Entities/Users/SocketVoiceState.cs

+ 0
- 2
src/Discord.Net.Rest/Entities/Channels/RestChannel.cs View File

@@ -1,13 +1,11 @@
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Diagnostics;
using System.Linq; using System.Linq;
using System.Threading.Tasks; using System.Threading.Tasks;
using Model = Discord.API.Channel; using Model = Discord.API.Channel;


namespace Discord.Rest namespace Discord.Rest
{ {
[DebuggerDisplay(@"{DebuggerDisplay,nq}")]
public abstract class RestChannel : RestEntity<ulong>, IChannel, IUpdateable public abstract class RestChannel : RestEntity<ulong>, IChannel, IUpdateable
{ {
internal RestChannel(BaseDiscordClient discord, ulong id) internal RestChannel(BaseDiscordClient discord, ulong id)


+ 0
- 1
src/Discord.Net.Rest/Entities/Channels/RestDMChannel.cs View File

@@ -76,7 +76,6 @@ namespace Discord.Rest
public override string ToString() => $"@{Recipient}"; public override string ToString() => $"@{Recipient}";
private string DebuggerDisplay => $"@{Recipient} ({Id}, DM)"; private string DebuggerDisplay => $"@{Recipient} ({Id}, DM)";



//IDMChannel //IDMChannel
IUser IDMChannel.Recipient => Recipient; IUser IDMChannel.Recipient => Recipient;




+ 3
- 0
src/Discord.Net.Rest/Entities/Channels/RestGroupChannel.cs View File

@@ -86,6 +86,9 @@ namespace Discord.Rest
public IDisposable EnterTypingState() public IDisposable EnterTypingState()
=> ChannelHelper.EnterTypingState(this, Discord); => ChannelHelper.EnterTypingState(this, Discord);


public override string ToString() => Name;
private string DebuggerDisplay => $"{Name} ({Id}, Group)";

//ISocketPrivateChannel //ISocketPrivateChannel
IReadOnlyCollection<RestUser> IRestPrivateChannel.Recipients => Recipients; IReadOnlyCollection<RestUser> IRestPrivateChannel.Recipients => Recipients;




+ 3
- 3
src/Discord.Net.Rest/Entities/Channels/RestGuildChannel.cs View File

@@ -2,14 +2,12 @@
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Collections.Immutable; using System.Collections.Immutable;
using System.Diagnostics;
using System.Linq; using System.Linq;
using System.Threading.Tasks; using System.Threading.Tasks;
using Model = Discord.API.Channel; using Model = Discord.API.Channel;


namespace Discord.Rest namespace Discord.Rest
{ {
[DebuggerDisplay(@"{DebuggerDisplay,nq}")]
public abstract class RestGuildChannel : RestChannel, IGuildChannel, IUpdateable public abstract class RestGuildChannel : RestChannel, IGuildChannel, IUpdateable
{ {
private ImmutableArray<Overwrite> _overwrites; private ImmutableArray<Overwrite> _overwrites;
@@ -117,7 +115,9 @@ namespace Discord.Rest
=> await ChannelHelper.GetInvitesAsync(this, Discord); => await ChannelHelper.GetInvitesAsync(this, Discord);
public async Task<RestInviteMetadata> CreateInviteAsync(int? maxAge = 3600, int? maxUses = null, bool isTemporary = true) public async Task<RestInviteMetadata> CreateInviteAsync(int? maxAge = 3600, int? maxUses = null, bool isTemporary = true)
=> await ChannelHelper.CreateInviteAsync(this, Discord, maxAge, maxUses, isTemporary); => await ChannelHelper.CreateInviteAsync(this, Discord, maxAge, maxUses, isTemporary);

public override string ToString() => Name;

//IGuildChannel //IGuildChannel
async Task<IReadOnlyCollection<IInviteMetadata>> IGuildChannel.GetInvitesAsync() async Task<IReadOnlyCollection<IInviteMetadata>> IGuildChannel.GetInvitesAsync()
=> await GetInvitesAsync(); => await GetInvitesAsync();


+ 2
- 1
src/Discord.Net.Rest/Entities/Channels/RestTextChannel.cs View File

@@ -1,7 +1,6 @@
using Discord.API.Rest; using Discord.API.Rest;
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Collections.Immutable;
using System.Diagnostics; using System.Diagnostics;
using System.IO; using System.IO;
using System.Linq; using System.Linq;
@@ -67,6 +66,8 @@ namespace Discord.Rest
public IDisposable EnterTypingState() public IDisposable EnterTypingState()
=> ChannelHelper.EnterTypingState(this, Discord); => ChannelHelper.EnterTypingState(this, Discord);


private string DebuggerDisplay => $"{Name} ({Id}, Text)";

//IGuildChannel //IGuildChannel
async Task<IGuildUser> IGuildChannel.GetUserAsync(ulong id, CacheMode mode) async Task<IGuildUser> IGuildChannel.GetUserAsync(ulong id, CacheMode mode)
{ {


+ 2
- 1
src/Discord.Net.Rest/Entities/Channels/RestVoiceChannel.cs View File

@@ -2,7 +2,6 @@
using Discord.Audio; using Discord.Audio;
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Collections.Immutable;
using System.Diagnostics; using System.Diagnostics;
using System.Linq; using System.Linq;
using System.Threading.Tasks; using System.Threading.Tasks;
@@ -37,6 +36,8 @@ namespace Discord.Rest
public Task ModifyAsync(Action<ModifyVoiceChannelParams> func) public Task ModifyAsync(Action<ModifyVoiceChannelParams> func)
=> ChannelHelper.ModifyAsync(this, Discord, func); => ChannelHelper.ModifyAsync(this, Discord, func);


private string DebuggerDisplay => $"{Name} ({Id}, Voice)";

//IVoiceChannel //IVoiceChannel
Task<IAudioClient> IVoiceChannel.ConnectAsync() { throw new NotSupportedException(); } Task<IAudioClient> IVoiceChannel.ConnectAsync() { throw new NotSupportedException(); }




+ 1
- 0
src/Discord.Net.Rest/Entities/Guilds/RestBan.cs View File

@@ -22,6 +22,7 @@ namespace Discord.Rest
public override string ToString() => User.ToString(); public override string ToString() => User.ToString();
private string DebuggerDisplay => $"{User}: {Reason}"; private string DebuggerDisplay => $"{User}: {Reason}";


//IBan
IUser IBan.User => User; IUser IBan.User => User;
} }
} }

+ 3
- 0
src/Discord.Net.Rest/Entities/Guilds/RestGuild.cs View File

@@ -171,6 +171,9 @@ namespace Discord.Rest
public Task<int> PruneUsersAsync(int days = 30, bool simulate = false) public Task<int> PruneUsersAsync(int days = 30, bool simulate = false)
=> GuildHelper.PruneUsersAsync(this, Discord, days, simulate); => GuildHelper.PruneUsersAsync(this, Discord, days, simulate);


public override string ToString() => Name;
private string DebuggerDisplay => $"{Name} ({Id})";

//IGuild //IGuild
bool IGuild.Available => Available; bool IGuild.Available => Available;
IAudioClient IGuild.AudioClient => null; IAudioClient IGuild.AudioClient => null;


+ 0
- 1
src/Discord.Net.Rest/Entities/Invites/RestInviteMetadata.cs View File

@@ -4,7 +4,6 @@ using Model = Discord.API.InviteMetadata;


namespace Discord.Rest namespace Discord.Rest
{ {
[DebuggerDisplay(@"{DebuggerDisplay,nq}")]
public class RestInviteMetadata : RestInvite, IInviteMetadata public class RestInviteMetadata : RestInvite, IInviteMetadata
{ {
private long _createdAtTicks; private long _createdAtTicks;


+ 6
- 2
src/Discord.Net.Rest/Entities/Messages/RestAttachment.cs View File

@@ -1,8 +1,9 @@
using Model = Discord.API.Attachment;
using System.Diagnostics;
using Model = Discord.API.Attachment;


namespace Discord namespace Discord
{ {
//TODO: Rename to Attachment?
[DebuggerDisplay(@"{DebuggerDisplay,nq}")]
public class RestAttachment : IAttachment public class RestAttachment : IAttachment
{ {
public ulong Id { get; } public ulong Id { get; }
@@ -29,5 +30,8 @@ namespace Discord
model.Height.IsSpecified ? model.Height.Value : (int?)null, model.Height.IsSpecified ? model.Height.Value : (int?)null,
model.Width.IsSpecified ? model.Width.Value : (int?)null); model.Width.IsSpecified ? model.Width.Value : (int?)null);
} }

public override string ToString() => Filename;
private string DebuggerDisplay => $"{Filename} ({Size} bytes)";
} }
} }

+ 6
- 1
src/Discord.Net.Rest/Entities/Messages/RestEmbed.cs View File

@@ -1,7 +1,9 @@
using Model = Discord.API.Embed;
using System.Diagnostics;
using Model = Discord.API.Embed;


namespace Discord namespace Discord
{ {
[DebuggerDisplay(@"{DebuggerDisplay,nq}")]
public class RestEmbed : IEmbed public class RestEmbed : IEmbed
{ {
public string Description { get; } public string Description { get; }
@@ -26,5 +28,8 @@ namespace Discord
model.Provider.IsSpecified ? EmbedProvider.Create(model.Provider.Value) : (EmbedProvider?)null, model.Provider.IsSpecified ? EmbedProvider.Create(model.Provider.Value) : (EmbedProvider?)null,
model.Thumbnail.IsSpecified ? EmbedThumbnail.Create(model.Thumbnail.Value) : (EmbedThumbnail?)null); model.Thumbnail.IsSpecified ? EmbedThumbnail.Create(model.Thumbnail.Value) : (EmbedThumbnail?)null);
} }

public override string ToString() => Title;
private string DebuggerDisplay => $"{Title} ({Type})";
} }
} }

+ 2
- 2
src/Discord.Net.Rest/Entities/Messages/RestMessage.cs View File

@@ -1,13 +1,11 @@
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Collections.Immutable; using System.Collections.Immutable;
using System.Diagnostics;
using System.Threading.Tasks; using System.Threading.Tasks;
using Model = Discord.API.Message; using Model = Discord.API.Message;


namespace Discord.Rest namespace Discord.Rest
{ {
[DebuggerDisplay(@"{DebuggerDisplay,nq}")]
public abstract class RestMessage : RestEntity<ulong>, IMessage, IUpdateable public abstract class RestMessage : RestEntity<ulong>, IMessage, IUpdateable
{ {
private long _timestampTicks; private long _timestampTicks;
@@ -56,6 +54,8 @@ namespace Discord.Rest
Update(model); Update(model);
} }


public override string ToString() => Content;

MessageType IMessage.Type => MessageType.Default; MessageType IMessage.Type => MessageType.Default;
} }
} }

+ 2
- 0
src/Discord.Net.Rest/Entities/Messages/RestSystemMessage.cs View File

@@ -24,5 +24,7 @@ namespace Discord.Rest


Type = model.Type; Type = model.Type;
} }

private string DebuggerDisplay => $"{Author}: {Content} ({Id}, {Type})";
} }
} }

+ 2
- 0
src/Discord.Net.Rest/Entities/Messages/RestUserMessage.cs View File

@@ -130,5 +130,7 @@ namespace Discord.Rest
text = MentionsHelper.ResolveEveryoneMentions(text, everyoneHandling); text = MentionsHelper.ResolveEveryoneMentions(text, everyoneHandling);
return text; return text;
} }

private string DebuggerDisplay => $"{Author}: {Content} ({Id}{(Attachments.Count > 0 ? $", {Attachments.Count} Attachments" : "")}";
} }
} }

+ 5
- 1
src/Discord.Net.Rest/Entities/RestApplication.cs View File

@@ -1,9 +1,11 @@
using System; using System;
using System.Diagnostics;
using System.Threading.Tasks; using System.Threading.Tasks;
using Model = Discord.API.Application; using Model = Discord.API.Application;


namespace Discord.Rest namespace Discord.Rest
{ {
[DebuggerDisplay(@"{DebuggerDisplay,nq}")]
public class RestApplication : RestEntity<ulong>, IApplication public class RestApplication : RestEntity<ulong>, IApplication
{ {
protected string _iconId; protected string _iconId;
@@ -27,7 +29,6 @@ namespace Discord.Rest
entity.Update(model); entity.Update(model);
return entity; return entity;
} }

internal void Update(Model model) internal void Update(Model model)
{ {
Description = model.Description; Description = model.Description;
@@ -45,5 +46,8 @@ namespace Discord.Rest
throw new InvalidOperationException("Unable to update this object from a different application token."); throw new InvalidOperationException("Unable to update this object from a different application token.");
Update(response); Update(response);
} }

public override string ToString() => Name;
private string DebuggerDisplay => $"{Name} ({Id})";
} }
} }

+ 3
- 0
src/Discord.Net.Rest/Entities/Roles/RestRole.cs View File

@@ -46,6 +46,9 @@ namespace Discord.Rest
public Task DeleteAsync() public Task DeleteAsync()
=> RoleHelper.DeleteAsync(this, Discord); => RoleHelper.DeleteAsync(this, Discord);


public override string ToString() => Name;
private string DebuggerDisplay => $"{Name} ({Id})";

//IRole //IRole
IGuild IRole.Guild => Guild; IGuild IRole.Guild => Guild;
} }


+ 1
- 1
src/Discord.Net.Rest/Entities/Users/RestConnection.cs View File

@@ -30,6 +30,6 @@ namespace Discord
} }


public override string ToString() => Name; public override string ToString() => Name;
private string DebuggerDisplay => $"{Name} ({Id}, Type = {Type}{(IsRevoked ? ", Revoked" : "")})";
private string DebuggerDisplay => $"{Name} ({Id}, {Type}{(IsRevoked ? ", Revoked" : "")})";
} }
} }

+ 4
- 0
src/Discord.Net.Rest/Entities/Users/RestUser.cs View File

@@ -46,6 +46,10 @@ namespace Discord.Rest
public Task<RestDMChannel> CreateDMChannelAsync() public Task<RestDMChannel> CreateDMChannelAsync()
=> UserHelper.CreateDMChannelAsync(this, Discord); => UserHelper.CreateDMChannelAsync(this, Discord);


public override string ToString() => $"{Username}#{Discriminator}";
internal string DebuggerDisplay => $"{Username}#{Discriminator} (Id{(IsBot ? ", Bot" : "")})";

//IUser
Task<IDMChannel> IUser.GetDMChannelAsync(CacheMode mode) Task<IDMChannel> IUser.GetDMChannelAsync(CacheMode mode)
=> Task.FromResult<IDMChannel>(null); => Task.FromResult<IDMChannel>(null);
async Task<IDMChannel> IUser.CreateDMChannelAsync() async Task<IDMChannel> IUser.CreateDMChannelAsync()


+ 2
- 2
src/Discord.Net.WebSocket/Entities/Messages/SocketMessage.cs View File

@@ -6,7 +6,6 @@ using Model = Discord.API.Message;


namespace Discord.WebSocket namespace Discord.WebSocket
{ {
[DebuggerDisplay(@"{DebuggerDisplay,nq}")]
public abstract class SocketMessage : SocketEntity<ulong>, IMessage public abstract class SocketMessage : SocketEntity<ulong>, IMessage
{ {
private long _timestampTicks; private long _timestampTicks;
@@ -49,7 +48,8 @@ namespace Discord.WebSocket
if (model.Content.IsSpecified) if (model.Content.IsSpecified)
Content = model.Content.Value; Content = model.Content.Value;
} }

public override string ToString() => Content;
internal SocketMessage Clone() => MemberwiseClone() as SocketMessage; internal SocketMessage Clone() => MemberwiseClone() as SocketMessage;


//IMessage //IMessage


+ 4
- 3
src/Discord.Net.WebSocket/Entities/Messages/SocketSystemMessage.cs View File

@@ -1,7 +1,9 @@
using Model = Discord.API.Message;
using System.Diagnostics;
using Model = Discord.API.Message;


namespace Discord.WebSocket namespace Discord.WebSocket
{ {
[DebuggerDisplay(@"{DebuggerDisplay,nq}")]
internal class SocketSystemMessage : SocketMessage, ISystemMessage internal class SocketSystemMessage : SocketMessage, ISystemMessage
{ {
public MessageType Type { get; private set; } public MessageType Type { get; private set; }
@@ -22,8 +24,7 @@ namespace Discord.WebSocket


Type = model.Type; Type = model.Type;
} }

public override string ToString() => Content;
private string DebuggerDisplay => $"{Author}: {Content} ({Id}, {Type})"; private string DebuggerDisplay => $"{Author}: {Content} ({Id}, {Type})";
internal new SocketSystemMessage Clone() => MemberwiseClone() as SocketSystemMessage; internal new SocketSystemMessage Clone() => MemberwiseClone() as SocketSystemMessage;
} }


+ 2
- 1
src/Discord.Net.WebSocket/Entities/Messages/SocketUserMessage.cs View File

@@ -3,11 +3,13 @@ using Discord.Rest;
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Collections.Immutable; using System.Collections.Immutable;
using System.Diagnostics;
using System.Threading.Tasks; using System.Threading.Tasks;
using Model = Discord.API.Message; using Model = Discord.API.Message;


namespace Discord.WebSocket namespace Discord.WebSocket
{ {
[DebuggerDisplay(@"{DebuggerDisplay,nq}")]
public class SocketUserMessage : SocketMessage, IUserMessage public class SocketUserMessage : SocketMessage, IUserMessage
{ {
private bool _isMentioningEveryone, _isTTS, _isPinned; private bool _isMentioningEveryone, _isTTS, _isPinned;
@@ -131,7 +133,6 @@ namespace Discord.WebSocket
return text; return text;
} }


public override string ToString() => Content;
private string DebuggerDisplay => $"{Author}: {Content} ({Id}{(Attachments.Count > 0 ? $", {Attachments.Count} Attachments" : "")}"; private string DebuggerDisplay => $"{Author}: {Content} ({Id}{(Attachments.Count > 0 ? $", {Attachments.Count} Attachments" : "")}";
internal new SocketUserMessage Clone() => MemberwiseClone() as SocketUserMessage; internal new SocketUserMessage Clone() => MemberwiseClone() as SocketUserMessage;
} }


+ 3
- 1
src/Discord.Net.WebSocket/Entities/Users/SocketGlobalUser.cs View File

@@ -1,7 +1,9 @@
using Model = Discord.API.User;
using System.Diagnostics;
using Model = Discord.API.User;


namespace Discord.WebSocket namespace Discord.WebSocket
{ {
[DebuggerDisplay(@"{DebuggerDisplay,nq}")]
internal class SocketGlobalUser : SocketUser internal class SocketGlobalUser : SocketUser
{ {
public override bool IsBot { get; internal set; } public override bool IsBot { get; internal set; }


+ 2
- 0
src/Discord.Net.WebSocket/Entities/Users/SocketGuildUser.cs View File

@@ -3,12 +3,14 @@ using Discord.Rest;
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Collections.Immutable; using System.Collections.Immutable;
using System.Diagnostics;
using System.Threading.Tasks; using System.Threading.Tasks;
using Model = Discord.API.GuildMember; using Model = Discord.API.GuildMember;
using PresenceModel = Discord.API.Presence; using PresenceModel = Discord.API.Presence;


namespace Discord.WebSocket namespace Discord.WebSocket
{ {
[DebuggerDisplay(@"{DebuggerDisplay,nq}")]
public class SocketGuildUser : SocketUser, IGuildUser public class SocketGuildUser : SocketUser, IGuildUser
{ {
private long? _joinedAtTicks; private long? _joinedAtTicks;


+ 6
- 1
src/Discord.Net.WebSocket/Entities/Users/SocketPresence.cs View File

@@ -1,8 +1,10 @@
using Model = Discord.API.Presence;
using System.Diagnostics;
using Model = Discord.API.Presence;


namespace Discord.WebSocket namespace Discord.WebSocket
{ {
//TODO: C#7 Candidate for record type //TODO: C#7 Candidate for record type
[DebuggerDisplay(@"{DebuggerDisplay,nq}")]
public struct SocketPresence : IPresence public struct SocketPresence : IPresence
{ {
public Game? Game { get; } public Game? Game { get; }
@@ -18,6 +20,9 @@ namespace Discord.WebSocket
return new SocketPresence(model.Game != null ? Discord.Game.Create(model.Game) : (Game?)null, model.Status); return new SocketPresence(model.Game != null ? Discord.Game.Create(model.Game) : (Game?)null, model.Status);
} }


public override string ToString() => Status.ToString();
internal string DebuggerDisplay => $"{Status}{(Game != null ? $", {Game.Value.Name} ({Game.Value.StreamType})" : "")}";

internal SocketPresence Clone() => this; internal SocketPresence Clone() => this;
} }
} }

+ 2
- 0
src/Discord.Net.WebSocket/Entities/Users/SocketSelfUser.cs View File

@@ -1,11 +1,13 @@
using Discord.API.Rest; using Discord.API.Rest;
using Discord.Rest; using Discord.Rest;
using System; using System;
using System.Diagnostics;
using System.Threading.Tasks; using System.Threading.Tasks;
using Model = Discord.API.User; using Model = Discord.API.User;


namespace Discord.WebSocket namespace Discord.WebSocket
{ {
[DebuggerDisplay(@"{DebuggerDisplay,nq}")]
public class SocketSelfUser : SocketUser, ISelfUser public class SocketSelfUser : SocketUser, ISelfUser
{ {
public string Email { get; private set; } public string Email { get; private set; }


+ 2
- 0
src/Discord.Net.WebSocket/Entities/Users/SocketSimpleUser.cs View File

@@ -1,9 +1,11 @@
using System; using System;
using System.Diagnostics;
using Model = Discord.API.User; using Model = Discord.API.User;
using PresenceModel = Discord.API.Presence; using PresenceModel = Discord.API.Presence;


namespace Discord.WebSocket namespace Discord.WebSocket
{ {
[DebuggerDisplay(@"{DebuggerDisplay,nq}")]
public class SocketSimpleUser : SocketUser public class SocketSimpleUser : SocketUser
{ {
public override bool IsBot { get; internal set; } public override bool IsBot { get; internal set; }


+ 1
- 1
src/Discord.Net.WebSocket/Entities/Users/SocketUser.cs View File

@@ -44,7 +44,7 @@ namespace Discord.WebSocket
=> UserHelper.CreateDMChannelAsync(this, Discord); => UserHelper.CreateDMChannelAsync(this, Discord);


public override string ToString() => $"{Username}#{Discriminator}"; public override string ToString() => $"{Username}#{Discriminator}";
private string DebuggerDisplay => $"{Username}#{Discriminator} (Id{(IsBot ? ", Bot" : "")})";
internal string DebuggerDisplay => $"{Username}#{Discriminator} (Id{(IsBot ? ", Bot" : "")})";
internal SocketUser Clone() => MemberwiseClone() as SocketUser; internal SocketUser Clone() => MemberwiseClone() as SocketUser;


//IUser //IUser


+ 6
- 2
src/Discord.Net.WebSocket/Entities/Users/SocketVoiceState.cs View File

@@ -1,15 +1,17 @@
using System; using System;
using System.Diagnostics;
using Model = Discord.API.VoiceState; using Model = Discord.API.VoiceState;


namespace Discord.WebSocket namespace Discord.WebSocket
{ {
//TODO: C#7 Candidate for record type //TODO: C#7 Candidate for record type
[DebuggerDisplay(@"{DebuggerDisplay,nq}")]
public struct SocketVoiceState : IVoiceState public struct SocketVoiceState : IVoiceState
{ {
[Flags] [Flags]
private enum Flags : byte private enum Flags : byte
{ {
None = 0x00,
Normal = 0x00,
Suppressed = 0x01, Suppressed = 0x01,
Muted = 0x02, Muted = 0x02,
Deafened = 0x04, Deafened = 0x04,
@@ -33,7 +35,7 @@ namespace Discord.WebSocket
VoiceChannel = voiceChannel; VoiceChannel = voiceChannel;
VoiceSessionId = sessionId; VoiceSessionId = sessionId;


Flags voiceStates = Flags.None;
Flags voiceStates = Flags.Normal;
if (isSelfMuted) if (isSelfMuted)
voiceStates |= Flags.SelfMuted; voiceStates |= Flags.SelfMuted;
if (isSelfDeafened) if (isSelfDeafened)
@@ -47,6 +49,8 @@ namespace Discord.WebSocket
return new SocketVoiceState(voiceChannel, model.SessionId, model.SelfMute, model.SelfDeaf, model.Suppress); return new SocketVoiceState(voiceChannel, model.SessionId, model.SelfMute, model.SelfDeaf, model.Suppress);
} }


public override string ToString() => VoiceChannel?.Name ?? "Unknown";
internal string DebuggerDisplay => $"{VoiceChannel?.Name ?? "Unknown"} ({_voiceStates})";
internal SocketVoiceState Clone() => this; internal SocketVoiceState Clone() => this;


IVoiceChannel IVoiceState.VoiceChannel => VoiceChannel; IVoiceChannel IVoiceState.VoiceChannel => VoiceChannel;


Loading…
Cancel
Save