| @@ -9,7 +9,7 @@ namespace Discord.WebSocket | |||||
| [DebuggerDisplay(@"{DebuggerDisplay,nq}")] | [DebuggerDisplay(@"{DebuggerDisplay,nq}")] | ||||
| public class SocketInvite : SocketEntity<string>, IInviteMetadata | public class SocketInvite : SocketEntity<string>, IInviteMetadata | ||||
| { | { | ||||
| private long _createdAtTicks; | |||||
| private long _createdAtTicks; | |||||
| /// <inheritdoc /> | /// <inheritdoc /> | ||||
| public ulong ChannelId { get; private set; } | public ulong ChannelId { get; private set; } | ||||
| @@ -24,11 +24,26 @@ namespace Discord.WebSocket | |||||
| /// </summary> | /// </summary> | ||||
| public SocketGuild Guild { get; private set; } | public SocketGuild Guild { get; private set; } | ||||
| /// <inheritdoc /> | /// <inheritdoc /> | ||||
| ChannelType IInvite.ChannelType => throw new NotImplementedException(); | |||||
| ChannelType IInvite.ChannelType | |||||
| { | |||||
| get | |||||
| { | |||||
| switch (Channel) | |||||
| { | |||||
| case IVoiceChannel voiceChannel: return ChannelType.Voice; | |||||
| case ICategoryChannel categoryChannel: return ChannelType.Category; | |||||
| case IDMChannel dmChannel: return ChannelType.DM; | |||||
| case IGroupChannel groupChannel: return ChannelType.Group; | |||||
| case SocketNewsChannel socketNewsChannel: return ChannelType.News; | |||||
| case ITextChannel textChannel: return ChannelType.Text; | |||||
| default: throw new InvalidOperationException("Invalid channel type."); | |||||
| } | |||||
| } | |||||
| } | |||||
| /// <inheritdoc /> | /// <inheritdoc /> | ||||
| string IInvite.ChannelName => throw new NotImplementedException(); | |||||
| string IInvite.ChannelName => Channel.Name; | |||||
| /// <inheritdoc /> | /// <inheritdoc /> | ||||
| string IInvite.GuildName => throw new NotImplementedException(); | |||||
| string IInvite.GuildName => Guild.Name; | |||||
| /// <inheritdoc /> | /// <inheritdoc /> | ||||
| int? IInvite.PresenceCount => throw new NotImplementedException(); | int? IInvite.PresenceCount => throw new NotImplementedException(); | ||||
| /// <inheritdoc /> | /// <inheritdoc /> | ||||
| @@ -109,28 +124,9 @@ namespace Discord.WebSocket | |||||
| private string DebuggerDisplay => $"{Url} ({Guild?.Name} / {Channel.Name})"; | private string DebuggerDisplay => $"{Url} ({Guild?.Name} / {Channel.Name})"; | ||||
| /// <inheritdoc /> | /// <inheritdoc /> | ||||
| IGuild IInvite.Guild | |||||
| { | |||||
| get | |||||
| { | |||||
| if (Guild != null) | |||||
| return Guild; | |||||
| if (Channel is IGuildChannel guildChannel) | |||||
| return guildChannel.Guild; //If it fails, it'll still return this exception | |||||
| throw new InvalidOperationException("Unable to return this entity's parent unless it was fetched through that object."); | |||||
| } | |||||
| } | |||||
| IGuild IInvite.Guild => Guild; | |||||
| /// <inheritdoc /> | /// <inheritdoc /> | ||||
| IChannel IInvite.Channel | |||||
| { | |||||
| get | |||||
| { | |||||
| if (Channel != null) | |||||
| return Channel; | |||||
| throw new InvalidOperationException("Unable to return this entity's parent unless it was fetched through that object."); | |||||
| } | |||||
| } | |||||
| IChannel IInvite.Channel => Channel; | |||||
| /// <inheritdoc /> | /// <inheritdoc /> | ||||
| IUser IInviteMetadata.Inviter => Inviter; | IUser IInviteMetadata.Inviter => Inviter; | ||||
| } | } | ||||