Removed references from Invite.
This commit is contained in:
@@ -6,6 +6,61 @@ namespace Discord
|
|||||||
{
|
{
|
||||||
public sealed class Invite : CachedObject
|
public sealed class Invite : CachedObject
|
||||||
{
|
{
|
||||||
|
public sealed class ServerInfo
|
||||||
|
{
|
||||||
|
/// <summary> Returns the unique identifier of this server. </summary>
|
||||||
|
public string Id { get; }
|
||||||
|
/// <summary> Returns the name of this server. </summary>
|
||||||
|
public string Name { get; }
|
||||||
|
|
||||||
|
internal ServerInfo(string id, string name)
|
||||||
|
{
|
||||||
|
Id = id;
|
||||||
|
Name = name;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
public sealed class ChannelInfo
|
||||||
|
{
|
||||||
|
/// <summary> Returns the unique identifier of this channel. </summary>
|
||||||
|
public string Id { get; }
|
||||||
|
/// <summary> Returns the name of this channel. </summary>
|
||||||
|
public string Name { get; }
|
||||||
|
|
||||||
|
internal ChannelInfo(string id, string name)
|
||||||
|
{
|
||||||
|
Id = id;
|
||||||
|
Name = name;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
public sealed class InviterInfo
|
||||||
|
{
|
||||||
|
/// <summary> Returns the unique identifier for this user. </summary>
|
||||||
|
public string Id { get; }
|
||||||
|
/// <summary> Returns the name of this user. </summary>
|
||||||
|
public string Name { get; }
|
||||||
|
/// <summary> Returns the by-name unique identifier for this user. </summary>
|
||||||
|
public string Discriminator { get; }
|
||||||
|
/// <summary> Returns the unique identifier for this user's avatar. </summary>
|
||||||
|
public string AvatarId { get; }
|
||||||
|
/// <summary> Returns the full path to this user's avatar. </summary>
|
||||||
|
public string AvatarUrl => User.GetAvatarUrl(Id, AvatarId);
|
||||||
|
|
||||||
|
internal InviterInfo(string id, string name, string discriminator, string avatarId)
|
||||||
|
{
|
||||||
|
Id = id;
|
||||||
|
Name = name;
|
||||||
|
Discriminator = discriminator;
|
||||||
|
AvatarId = avatarId;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary> Returns information about the server this invite is attached to. </summary>
|
||||||
|
public ServerInfo Server { get; private set; }
|
||||||
|
/// <summary> Returns information about the channel this invite is attached to. </summary>
|
||||||
|
public ChannelInfo Channel { get; private set; }
|
||||||
|
/// <summary> Returns information about the user that created this invite. </summary>
|
||||||
|
public InviterInfo Inviter { get; private set; }
|
||||||
|
|
||||||
/// <summary> Returns, if enabled, an alternative human-readable code for URLs. </summary>
|
/// <summary> Returns, if enabled, an alternative human-readable code for URLs. </summary>
|
||||||
public string XkcdCode { get; }
|
public string XkcdCode { get; }
|
||||||
/// <summary> Time (in seconds) until the invite expires. Set to 0 to never expire. </summary>
|
/// <summary> Time (in seconds) until the invite expires. Set to 0 to never expire. </summary>
|
||||||
@@ -23,76 +78,22 @@ namespace Discord
|
|||||||
/// <summary> Returns a URL for this invite using XkcdCode if available or Id if not. </summary>
|
/// <summary> Returns a URL for this invite using XkcdCode if available or Id if not. </summary>
|
||||||
public string Url => API.Endpoints.InviteUrl(XkcdCode ?? Id);
|
public string Url => API.Endpoints.InviteUrl(XkcdCode ?? Id);
|
||||||
|
|
||||||
/// <summary> Returns the user that created this invite. </summary>
|
|
||||||
[JsonIgnore]
|
|
||||||
public User Inviter => _inviter.Value;
|
|
||||||
private readonly Reference<User> _inviter;
|
|
||||||
private User _generatedInviter;
|
|
||||||
|
|
||||||
/// <summary> Returns the server this invite is to. </summary>
|
|
||||||
[JsonIgnore]
|
|
||||||
public Server Server => _server.Value;
|
|
||||||
private readonly Reference<Server> _server;
|
|
||||||
private Server _generatedServer;
|
|
||||||
|
|
||||||
/// <summary> Returns the channel this invite is to. </summary>
|
|
||||||
[JsonIgnore]
|
|
||||||
public Channel Channel => _channel.Value;
|
|
||||||
private readonly Reference<Channel> _channel;
|
|
||||||
private Channel _generatedChannel;
|
|
||||||
|
|
||||||
internal Invite(DiscordClient client, string code, string xkcdPass, string serverId, string inviterId, string channelId)
|
internal Invite(DiscordClient client, string code, string xkcdPass, string serverId, string inviterId, string channelId)
|
||||||
: base(client, code)
|
: base(client, code)
|
||||||
{
|
{
|
||||||
XkcdCode = xkcdPass;
|
XkcdCode = xkcdPass;
|
||||||
_server = new Reference<Server>(serverId, x =>
|
|
||||||
{
|
|
||||||
var server = _client.Servers[x];
|
|
||||||
if (server == null)
|
|
||||||
{
|
|
||||||
server = _generatedServer = new Server(client, x);
|
|
||||||
//server.Cache();
|
|
||||||
}
|
|
||||||
return server;
|
|
||||||
});
|
|
||||||
_inviter = new Reference<User>(serverId, x =>
|
|
||||||
{
|
|
||||||
var inviter = _client.Users[x, _server.Id];
|
|
||||||
if (inviter == null)
|
|
||||||
{
|
|
||||||
inviter = _generatedInviter = new User(client, x, _server.Id);
|
|
||||||
//inviter.Cache();
|
|
||||||
}
|
|
||||||
return inviter;
|
|
||||||
});
|
|
||||||
_channel = new Reference<Channel>(serverId, x =>
|
|
||||||
{
|
|
||||||
var channel = _client.Channels[x];
|
|
||||||
if (channel == null)
|
|
||||||
{
|
|
||||||
channel = _generatedChannel = new Channel(client, x, _server.Id, null);
|
|
||||||
//channel.Cache();
|
|
||||||
}
|
|
||||||
return channel;
|
|
||||||
});
|
|
||||||
}
|
|
||||||
internal override void LoadReferences()
|
|
||||||
{
|
|
||||||
_server.Load();
|
|
||||||
_inviter.Load();
|
|
||||||
_channel.Load();
|
|
||||||
}
|
}
|
||||||
|
internal override void LoadReferences() { }
|
||||||
internal override void UnloadReferences() { }
|
internal override void UnloadReferences() { }
|
||||||
|
|
||||||
|
|
||||||
internal void Update(InviteReference model)
|
internal void Update(InviteReference model)
|
||||||
{
|
{
|
||||||
if (model.Guild != null && _generatedServer != null)
|
if (model.Guild != null)
|
||||||
_generatedServer.Update(model.Guild);
|
Server = new ServerInfo(model.Guild.Id, model.Guild.Name);
|
||||||
if (model.Inviter != null && _generatedInviter != null)
|
if (model.Channel != null)
|
||||||
_generatedInviter.Update(model.Inviter);
|
Channel = new ChannelInfo(model.Channel.Id, model.Channel.Name);
|
||||||
if (model.Channel != null && _generatedChannel != null)
|
if (model.Inviter != null)
|
||||||
_generatedChannel.Update(model.Channel);
|
Inviter = new InviterInfo(model.Inviter.Id, model.Inviter.Username, model.Inviter.Discriminator, model.Inviter.Avatar);
|
||||||
}
|
}
|
||||||
internal void Update(InviteInfo model)
|
internal void Update(InviteInfo model)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -10,6 +10,7 @@ namespace Discord
|
|||||||
public class User : CachedObject
|
public class User : CachedObject
|
||||||
{
|
{
|
||||||
internal static string GetId(string userId, string serverId) => (serverId ?? "Private") + '_' + userId;
|
internal static string GetId(string userId, string serverId) => (serverId ?? "Private") + '_' + userId;
|
||||||
|
internal static string GetAvatarUrl(string userId, string avatarId) => avatarId != null ? Endpoints.UserAvatar(userId, avatarId) : null;
|
||||||
|
|
||||||
private ConcurrentDictionary<string, Channel> _channels;
|
private ConcurrentDictionary<string, Channel> _channels;
|
||||||
private ConcurrentDictionary<string, ChannelPermissions> _permissions;
|
private ConcurrentDictionary<string, ChannelPermissions> _permissions;
|
||||||
@@ -24,7 +25,7 @@ namespace Discord
|
|||||||
/// <summary> Returns the unique identifier for this user's current avatar. </summary>
|
/// <summary> Returns the unique identifier for this user's current avatar. </summary>
|
||||||
public string AvatarId { get; private set; }
|
public string AvatarId { get; private set; }
|
||||||
/// <summary> Returns the URL to this user's current avatar. </summary>
|
/// <summary> Returns the URL to this user's current avatar. </summary>
|
||||||
public string AvatarUrl => AvatarId != null ? API.Endpoints.UserAvatar(Id, AvatarId) : null;
|
public string AvatarUrl => GetAvatarUrl(Id, AvatarId);
|
||||||
/// <summary> Returns the datetime that this user joined this server. </summary>
|
/// <summary> Returns the datetime that this user joined this server. </summary>
|
||||||
public DateTime JoinedAt { get; private set; }
|
public DateTime JoinedAt { get; private set; }
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user