Added missing ToString and DebuggerDisplays
This commit is contained in:
@@ -1,13 +1,11 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics;
|
||||
using System.Linq;
|
||||
using System.Threading.Tasks;
|
||||
using Model = Discord.API.Channel;
|
||||
|
||||
namespace Discord.Rest
|
||||
{
|
||||
[DebuggerDisplay(@"{DebuggerDisplay,nq}")]
|
||||
public abstract class RestChannel : RestEntity<ulong>, IChannel, IUpdateable
|
||||
{
|
||||
internal RestChannel(BaseDiscordClient discord, ulong id)
|
||||
|
||||
@@ -76,7 +76,6 @@ namespace Discord.Rest
|
||||
public override string ToString() => $"@{Recipient}";
|
||||
private string DebuggerDisplay => $"@{Recipient} ({Id}, DM)";
|
||||
|
||||
|
||||
//IDMChannel
|
||||
IUser IDMChannel.Recipient => Recipient;
|
||||
|
||||
|
||||
@@ -86,6 +86,9 @@ namespace Discord.Rest
|
||||
public IDisposable EnterTypingState()
|
||||
=> ChannelHelper.EnterTypingState(this, Discord);
|
||||
|
||||
public override string ToString() => Name;
|
||||
private string DebuggerDisplay => $"{Name} ({Id}, Group)";
|
||||
|
||||
//ISocketPrivateChannel
|
||||
IReadOnlyCollection<RestUser> IRestPrivateChannel.Recipients => Recipients;
|
||||
|
||||
|
||||
@@ -2,14 +2,12 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Collections.Immutable;
|
||||
using System.Diagnostics;
|
||||
using System.Linq;
|
||||
using System.Threading.Tasks;
|
||||
using Model = Discord.API.Channel;
|
||||
|
||||
namespace Discord.Rest
|
||||
{
|
||||
[DebuggerDisplay(@"{DebuggerDisplay,nq}")]
|
||||
public abstract class RestGuildChannel : RestChannel, IGuildChannel, IUpdateable
|
||||
{
|
||||
private ImmutableArray<Overwrite> _overwrites;
|
||||
@@ -117,7 +115,9 @@ namespace Discord.Rest
|
||||
=> await ChannelHelper.GetInvitesAsync(this, Discord);
|
||||
public async Task<RestInviteMetadata> CreateInviteAsync(int? maxAge = 3600, int? maxUses = null, bool isTemporary = true)
|
||||
=> await ChannelHelper.CreateInviteAsync(this, Discord, maxAge, maxUses, isTemporary);
|
||||
|
||||
|
||||
public override string ToString() => Name;
|
||||
|
||||
//IGuildChannel
|
||||
async Task<IReadOnlyCollection<IInviteMetadata>> IGuildChannel.GetInvitesAsync()
|
||||
=> await GetInvitesAsync();
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
using Discord.API.Rest;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Collections.Immutable;
|
||||
using System.Diagnostics;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
@@ -67,6 +66,8 @@ namespace Discord.Rest
|
||||
public IDisposable EnterTypingState()
|
||||
=> ChannelHelper.EnterTypingState(this, Discord);
|
||||
|
||||
private string DebuggerDisplay => $"{Name} ({Id}, Text)";
|
||||
|
||||
//IGuildChannel
|
||||
async Task<IGuildUser> IGuildChannel.GetUserAsync(ulong id, CacheMode mode)
|
||||
{
|
||||
|
||||
@@ -2,7 +2,6 @@
|
||||
using Discord.Audio;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Collections.Immutable;
|
||||
using System.Diagnostics;
|
||||
using System.Linq;
|
||||
using System.Threading.Tasks;
|
||||
@@ -37,6 +36,8 @@ namespace Discord.Rest
|
||||
public Task ModifyAsync(Action<ModifyVoiceChannelParams> func)
|
||||
=> ChannelHelper.ModifyAsync(this, Discord, func);
|
||||
|
||||
private string DebuggerDisplay => $"{Name} ({Id}, Voice)";
|
||||
|
||||
//IVoiceChannel
|
||||
Task<IAudioClient> IVoiceChannel.ConnectAsync() { throw new NotSupportedException(); }
|
||||
|
||||
|
||||
@@ -22,6 +22,7 @@ namespace Discord.Rest
|
||||
public override string ToString() => User.ToString();
|
||||
private string DebuggerDisplay => $"{User}: {Reason}";
|
||||
|
||||
//IBan
|
||||
IUser IBan.User => User;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -171,6 +171,9 @@ namespace Discord.Rest
|
||||
public Task<int> PruneUsersAsync(int days = 30, bool simulate = false)
|
||||
=> GuildHelper.PruneUsersAsync(this, Discord, days, simulate);
|
||||
|
||||
public override string ToString() => Name;
|
||||
private string DebuggerDisplay => $"{Name} ({Id})";
|
||||
|
||||
//IGuild
|
||||
bool IGuild.Available => Available;
|
||||
IAudioClient IGuild.AudioClient => null;
|
||||
|
||||
@@ -4,7 +4,6 @@ using Model = Discord.API.InviteMetadata;
|
||||
|
||||
namespace Discord.Rest
|
||||
{
|
||||
[DebuggerDisplay(@"{DebuggerDisplay,nq}")]
|
||||
public class RestInviteMetadata : RestInvite, IInviteMetadata
|
||||
{
|
||||
private long _createdAtTicks;
|
||||
|
||||
@@ -1,8 +1,9 @@
|
||||
using Model = Discord.API.Attachment;
|
||||
using System.Diagnostics;
|
||||
using Model = Discord.API.Attachment;
|
||||
|
||||
namespace Discord
|
||||
{
|
||||
//TODO: Rename to Attachment?
|
||||
[DebuggerDisplay(@"{DebuggerDisplay,nq}")]
|
||||
public class RestAttachment : IAttachment
|
||||
{
|
||||
public ulong Id { get; }
|
||||
@@ -29,5 +30,8 @@ namespace Discord
|
||||
model.Height.IsSpecified ? model.Height.Value : (int?)null,
|
||||
model.Width.IsSpecified ? model.Width.Value : (int?)null);
|
||||
}
|
||||
|
||||
public override string ToString() => Filename;
|
||||
private string DebuggerDisplay => $"{Filename} ({Size} bytes)";
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,7 +1,9 @@
|
||||
using Model = Discord.API.Embed;
|
||||
using System.Diagnostics;
|
||||
using Model = Discord.API.Embed;
|
||||
|
||||
namespace Discord
|
||||
{
|
||||
[DebuggerDisplay(@"{DebuggerDisplay,nq}")]
|
||||
public class RestEmbed : IEmbed
|
||||
{
|
||||
public string Description { get; }
|
||||
@@ -26,5 +28,8 @@ namespace Discord
|
||||
model.Provider.IsSpecified ? EmbedProvider.Create(model.Provider.Value) : (EmbedProvider?)null,
|
||||
model.Thumbnail.IsSpecified ? EmbedThumbnail.Create(model.Thumbnail.Value) : (EmbedThumbnail?)null);
|
||||
}
|
||||
|
||||
public override string ToString() => Title;
|
||||
private string DebuggerDisplay => $"{Title} ({Type})";
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,13 +1,11 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Collections.Immutable;
|
||||
using System.Diagnostics;
|
||||
using System.Threading.Tasks;
|
||||
using Model = Discord.API.Message;
|
||||
|
||||
namespace Discord.Rest
|
||||
{
|
||||
[DebuggerDisplay(@"{DebuggerDisplay,nq}")]
|
||||
public abstract class RestMessage : RestEntity<ulong>, IMessage, IUpdateable
|
||||
{
|
||||
private long _timestampTicks;
|
||||
@@ -56,6 +54,8 @@ namespace Discord.Rest
|
||||
Update(model);
|
||||
}
|
||||
|
||||
public override string ToString() => Content;
|
||||
|
||||
MessageType IMessage.Type => MessageType.Default;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -24,5 +24,7 @@ namespace Discord.Rest
|
||||
|
||||
Type = model.Type;
|
||||
}
|
||||
|
||||
private string DebuggerDisplay => $"{Author}: {Content} ({Id}, {Type})";
|
||||
}
|
||||
}
|
||||
|
||||
@@ -130,5 +130,7 @@ namespace Discord.Rest
|
||||
text = MentionsHelper.ResolveEveryoneMentions(text, everyoneHandling);
|
||||
return text;
|
||||
}
|
||||
|
||||
private string DebuggerDisplay => $"{Author}: {Content} ({Id}{(Attachments.Count > 0 ? $", {Attachments.Count} Attachments" : "")}";
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,9 +1,11 @@
|
||||
using System;
|
||||
using System.Diagnostics;
|
||||
using System.Threading.Tasks;
|
||||
using Model = Discord.API.Application;
|
||||
|
||||
namespace Discord.Rest
|
||||
{
|
||||
[DebuggerDisplay(@"{DebuggerDisplay,nq}")]
|
||||
public class RestApplication : RestEntity<ulong>, IApplication
|
||||
{
|
||||
protected string _iconId;
|
||||
@@ -27,7 +29,6 @@ namespace Discord.Rest
|
||||
entity.Update(model);
|
||||
return entity;
|
||||
}
|
||||
|
||||
internal void Update(Model model)
|
||||
{
|
||||
Description = model.Description;
|
||||
@@ -45,5 +46,8 @@ namespace Discord.Rest
|
||||
throw new InvalidOperationException("Unable to update this object from a different application token.");
|
||||
Update(response);
|
||||
}
|
||||
|
||||
public override string ToString() => Name;
|
||||
private string DebuggerDisplay => $"{Name} ({Id})";
|
||||
}
|
||||
}
|
||||
|
||||
@@ -46,6 +46,9 @@ namespace Discord.Rest
|
||||
public Task DeleteAsync()
|
||||
=> RoleHelper.DeleteAsync(this, Discord);
|
||||
|
||||
public override string ToString() => Name;
|
||||
private string DebuggerDisplay => $"{Name} ({Id})";
|
||||
|
||||
//IRole
|
||||
IGuild IRole.Guild => Guild;
|
||||
}
|
||||
|
||||
@@ -30,6 +30,6 @@ namespace Discord
|
||||
}
|
||||
|
||||
public override string ToString() => Name;
|
||||
private string DebuggerDisplay => $"{Name} ({Id}, Type = {Type}{(IsRevoked ? ", Revoked" : "")})";
|
||||
private string DebuggerDisplay => $"{Name} ({Id}, {Type}{(IsRevoked ? ", Revoked" : "")})";
|
||||
}
|
||||
}
|
||||
|
||||
@@ -46,6 +46,10 @@ namespace Discord.Rest
|
||||
public Task<RestDMChannel> CreateDMChannelAsync()
|
||||
=> 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.FromResult<IDMChannel>(null);
|
||||
async Task<IDMChannel> IUser.CreateDMChannelAsync()
|
||||
|
||||
@@ -6,7 +6,6 @@ using Model = Discord.API.Message;
|
||||
|
||||
namespace Discord.WebSocket
|
||||
{
|
||||
[DebuggerDisplay(@"{DebuggerDisplay,nq}")]
|
||||
public abstract class SocketMessage : SocketEntity<ulong>, IMessage
|
||||
{
|
||||
private long _timestampTicks;
|
||||
@@ -49,7 +48,8 @@ namespace Discord.WebSocket
|
||||
if (model.Content.IsSpecified)
|
||||
Content = model.Content.Value;
|
||||
}
|
||||
|
||||
|
||||
public override string ToString() => Content;
|
||||
internal SocketMessage Clone() => MemberwiseClone() as SocketMessage;
|
||||
|
||||
//IMessage
|
||||
|
||||
@@ -1,7 +1,9 @@
|
||||
using Model = Discord.API.Message;
|
||||
using System.Diagnostics;
|
||||
using Model = Discord.API.Message;
|
||||
|
||||
namespace Discord.WebSocket
|
||||
{
|
||||
[DebuggerDisplay(@"{DebuggerDisplay,nq}")]
|
||||
internal class SocketSystemMessage : SocketMessage, ISystemMessage
|
||||
{
|
||||
public MessageType Type { get; private set; }
|
||||
@@ -22,8 +24,7 @@ namespace Discord.WebSocket
|
||||
|
||||
Type = model.Type;
|
||||
}
|
||||
|
||||
public override string ToString() => Content;
|
||||
|
||||
private string DebuggerDisplay => $"{Author}: {Content} ({Id}, {Type})";
|
||||
internal new SocketSystemMessage Clone() => MemberwiseClone() as SocketSystemMessage;
|
||||
}
|
||||
|
||||
@@ -3,11 +3,13 @@ using Discord.Rest;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Collections.Immutable;
|
||||
using System.Diagnostics;
|
||||
using System.Threading.Tasks;
|
||||
using Model = Discord.API.Message;
|
||||
|
||||
namespace Discord.WebSocket
|
||||
{
|
||||
[DebuggerDisplay(@"{DebuggerDisplay,nq}")]
|
||||
public class SocketUserMessage : SocketMessage, IUserMessage
|
||||
{
|
||||
private bool _isMentioningEveryone, _isTTS, _isPinned;
|
||||
@@ -131,7 +133,6 @@ namespace Discord.WebSocket
|
||||
return text;
|
||||
}
|
||||
|
||||
public override string ToString() => Content;
|
||||
private string DebuggerDisplay => $"{Author}: {Content} ({Id}{(Attachments.Count > 0 ? $", {Attachments.Count} Attachments" : "")}";
|
||||
internal new SocketUserMessage Clone() => MemberwiseClone() as SocketUserMessage;
|
||||
}
|
||||
|
||||
@@ -1,7 +1,9 @@
|
||||
using Model = Discord.API.User;
|
||||
using System.Diagnostics;
|
||||
using Model = Discord.API.User;
|
||||
|
||||
namespace Discord.WebSocket
|
||||
{
|
||||
[DebuggerDisplay(@"{DebuggerDisplay,nq}")]
|
||||
internal class SocketGlobalUser : SocketUser
|
||||
{
|
||||
public override bool IsBot { get; internal set; }
|
||||
|
||||
@@ -3,12 +3,14 @@ using Discord.Rest;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Collections.Immutable;
|
||||
using System.Diagnostics;
|
||||
using System.Threading.Tasks;
|
||||
using Model = Discord.API.GuildMember;
|
||||
using PresenceModel = Discord.API.Presence;
|
||||
|
||||
namespace Discord.WebSocket
|
||||
{
|
||||
[DebuggerDisplay(@"{DebuggerDisplay,nq}")]
|
||||
public class SocketGuildUser : SocketUser, IGuildUser
|
||||
{
|
||||
private long? _joinedAtTicks;
|
||||
|
||||
@@ -1,8 +1,10 @@
|
||||
using Model = Discord.API.Presence;
|
||||
using System.Diagnostics;
|
||||
using Model = Discord.API.Presence;
|
||||
|
||||
namespace Discord.WebSocket
|
||||
{
|
||||
//TODO: C#7 Candidate for record type
|
||||
[DebuggerDisplay(@"{DebuggerDisplay,nq}")]
|
||||
public struct SocketPresence : IPresence
|
||||
{
|
||||
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);
|
||||
}
|
||||
|
||||
public override string ToString() => Status.ToString();
|
||||
internal string DebuggerDisplay => $"{Status}{(Game != null ? $", {Game.Value.Name} ({Game.Value.StreamType})" : "")}";
|
||||
|
||||
internal SocketPresence Clone() => this;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,11 +1,13 @@
|
||||
using Discord.API.Rest;
|
||||
using Discord.Rest;
|
||||
using System;
|
||||
using System.Diagnostics;
|
||||
using System.Threading.Tasks;
|
||||
using Model = Discord.API.User;
|
||||
|
||||
namespace Discord.WebSocket
|
||||
{
|
||||
[DebuggerDisplay(@"{DebuggerDisplay,nq}")]
|
||||
public class SocketSelfUser : SocketUser, ISelfUser
|
||||
{
|
||||
public string Email { get; private set; }
|
||||
|
||||
@@ -1,9 +1,11 @@
|
||||
using System;
|
||||
using System.Diagnostics;
|
||||
using Model = Discord.API.User;
|
||||
using PresenceModel = Discord.API.Presence;
|
||||
|
||||
namespace Discord.WebSocket
|
||||
{
|
||||
[DebuggerDisplay(@"{DebuggerDisplay,nq}")]
|
||||
public class SocketSimpleUser : SocketUser
|
||||
{
|
||||
public override bool IsBot { get; internal set; }
|
||||
|
||||
@@ -44,7 +44,7 @@ namespace Discord.WebSocket
|
||||
=> UserHelper.CreateDMChannelAsync(this, Discord);
|
||||
|
||||
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;
|
||||
|
||||
//IUser
|
||||
|
||||
@@ -1,15 +1,17 @@
|
||||
using System;
|
||||
using System.Diagnostics;
|
||||
using Model = Discord.API.VoiceState;
|
||||
|
||||
namespace Discord.WebSocket
|
||||
{
|
||||
//TODO: C#7 Candidate for record type
|
||||
[DebuggerDisplay(@"{DebuggerDisplay,nq}")]
|
||||
public struct SocketVoiceState : IVoiceState
|
||||
{
|
||||
[Flags]
|
||||
private enum Flags : byte
|
||||
{
|
||||
None = 0x00,
|
||||
Normal = 0x00,
|
||||
Suppressed = 0x01,
|
||||
Muted = 0x02,
|
||||
Deafened = 0x04,
|
||||
@@ -33,7 +35,7 @@ namespace Discord.WebSocket
|
||||
VoiceChannel = voiceChannel;
|
||||
VoiceSessionId = sessionId;
|
||||
|
||||
Flags voiceStates = Flags.None;
|
||||
Flags voiceStates = Flags.Normal;
|
||||
if (isSelfMuted)
|
||||
voiceStates |= Flags.SelfMuted;
|
||||
if (isSelfDeafened)
|
||||
@@ -47,6 +49,8 @@ namespace Discord.WebSocket
|
||||
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;
|
||||
|
||||
IVoiceChannel IVoiceState.VoiceChannel => VoiceChannel;
|
||||
|
||||
Reference in New Issue
Block a user