Simplified ToString, added debug strings
This commit is contained in:
@@ -1,8 +1,10 @@
|
|||||||
using System;
|
using System;
|
||||||
|
using System.Diagnostics;
|
||||||
|
|
||||||
namespace Discord.API
|
namespace Discord.API
|
||||||
{
|
{
|
||||||
//Based on https://github.com/dotnet/coreclr/blob/master/src/mscorlib/src/System/Nullable.cs
|
//Based on https://github.com/dotnet/coreclr/blob/master/src/mscorlib/src/System/Nullable.cs
|
||||||
|
[DebuggerDisplay(@"{DebuggerDisplay,nq}")]
|
||||||
public struct Optional<T> : IOptional
|
public struct Optional<T> : IOptional
|
||||||
{
|
{
|
||||||
private readonly T _value;
|
private readonly T _value;
|
||||||
@@ -40,7 +42,8 @@ namespace Discord.API
|
|||||||
}
|
}
|
||||||
|
|
||||||
public override int GetHashCode() => IsSpecified ? _value.GetHashCode() : 0;
|
public override int GetHashCode() => IsSpecified ? _value.GetHashCode() : 0;
|
||||||
public override string ToString() => IsSpecified ? _value.ToString() : "";
|
public override string ToString() => IsSpecified ? _value?.ToString() : null;
|
||||||
|
private string DebuggerDisplay => IsSpecified ? _value.ToString() : "<unspecified>";
|
||||||
|
|
||||||
public static implicit operator Optional<T>(T value) => new Optional<T>(value);
|
public static implicit operator Optional<T>(T value) => new Optional<T>(value);
|
||||||
public static implicit operator T(Optional<T> value) => value.Value;
|
public static implicit operator T(Optional<T> value) => value.Value;
|
||||||
|
|||||||
@@ -1,5 +1,8 @@
|
|||||||
namespace Discord
|
using System.Diagnostics;
|
||||||
|
|
||||||
|
namespace Discord
|
||||||
{
|
{
|
||||||
|
[DebuggerDisplay("{DebuggerDisplay,nq}")]
|
||||||
public struct IntegrationAccount
|
public struct IntegrationAccount
|
||||||
{
|
{
|
||||||
/// <inheritdoc />
|
/// <inheritdoc />
|
||||||
@@ -8,6 +11,7 @@
|
|||||||
/// <inheritdoc />
|
/// <inheritdoc />
|
||||||
public string Name { get; private set; }
|
public string Name { get; private set; }
|
||||||
|
|
||||||
public override string ToString() => Name ?? Id.ToString();
|
public override string ToString() => Name;
|
||||||
|
private string DebuggerDisplay => $"{Name} ({Id})";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,7 +1,9 @@
|
|||||||
using Model = Discord.API.VoiceRegion;
|
using System.Diagnostics;
|
||||||
|
using Model = Discord.API.VoiceRegion;
|
||||||
|
|
||||||
namespace Discord.Rest
|
namespace Discord.Rest
|
||||||
{
|
{
|
||||||
|
[DebuggerDisplay("{DebuggerDisplay,nq}")]
|
||||||
public class VoiceRegion : IVoiceRegion
|
public class VoiceRegion : IVoiceRegion
|
||||||
{
|
{
|
||||||
/// <inheritdoc />
|
/// <inheritdoc />
|
||||||
@@ -27,6 +29,7 @@ namespace Discord.Rest
|
|||||||
SamplePort = model.SamplePort;
|
SamplePort = model.SamplePort;
|
||||||
}
|
}
|
||||||
|
|
||||||
public override string ToString() => $"{Name ?? Id.ToString()}";
|
public override string ToString() => Name;
|
||||||
|
private string DebuggerDisplay => $"{Name} ({Id}{(IsVip ? ", VIP" : "")}{(IsOptimal ? ", Optimal" : "")})";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,8 +1,10 @@
|
|||||||
using System.Threading.Tasks;
|
using System.Diagnostics;
|
||||||
|
using System.Threading.Tasks;
|
||||||
using Model = Discord.API.Invite;
|
using Model = Discord.API.Invite;
|
||||||
|
|
||||||
namespace Discord
|
namespace Discord
|
||||||
{
|
{
|
||||||
|
[DebuggerDisplay(@"{DebuggerDisplay,nq}")]
|
||||||
public class Invite : IInvite
|
public class Invite : IInvite
|
||||||
{
|
{
|
||||||
/// <inheritdoc />
|
/// <inheritdoc />
|
||||||
@@ -56,6 +58,7 @@ namespace Discord
|
|||||||
|
|
||||||
/// <inheritdoc />
|
/// <inheritdoc />
|
||||||
public override string ToString() => XkcdUrl ?? Url;
|
public override string ToString() => XkcdUrl ?? Url;
|
||||||
|
private string DebuggerDisplay => $"{XkcdUrl ?? Url} ({GuildName} / {ChannelName})";
|
||||||
|
|
||||||
string IEntity<string>.Id => Code;
|
string IEntity<string>.Id => Code;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
namespace Discord
|
namespace Discord
|
||||||
{
|
{
|
||||||
internal enum ChannelPermission : byte
|
public enum ChannelPermission : byte
|
||||||
{
|
{
|
||||||
//General
|
//General
|
||||||
CreateInstantInvite = 0,
|
CreateInstantInvite = 0,
|
||||||
|
|||||||
@@ -1,8 +1,10 @@
|
|||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
|
using System.Diagnostics;
|
||||||
|
|
||||||
namespace Discord
|
namespace Discord
|
||||||
{
|
{
|
||||||
|
[DebuggerDisplay("{DebuggerDisplay,nq}")]
|
||||||
public struct ChannelPermissions
|
public struct ChannelPermissions
|
||||||
{
|
{
|
||||||
private static ChannelPermissions _allDM { get; } = new ChannelPermissions(0b000100_000000_0011111111_0000011001);
|
private static ChannelPermissions _allDM { get; } = new ChannelPermissions(0b000100_000000_0011111111_0000011001);
|
||||||
@@ -117,20 +119,19 @@ namespace Discord
|
|||||||
embedLinks, attachFiles, readMessageHistory, mentionEveryone, connect, speak, muteMembers, deafenMembers,
|
embedLinks, attachFiles, readMessageHistory, mentionEveryone, connect, speak, muteMembers, deafenMembers,
|
||||||
moveMembers, useVoiceActivation, managePermissions);
|
moveMembers, useVoiceActivation, managePermissions);
|
||||||
|
|
||||||
/// <inheritdoc />
|
public List<ChannelPermission> ToList()
|
||||||
public override string ToString()
|
|
||||||
{
|
{
|
||||||
var perms = new List<string>();
|
var perms = new List<ChannelPermission>();
|
||||||
ulong x = 1;
|
ulong x = 1;
|
||||||
for (byte i = 0; i < Permissions.MaxBits; i++, x <<= 1)
|
for (byte i = 0; i < Permissions.MaxBits; i++, x <<= 1)
|
||||||
{
|
{
|
||||||
if ((RawValue & x) != 0)
|
if ((RawValue & x) != 0)
|
||||||
{
|
perms.Add((ChannelPermission)i);
|
||||||
if (Enum.IsDefined(typeof(ChannelPermission), i))
|
|
||||||
perms.Add($"{(ChannelPermission)i}");
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
return string.Join(", ", perms);
|
return perms;
|
||||||
}
|
}
|
||||||
|
/// <inheritdoc />
|
||||||
|
public override string ToString() => RawValue.ToString();
|
||||||
|
private string DebuggerDisplay => $"{RawValue} ({string.Join(", ", ToList())})";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
namespace Discord
|
namespace Discord
|
||||||
{
|
{
|
||||||
internal enum GuildPermission : byte
|
public enum GuildPermission : byte
|
||||||
{
|
{
|
||||||
//General
|
//General
|
||||||
CreateInstantInvite = 0,
|
CreateInstantInvite = 0,
|
||||||
|
|||||||
@@ -1,7 +1,10 @@
|
|||||||
using System.Collections.Generic;
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Diagnostics;
|
||||||
|
|
||||||
namespace Discord
|
namespace Discord
|
||||||
{
|
{
|
||||||
|
[DebuggerDisplay(@"{DebuggerDisplay,nq}")]
|
||||||
public struct GuildPermissions
|
public struct GuildPermissions
|
||||||
{
|
{
|
||||||
/// <summary> Gets a blank GuildPermissions that grants no permissions. </summary>
|
/// <summary> Gets a blank GuildPermissions that grants no permissions. </summary>
|
||||||
@@ -125,21 +128,20 @@ namespace Discord
|
|||||||
=> new GuildPermissions(RawValue, createInstantInvite, manageRoles, kickMembers, banMembers, manageChannels, manageGuild, readMessages,
|
=> new GuildPermissions(RawValue, createInstantInvite, manageRoles, kickMembers, banMembers, manageChannels, manageGuild, readMessages,
|
||||||
sendMessages, sendTTSMessages, manageMessages, embedLinks, attachFiles, mentionEveryone, connect, speak, muteMembers, deafenMembers,
|
sendMessages, sendTTSMessages, manageMessages, embedLinks, attachFiles, mentionEveryone, connect, speak, muteMembers, deafenMembers,
|
||||||
moveMembers, useVoiceActivation, changeNickname, manageNicknames, manageRoles);
|
moveMembers, useVoiceActivation, changeNickname, manageNicknames, manageRoles);
|
||||||
|
|
||||||
/// <inheritdoc />
|
public List<GuildPermission> ToList()
|
||||||
public override string ToString()
|
|
||||||
{
|
{
|
||||||
var perms = new List<string>();
|
var perms = new List<GuildPermission>();
|
||||||
ulong x = 1;
|
ulong x = 1;
|
||||||
for (byte i = 0; i < Permissions.MaxBits; i++, x <<= 1)
|
for (byte i = 0; i < Permissions.MaxBits; i++, x <<= 1)
|
||||||
{
|
{
|
||||||
if ((RawValue & x) != 0)
|
if ((RawValue & x) != 0)
|
||||||
{
|
perms.Add((GuildPermission)i);
|
||||||
if (System.Enum.IsDefined(typeof(GuildPermission), i))
|
|
||||||
perms.Add($"{(GuildPermission)i}");
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
return string.Join(", ", perms);
|
return perms;
|
||||||
}
|
}
|
||||||
|
/// <inheritdoc />
|
||||||
|
public override string ToString() => RawValue.ToString();
|
||||||
|
private string DebuggerDisplay => $"{RawValue} ({string.Join(", ", ToList())})";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,8 +1,10 @@
|
|||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
|
using System.Diagnostics;
|
||||||
|
|
||||||
namespace Discord
|
namespace Discord
|
||||||
{
|
{
|
||||||
|
[DebuggerDisplay(@"{DebuggerDisplay,nq}")]
|
||||||
public struct OverwritePermissions
|
public struct OverwritePermissions
|
||||||
{
|
{
|
||||||
/// <summary> Gets a blank OverwritePermissions that inherits all permissions. </summary>
|
/// <summary> Gets a blank OverwritePermissions that inherits all permissions. </summary>
|
||||||
@@ -111,25 +113,32 @@ namespace Discord
|
|||||||
embedLinks, attachFiles, readMessageHistory, mentionEveryone, connect, speak, muteMembers, deafenMembers,
|
embedLinks, attachFiles, readMessageHistory, mentionEveryone, connect, speak, muteMembers, deafenMembers,
|
||||||
moveMembers, useVoiceActivation, managePermissions);
|
moveMembers, useVoiceActivation, managePermissions);
|
||||||
|
|
||||||
/// <inheritdoc />
|
public List<ChannelPermission> ToAllowList()
|
||||||
public override string ToString()
|
|
||||||
{
|
{
|
||||||
var perms = new List<string>();
|
var perms = new List<ChannelPermission>();
|
||||||
ulong x = 1;
|
ulong x = 1;
|
||||||
for (byte i = 0; i < Permissions.MaxBits; i++, x <<= 1)
|
for (byte i = 0; i < Permissions.MaxBits; i++, x <<= 1)
|
||||||
{
|
{
|
||||||
if ((AllowValue & x) != 0)
|
if ((AllowValue & x) != 0)
|
||||||
{
|
perms.Add((ChannelPermission)i);
|
||||||
if (Enum.IsDefined(typeof(GuildPermission), i))
|
|
||||||
perms.Add($"+{(GuildPermission)i}");
|
|
||||||
}
|
|
||||||
else if ((DenyValue & x) != 0)
|
|
||||||
{
|
|
||||||
if (Enum.IsDefined(typeof(GuildPermission), i))
|
|
||||||
perms.Add($"-{(GuildPermission)i}");
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
return string.Join(", ", perms);
|
return perms;
|
||||||
}
|
}
|
||||||
|
public List<ChannelPermission> ToDenyList()
|
||||||
|
{
|
||||||
|
var perms = new List<ChannelPermission>();
|
||||||
|
ulong x = 1;
|
||||||
|
for (byte i = 0; i < Permissions.MaxBits; i++, x <<= 1)
|
||||||
|
{
|
||||||
|
if ((DenyValue & x) != 0)
|
||||||
|
perms.Add((ChannelPermission)i);
|
||||||
|
}
|
||||||
|
return perms;
|
||||||
|
}
|
||||||
|
/// <inheritdoc />
|
||||||
|
public override string ToString() => $"Allow {AllowValue}, Deny {DenyValue}";
|
||||||
|
private string DebuggerDisplay =>
|
||||||
|
$"Allow {AllowValue} ({string.Join(", ", ToAllowList())})\n" +
|
||||||
|
$"Deny {DenyValue} ({string.Join(", ", ToDenyList())})";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,8 +1,10 @@
|
|||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
|
using System.Diagnostics;
|
||||||
using Model = Discord.API.Connection;
|
using Model = Discord.API.Connection;
|
||||||
|
|
||||||
namespace Discord.Rest
|
namespace Discord.Rest
|
||||||
{
|
{
|
||||||
|
[DebuggerDisplay(@"{DebuggerDisplay,nq}")]
|
||||||
public class Connection : IConnection
|
public class Connection : IConnection
|
||||||
{
|
{
|
||||||
public string Id { get; }
|
public string Id { get; }
|
||||||
@@ -23,6 +25,7 @@ namespace Discord.Rest
|
|||||||
IntegrationIds = model.Integrations;
|
IntegrationIds = model.Integrations;
|
||||||
}
|
}
|
||||||
|
|
||||||
public override string ToString() => $"{Name ?? Id.ToString()} ({Type})";
|
public override string ToString() => Name;
|
||||||
|
private string DebuggerDisplay => $"{Name} ({Id}, Type = {Type}{(IsRevoked ? ", Revoked" : "")})";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -2,6 +2,7 @@
|
|||||||
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.IO;
|
using System.IO;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
@@ -9,6 +10,7 @@ using Model = Discord.API.Channel;
|
|||||||
|
|
||||||
namespace Discord.Rest
|
namespace Discord.Rest
|
||||||
{
|
{
|
||||||
|
[DebuggerDisplay(@"{DebuggerDisplay,nq}")]
|
||||||
public class DMChannel : IDMChannel
|
public class DMChannel : IDMChannel
|
||||||
{
|
{
|
||||||
/// <inheritdoc />
|
/// <inheritdoc />
|
||||||
@@ -121,8 +123,9 @@ namespace Discord.Rest
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// <inheritdoc />
|
/// <inheritdoc />
|
||||||
public override string ToString() => $"@{Recipient} [DM]";
|
public override string ToString() => '@' + Recipient.ToString();
|
||||||
|
private string DebuggerDisplay => $"@{Recipient} ({Id}, DM)";
|
||||||
|
|
||||||
IDMUser IDMChannel.Recipient => Recipient;
|
IDMUser IDMChannel.Recipient => Recipient;
|
||||||
IEnumerable<IMessage> IMessageChannel.CachedMessages => Array.Empty<Message>();
|
IEnumerable<IMessage> IMessageChannel.CachedMessages => Array.Empty<Message>();
|
||||||
|
|
||||||
|
|||||||
@@ -148,6 +148,9 @@ namespace Discord.Rest
|
|||||||
Update(model);
|
Update(model);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <inheritdoc />
|
||||||
|
public override string ToString() => Name;
|
||||||
|
|
||||||
IGuild IGuildChannel.Guild => Guild;
|
IGuild IGuildChannel.Guild => Guild;
|
||||||
async Task<IInviteMetadata> IGuildChannel.CreateInvite(int? maxAge, int? maxUses, bool isTemporary, bool withXkcd)
|
async Task<IInviteMetadata> IGuildChannel.CreateInvite(int? maxAge, int? maxUses, bool isTemporary, bool withXkcd)
|
||||||
=> await CreateInvite(maxAge, maxUses, isTemporary, withXkcd).ConfigureAwait(false);
|
=> await CreateInvite(maxAge, maxUses, isTemporary, withXkcd).ConfigureAwait(false);
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
using Discord.API.Rest;
|
using Discord.API.Rest;
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
|
using System.Diagnostics;
|
||||||
using System.IO;
|
using System.IO;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
@@ -8,6 +9,7 @@ using Model = Discord.API.Channel;
|
|||||||
|
|
||||||
namespace Discord.Rest
|
namespace Discord.Rest
|
||||||
{
|
{
|
||||||
|
[DebuggerDisplay(@"{DebuggerDisplay,nq}")]
|
||||||
public class TextChannel : GuildChannel, ITextChannel
|
public class TextChannel : GuildChannel, ITextChannel
|
||||||
{
|
{
|
||||||
/// <inheritdoc />
|
/// <inheritdoc />
|
||||||
@@ -103,8 +105,7 @@ namespace Discord.Rest
|
|||||||
await Discord.BaseClient.TriggerTypingIndicator(Id).ConfigureAwait(false);
|
await Discord.BaseClient.TriggerTypingIndicator(Id).ConfigureAwait(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <inheritdoc />
|
private string DebuggerDisplay => $"{Name} ({Id}, Text)";
|
||||||
public override string ToString() => $"{base.ToString()} [Text]";
|
|
||||||
|
|
||||||
IEnumerable<IMessage> IMessageChannel.CachedMessages => Array.Empty<Message>();
|
IEnumerable<IMessage> IMessageChannel.CachedMessages => Array.Empty<Message>();
|
||||||
|
|
||||||
|
|||||||
@@ -1,11 +1,13 @@
|
|||||||
using Discord.API.Rest;
|
using Discord.API.Rest;
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
|
using System.Diagnostics;
|
||||||
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 class VoiceChannel : GuildChannel, IVoiceChannel
|
public class VoiceChannel : GuildChannel, IVoiceChannel
|
||||||
{
|
{
|
||||||
/// <inheritdoc />
|
/// <inheritdoc />
|
||||||
@@ -35,7 +37,6 @@ namespace Discord.Rest
|
|||||||
public override Task<GuildUser> GetUser(ulong id) { throw new NotSupportedException(); }
|
public override Task<GuildUser> GetUser(ulong id) { throw new NotSupportedException(); }
|
||||||
public override Task<IEnumerable<GuildUser>> GetUsers() { throw new NotSupportedException(); }
|
public override Task<IEnumerable<GuildUser>> GetUsers() { throw new NotSupportedException(); }
|
||||||
|
|
||||||
/// <inheritdoc />
|
private string DebuggerDisplay => $"{Name} ({Id}, Voice)";
|
||||||
public override string ToString() => $"{base.ToString()} [Voice]";
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -8,10 +8,12 @@ using System.Threading.Tasks;
|
|||||||
using Model = Discord.API.Guild;
|
using Model = Discord.API.Guild;
|
||||||
using EmbedModel = Discord.API.GuildEmbed;
|
using EmbedModel = Discord.API.GuildEmbed;
|
||||||
using RoleModel = Discord.API.Role;
|
using RoleModel = Discord.API.Role;
|
||||||
|
using System.Diagnostics;
|
||||||
|
|
||||||
namespace Discord.Rest
|
namespace Discord.Rest
|
||||||
{
|
{
|
||||||
/// <summary> Represents a Discord guild (called a server in the official client). </summary>
|
/// <summary> Represents a Discord guild (called a server in the official client). </summary>
|
||||||
|
[DebuggerDisplay(@"{DebuggerDisplay,nq}")]
|
||||||
public class Guild : IGuild
|
public class Guild : IGuild
|
||||||
{
|
{
|
||||||
private ConcurrentDictionary<ulong, Role> _roles;
|
private ConcurrentDictionary<ulong, Role> _roles;
|
||||||
@@ -332,7 +334,8 @@ namespace Discord.Rest
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public override string ToString() => Name ?? Id.ToString();
|
public override string ToString() => Name;
|
||||||
|
private string DebuggerDisplay => $"{Name} ({Id})";
|
||||||
|
|
||||||
IEnumerable<Emoji> IGuild.Emojis => Emojis;
|
IEnumerable<Emoji> IGuild.Emojis => Emojis;
|
||||||
ulong IGuild.EveryoneRoleId => EveryoneRole.Id;
|
ulong IGuild.EveryoneRoleId => EveryoneRole.Id;
|
||||||
|
|||||||
@@ -1,8 +1,10 @@
|
|||||||
using System;
|
using System;
|
||||||
|
using System.Diagnostics;
|
||||||
using Model = Discord.API.GuildEmbed;
|
using Model = Discord.API.GuildEmbed;
|
||||||
|
|
||||||
namespace Discord
|
namespace Discord
|
||||||
{
|
{
|
||||||
|
[DebuggerDisplay(@"{DebuggerDisplay,nq}")]
|
||||||
public class GuildEmbed : IGuildEmbed
|
public class GuildEmbed : IGuildEmbed
|
||||||
{
|
{
|
||||||
/// <inheritdoc />
|
/// <inheritdoc />
|
||||||
@@ -26,6 +28,7 @@ namespace Discord
|
|||||||
IsEnabled = model.Enabled;
|
IsEnabled = model.Enabled;
|
||||||
}
|
}
|
||||||
|
|
||||||
public override string ToString() => $"{Id} ({(IsEnabled ? "Enabled" : "Disabled")})";
|
public override string ToString() => Id.ToString();
|
||||||
|
private string DebuggerDisplay => $"{Id}{(IsEnabled ? " (Enabled)" : "")}";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,10 +1,12 @@
|
|||||||
using Discord.API.Rest;
|
using Discord.API.Rest;
|
||||||
using System;
|
using System;
|
||||||
|
using System.Diagnostics;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
using Model = Discord.API.Integration;
|
using Model = Discord.API.Integration;
|
||||||
|
|
||||||
namespace Discord.Rest
|
namespace Discord.Rest
|
||||||
{
|
{
|
||||||
|
[DebuggerDisplay(@"{DebuggerDisplay,nq}")]
|
||||||
public class GuildIntegration : IGuildIntegration
|
public class GuildIntegration : IGuildIntegration
|
||||||
{
|
{
|
||||||
/// <inheritdoc />
|
/// <inheritdoc />
|
||||||
@@ -77,7 +79,8 @@ namespace Discord.Rest
|
|||||||
await Discord.BaseClient.SyncGuildIntegration(Guild.Id, Id).ConfigureAwait(false);
|
await Discord.BaseClient.SyncGuildIntegration(Guild.Id, Id).ConfigureAwait(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
public override string ToString() => $"{Name ?? Id.ToString()} ({(IsEnabled ? "Enabled" : "Disabled")})";
|
public override string ToString() => Name;
|
||||||
|
private string DebuggerDisplay => $"{Name} ({Id}{(IsEnabled ? ", Enabled" : "")})";
|
||||||
|
|
||||||
IGuild IGuildIntegration.Guild => Guild;
|
IGuild IGuildIntegration.Guild => Guild;
|
||||||
IRole IGuildIntegration.Role => Role;
|
IRole IGuildIntegration.Role => Role;
|
||||||
|
|||||||
@@ -1,9 +1,11 @@
|
|||||||
using System;
|
using System;
|
||||||
|
using System.Diagnostics;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
using Model = Discord.API.UserGuild;
|
using Model = Discord.API.UserGuild;
|
||||||
|
|
||||||
namespace Discord
|
namespace Discord
|
||||||
{
|
{
|
||||||
|
[DebuggerDisplay(@"{DebuggerDisplay,nq}")]
|
||||||
public class UserGuild : IUserGuild
|
public class UserGuild : IUserGuild
|
||||||
{
|
{
|
||||||
private string _iconId;
|
private string _iconId;
|
||||||
@@ -48,6 +50,7 @@ namespace Discord
|
|||||||
await Discord.BaseClient.DeleteGuild(Id).ConfigureAwait(false);
|
await Discord.BaseClient.DeleteGuild(Id).ConfigureAwait(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
public override string ToString() => Name ?? Id.ToString();
|
public override string ToString() => Name;
|
||||||
|
private string DebuggerDisplay => $"{Name} ({Id}{(IsOwner ? ", Owned" : "")})";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -2,11 +2,13 @@
|
|||||||
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 class Message : IMessage
|
public class Message : IMessage
|
||||||
{
|
{
|
||||||
/// <inheritdoc />
|
/// <inheritdoc />
|
||||||
@@ -135,7 +137,8 @@ namespace Discord.Rest
|
|||||||
await Discord.BaseClient.DeleteMessage(Channel.Id, Id).ConfigureAwait(false);
|
await Discord.BaseClient.DeleteMessage(Channel.Id, Id).ConfigureAwait(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
public override string ToString() => $"{Author.ToString()}: {Text}";
|
public override string ToString() => Text;
|
||||||
|
private string DebuggerDisplay => $"{Author}: {Text}";
|
||||||
|
|
||||||
IUser IMessage.Author => Author;
|
IUser IMessage.Author => Author;
|
||||||
IReadOnlyList<Attachment> IMessage.Attachments => Attachments;
|
IReadOnlyList<Attachment> IMessage.Attachments => Attachments;
|
||||||
|
|||||||
@@ -1,12 +1,14 @@
|
|||||||
using Discord.API.Rest;
|
using Discord.API.Rest;
|
||||||
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.Role;
|
using Model = Discord.API.Role;
|
||||||
|
|
||||||
namespace Discord.Rest
|
namespace Discord.Rest
|
||||||
{
|
{
|
||||||
|
[DebuggerDisplay(@"{DebuggerDisplay,nq}")]
|
||||||
public class Role : IRole, IMentionable
|
public class Role : IRole, IMentionable
|
||||||
{
|
{
|
||||||
/// <inheritdoc />
|
/// <inheritdoc />
|
||||||
@@ -66,8 +68,9 @@ namespace Discord.Rest
|
|||||||
=> await Discord.BaseClient.DeleteGuildRole(Guild.Id, Id).ConfigureAwait(false);
|
=> await Discord.BaseClient.DeleteGuildRole(Guild.Id, Id).ConfigureAwait(false);
|
||||||
|
|
||||||
/// <inheritdoc />
|
/// <inheritdoc />
|
||||||
public override string ToString() => Name ?? Id.ToString();
|
public override string ToString() => Name;
|
||||||
|
private string DebuggerDisplay => $"{Name} ({Id})";
|
||||||
|
|
||||||
ulong IRole.GuildId => Guild.Id;
|
ulong IRole.GuildId => Guild.Id;
|
||||||
|
|
||||||
async Task<IEnumerable<IGuildUser>> IRole.GetUsers()
|
async Task<IEnumerable<IGuildUser>> IRole.GetUsers()
|
||||||
|
|||||||
@@ -1,10 +1,12 @@
|
|||||||
using Discord.API.Rest;
|
using Discord.API.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.Rest
|
namespace Discord.Rest
|
||||||
{
|
{
|
||||||
|
[DebuggerDisplay("{DebuggerDisplay,nq}")]
|
||||||
public abstract class User : IUser
|
public abstract class User : IUser
|
||||||
{
|
{
|
||||||
private string _avatarId;
|
private string _avatarId;
|
||||||
@@ -51,7 +53,8 @@ namespace Discord.Rest
|
|||||||
return new DMChannel(Discord, model);
|
return new DMChannel(Discord, model);
|
||||||
}
|
}
|
||||||
|
|
||||||
public override string ToString() => $"{Username ?? Id.ToString()}";
|
public override string ToString() => $"{Username}#{Discriminator}";
|
||||||
|
private string DebuggerDisplay => $"{Username}#{Discriminator} ({Id})";
|
||||||
|
|
||||||
/// <inheritdoc />
|
/// <inheritdoc />
|
||||||
Game? IUser.CurrentGame => null;
|
Game? IUser.CurrentGame => null;
|
||||||
|
|||||||
@@ -2,6 +2,7 @@
|
|||||||
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.IO;
|
using System.IO;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
@@ -9,6 +10,7 @@ using Model = Discord.API.Channel;
|
|||||||
|
|
||||||
namespace Discord.WebSocket
|
namespace Discord.WebSocket
|
||||||
{
|
{
|
||||||
|
[DebuggerDisplay(@"{DebuggerDisplay,nq}")]
|
||||||
public class DMChannel : IDMChannel
|
public class DMChannel : IDMChannel
|
||||||
{
|
{
|
||||||
private readonly MessageCache _messages;
|
private readonly MessageCache _messages;
|
||||||
@@ -114,8 +116,9 @@ namespace Discord.WebSocket
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// <inheritdoc />
|
/// <inheritdoc />
|
||||||
public override string ToString() => $"@{Recipient} [DM]";
|
public override string ToString() => '@' + Recipient.ToString();
|
||||||
|
private string DebuggerDisplay => $"@{Recipient} ({Id}, DM)";
|
||||||
|
|
||||||
IDMUser IDMChannel.Recipient => Recipient;
|
IDMUser IDMChannel.Recipient => Recipient;
|
||||||
IEnumerable<IMessage> IMessageChannel.CachedMessages => CachedMessages;
|
IEnumerable<IMessage> IMessageChannel.CachedMessages => CachedMessages;
|
||||||
|
|
||||||
|
|||||||
@@ -133,6 +133,9 @@ namespace Discord.WebSocket
|
|||||||
await Discord.BaseClient.DeleteChannel(Id).ConfigureAwait(false);
|
await Discord.BaseClient.DeleteChannel(Id).ConfigureAwait(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <inheritdoc />
|
||||||
|
public override string ToString() => Name;
|
||||||
|
|
||||||
IGuild IGuildChannel.Guild => Guild;
|
IGuild IGuildChannel.Guild => Guild;
|
||||||
async Task<IInviteMetadata> IGuildChannel.CreateInvite(int? maxAge, int? maxUses, bool isTemporary, bool withXkcd)
|
async Task<IInviteMetadata> IGuildChannel.CreateInvite(int? maxAge, int? maxUses, bool isTemporary, bool withXkcd)
|
||||||
=> await CreateInvite(maxAge, maxUses, isTemporary, withXkcd).ConfigureAwait(false);
|
=> await CreateInvite(maxAge, maxUses, isTemporary, withXkcd).ConfigureAwait(false);
|
||||||
|
|||||||
@@ -2,6 +2,7 @@
|
|||||||
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.IO;
|
using System.IO;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
@@ -9,6 +10,7 @@ using Model = Discord.API.Channel;
|
|||||||
|
|
||||||
namespace Discord.WebSocket
|
namespace Discord.WebSocket
|
||||||
{
|
{
|
||||||
|
[DebuggerDisplay(@"{DebuggerDisplay,nq}")]
|
||||||
public class TextChannel : GuildChannel, ITextChannel
|
public class TextChannel : GuildChannel, ITextChannel
|
||||||
{
|
{
|
||||||
private readonly MessageCache _messages;
|
private readonly MessageCache _messages;
|
||||||
@@ -105,8 +107,7 @@ namespace Discord.WebSocket
|
|||||||
await Discord.BaseClient.TriggerTypingIndicator(Id).ConfigureAwait(false);
|
await Discord.BaseClient.TriggerTypingIndicator(Id).ConfigureAwait(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <inheritdoc />
|
private string DebuggerDisplay => $"{Name} ({Id}, Text)";
|
||||||
public override string ToString() => $"{base.ToString()} [Text]";
|
|
||||||
|
|
||||||
IEnumerable<IMessage> IMessageChannel.CachedMessages => CachedMessages;
|
IEnumerable<IMessage> IMessageChannel.CachedMessages => CachedMessages;
|
||||||
|
|
||||||
|
|||||||
@@ -1,12 +1,14 @@
|
|||||||
using Discord.API.Rest;
|
using Discord.API.Rest;
|
||||||
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.WebSocket
|
namespace Discord.WebSocket
|
||||||
{
|
{
|
||||||
|
[DebuggerDisplay(@"{DebuggerDisplay,nq}")]
|
||||||
public class VoiceChannel : GuildChannel, IVoiceChannel
|
public class VoiceChannel : GuildChannel, IVoiceChannel
|
||||||
{
|
{
|
||||||
/// <inheritdoc />
|
/// <inheritdoc />
|
||||||
@@ -43,7 +45,6 @@ namespace Discord.WebSocket
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <inheritdoc />
|
private string DebuggerDisplay => $"{Name} ({Id}, Voice)";
|
||||||
public override string ToString() => $"{base.ToString()} [Voice]";
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -8,10 +8,12 @@ using System.Threading.Tasks;
|
|||||||
using Model = Discord.API.Guild;
|
using Model = Discord.API.Guild;
|
||||||
using EmbedModel = Discord.API.GuildEmbed;
|
using EmbedModel = Discord.API.GuildEmbed;
|
||||||
using RoleModel = Discord.API.Role;
|
using RoleModel = Discord.API.Role;
|
||||||
|
using System.Diagnostics;
|
||||||
|
|
||||||
namespace Discord.WebSocket
|
namespace Discord.WebSocket
|
||||||
{
|
{
|
||||||
/// <summary> Represents a Discord guild (called a server in the official client). </summary>
|
/// <summary> Represents a Discord guild (called a server in the official client). </summary>
|
||||||
|
[DebuggerDisplay(@"{DebuggerDisplay,nq}")]
|
||||||
public class Guild : IGuild
|
public class Guild : IGuild
|
||||||
{
|
{
|
||||||
private ConcurrentDictionary<ulong, Role> _roles;
|
private ConcurrentDictionary<ulong, Role> _roles;
|
||||||
@@ -325,7 +327,8 @@ namespace Discord.WebSocket
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public override string ToString() => Name ?? Id.ToString();
|
public override string ToString() => Name;
|
||||||
|
private string DebuggerDisplay => $"{Name} ({Id})";
|
||||||
|
|
||||||
IEnumerable<Emoji> IGuild.Emojis => Emojis;
|
IEnumerable<Emoji> IGuild.Emojis => Emojis;
|
||||||
ulong IGuild.EveryoneRoleId => EveryoneRole.Id;
|
ulong IGuild.EveryoneRoleId => EveryoneRole.Id;
|
||||||
|
|||||||
@@ -1,10 +1,12 @@
|
|||||||
using Discord.API.Rest;
|
using Discord.API.Rest;
|
||||||
using System;
|
using System;
|
||||||
|
using System.Diagnostics;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
using Model = Discord.API.Integration;
|
using Model = Discord.API.Integration;
|
||||||
|
|
||||||
namespace Discord.WebSocket
|
namespace Discord.WebSocket
|
||||||
{
|
{
|
||||||
|
[DebuggerDisplay(@"{DebuggerDisplay,nq}")]
|
||||||
public class GuildIntegration : IGuildIntegration
|
public class GuildIntegration : IGuildIntegration
|
||||||
{
|
{
|
||||||
/// <inheritdoc />
|
/// <inheritdoc />
|
||||||
@@ -75,7 +77,8 @@ namespace Discord.WebSocket
|
|||||||
await Discord.BaseClient.SyncGuildIntegration(Guild.Id, Id).ConfigureAwait(false);
|
await Discord.BaseClient.SyncGuildIntegration(Guild.Id, Id).ConfigureAwait(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
public override string ToString() => $"{Name ?? Id.ToString()} ({(IsEnabled ? "Enabled" : "Disabled")})";
|
public override string ToString() => Name;
|
||||||
|
private string DebuggerDisplay => $"{Name} ({Id}{(IsEnabled ? ", Enabled" : "")})";
|
||||||
|
|
||||||
IGuild IGuildIntegration.Guild => Guild;
|
IGuild IGuildIntegration.Guild => Guild;
|
||||||
IRole IGuildIntegration.Role => Role;
|
IRole IGuildIntegration.Role => Role;
|
||||||
|
|||||||
@@ -2,11 +2,13 @@
|
|||||||
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 Message : IMessage
|
public class Message : IMessage
|
||||||
{
|
{
|
||||||
/// <inheritdoc />
|
/// <inheritdoc />
|
||||||
@@ -133,7 +135,8 @@ namespace Discord.WebSocket
|
|||||||
await Discord.BaseClient.DeleteMessage(Channel.Id, Id).ConfigureAwait(false);
|
await Discord.BaseClient.DeleteMessage(Channel.Id, Id).ConfigureAwait(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
public override string ToString() => $"{Author.ToString()}: {Text}";
|
public override string ToString() => Text;
|
||||||
|
private string DebuggerDisplay => $"{Author}: {Text}";
|
||||||
|
|
||||||
IUser IMessage.Author => Author;
|
IUser IMessage.Author => Author;
|
||||||
IReadOnlyList<Attachment> IMessage.Attachments => Attachments;
|
IReadOnlyList<Attachment> IMessage.Attachments => Attachments;
|
||||||
|
|||||||
@@ -1,12 +1,14 @@
|
|||||||
using Discord.API.Rest;
|
using Discord.API.Rest;
|
||||||
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.Role;
|
using Model = Discord.API.Role;
|
||||||
|
|
||||||
namespace Discord.WebSocket
|
namespace Discord.WebSocket
|
||||||
{
|
{
|
||||||
|
[DebuggerDisplay(@"{DebuggerDisplay,nq}")]
|
||||||
public class Role : IRole, IMentionable
|
public class Role : IRole, IMentionable
|
||||||
{
|
{
|
||||||
/// <inheritdoc />
|
/// <inheritdoc />
|
||||||
@@ -65,8 +67,9 @@ namespace Discord.WebSocket
|
|||||||
=> await Discord.BaseClient.DeleteGuildRole(Guild.Id, Id).ConfigureAwait(false);
|
=> await Discord.BaseClient.DeleteGuildRole(Guild.Id, Id).ConfigureAwait(false);
|
||||||
|
|
||||||
/// <inheritdoc />
|
/// <inheritdoc />
|
||||||
public override string ToString() => Name ?? Id.ToString();
|
public override string ToString() => Name;
|
||||||
|
private string DebuggerDisplay => $"{Name} ({Id})";
|
||||||
|
|
||||||
ulong IRole.GuildId => Guild.Id;
|
ulong IRole.GuildId => Guild.Id;
|
||||||
|
|
||||||
async Task<IEnumerable<IGuildUser>> IRole.GetUsers()
|
async Task<IEnumerable<IGuildUser>> IRole.GetUsers()
|
||||||
|
|||||||
@@ -1,10 +1,12 @@
|
|||||||
using Discord.API.Rest;
|
using Discord.API.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 abstract class User : IUser
|
public abstract class User : IUser
|
||||||
{
|
{
|
||||||
private string _avatarId;
|
private string _avatarId;
|
||||||
@@ -51,7 +53,8 @@ namespace Discord.WebSocket
|
|||||||
return new DMChannel(Discord, model);
|
return new DMChannel(Discord, model);
|
||||||
}
|
}
|
||||||
|
|
||||||
public override string ToString() => $"{Username ?? Id.ToString()}";
|
public override string ToString() => $"{Username}#{Discriminator}";
|
||||||
|
private string DebuggerDisplay => $"{Username}#{Discriminator} ({Id})";
|
||||||
|
|
||||||
/// <inheritdoc />
|
/// <inheritdoc />
|
||||||
Game? IUser.CurrentGame => null;
|
Game? IUser.CurrentGame => null;
|
||||||
|
|||||||
Reference in New Issue
Block a user