Browse Source

Added Server documentation

tags/docs-0.9
Brandon Smith 9 years ago
parent
commit
f90e41271a
1 changed files with 33 additions and 9 deletions
  1. +33
    -9
      src/Discord.Net/Server.cs

+ 33
- 9
src/Discord.Net/Server.cs View File

@@ -9,32 +9,56 @@ namespace Discord
{
private readonly DiscordClient _client;

/// <summary> Returns the unique identifier for this server. </summary>
public string Id { get; }
/// <summary> Returns the name of this channel. </summary>
public string Name { get; internal set; }

public string AFKChannelId { get; internal set; }
/// <summary> Returns the amount of time (in seconds) a user must be inactive for until they are automatically moved to the AFK channel (see AFKChannel). </summary>
public int AFKTimeout { get; internal set; }
/// <summary> Returns the date and time your joined this server. </summary>
public DateTime JoinedAt { get; internal set; }
/// <summary> Returns the region for this server (see Regions). </summary>
public string Region { get; internal set; }

/// <summary> Returns the id of the user that first created this server. </summary>
public string OwnerId { get; internal set; }
/// <summary> Returns the user that first created this server. </summary>
public User Owner => _client.GetUser(OwnerId);
/// <summary> Returns true if the current user created this server. </summary>
public bool IsOwner => _client.UserId == OwnerId;

/// <summary> Returns the id of the AFK voice channel for this server (see AFKTimeout). </summary>
public string AFKChannelId { get; internal set; }
/// <summary> Returns the AFK voice channel for this server (see AFKTimeout). </summary>
public Channel AFKChannel => _client.GetChannel(AFKChannelId);

/// <summary> Returns the id of the default channel for this server. </summary>
public string DefaultChannelId => Id;
/// <summary> Returns the default channel for this server. </summary>
public Channel DefaultChannel =>_client.GetChannel(DefaultChannelId);

internal ConcurrentDictionary<string, Membership> _members;
/// <summary> Returns a collection of all channels within this server. </summary>
public IEnumerable<Membership> Members => _members.Values;

internal ConcurrentDictionary<string, bool> _bans;
/// <summary> Returns a collection of all users banned on this server. </summary>
/// <remarks> Only users seen in other servers will be returned. To get a list of all users, use BanIds. </remarks>
public IEnumerable<User> Bans => _bans.Keys.Select(x => _client.GetUser(x));
/// <summary> Returns a collection of the ids of all users banned on this server. </summary>
public IEnumerable<string> BanIds => _bans.Keys;

/// <summary> Returns a collection of all channels within this server. </summary>
public IEnumerable<Channel> Channels => _client.Channels.Where(x => x.ServerId == Id);
/// <summary> Returns a collection of all roles within this server. </summary>
public IEnumerable<Role> Roles => _client.Roles.Where(x => x.ServerId == Id);

//Not Implemented
//TODO: Not Implemented
/// <summary> Not implemented, stored for reference. </summary>
public object Presence { get; internal set; }
//TODO: Not Implemented
/// <summary> Not implemented, stored for reference. </summary>
public object[] VoiceStates { get; internal set; }

internal Server(string id, DiscordClient client)
@@ -45,11 +69,6 @@ namespace Discord
_bans = new ConcurrentDictionary<string, bool>();
}

public override string ToString()
{
return Name;
}

internal void AddMember(Membership membership)
{
_members[membership.UserId] = membership;
@@ -78,5 +97,10 @@ namespace Discord
bool ignored;
return _bans.TryRemove(banId, out ignored);
}

public override string ToString()
{
return Name;
}
}
}

Loading…
Cancel
Save