Browse Source

Added Invite documentation

tags/docs-0.9
Brandon Smith 9 years ago
parent
commit
67f9296c07
2 changed files with 25 additions and 6 deletions
  1. +1
    -1
      src/Discord.Net/DiscordClient.cs
  2. +24
    -5
      src/Discord.Net/Invite.cs

+ 1
- 1
src/Discord.Net/DiscordClient.cs View File

@@ -811,7 +811,7 @@ namespace Discord
public Task AcceptInvite(Invite invite)
{
CheckReady();
return DiscordAPI.AcceptInvite(invite.Code);
return DiscordAPI.AcceptInvite(invite.Id);
}
/// <summary> Accepts the provided invite. </summary>
public async Task AcceptInvite(string id)


+ 24
- 5
src/Discord.Net/Invite.cs View File

@@ -6,27 +6,46 @@ namespace Discord
{
private readonly DiscordClient _client;

public int MaxAge, Uses, MaxUses;
public bool IsRevoked, IsTemporary;
public readonly string Code, XkcdPass;
/// <summary> Returns the unique identifier for this invite. </summary>
public string Id { get; }
/// <summary> Time (in seconds) until the invite expires. Set to 0 to never expire. </summary>
public int MaxAge { get; internal set; }
/// <summary> The amount of times this invite has been used. </summary>
public int Uses { get; internal set; }
/// <summary> The max amount of times this invite may be used. </summary>
public int MaxUses { get; internal set; }
/// <summary> Returns true if this invite has been destroyed, or you are banned from that server. </summary>
public bool IsRevoked { get; internal set; }
/// <summary> If true, a user accepting this invite will be kicked from the server after closing their client. </summary>
public bool IsTemporary { get; internal set; }
/// <summary> Returns, if enabled, an alternative human-readable code for URLs. </summary>
public string XkcdPass { get; }

public string Url => API.Endpoints.InviteUrl(XkcdPass ?? Code);
/// <summary> Returns a URL for this invite using XkcdPass if available or Id if not. </summary>
public string Url => API.Endpoints.InviteUrl(XkcdPass ?? Id);

/// <summary> Returns the id of the user that created this invite. </summary>
public string InviterId { get; internal set; }
/// <summary> Returns the user that created this invite. </summary>
[JsonIgnore]
public User Inviter => _client.GetUser(InviterId);

/// <summary> Returns the id of the server this invite is to. </summary>
public string ServerId { get; internal set; }
/// <summary> Returns the server this invite is to. </summary>
[JsonIgnore]
public Server Server => _client.GetServer(ServerId);

/// <summary> Returns the id of the channel this invite is to. </summary>
public string ChannelId { get; internal set; }
/// <summary> Returns the channel this invite is to. </summary>
[JsonIgnore]
public Channel Channel => _client.GetChannel(ChannelId);

internal Invite(string code, string xkcdPass, DiscordClient client)
{
Code = code;
Id = code;
XkcdPass = xkcdPass;
_client = client;
}


Loading…
Cancel
Save