Ref project update

This commit is contained in:
RogueException
2016-03-12 20:20:30 -04:00
parent 5a38129c18
commit 30ac95280e
31 changed files with 389 additions and 286 deletions

View File

@@ -7,16 +7,12 @@ namespace Discord
{
/// <summary> Gets the type flags for this channel. </summary>
ChannelType Type { get; }
/// <summary> Gets whether this is a text channel. </summary>
bool IsText { get; }
/// <summary> Gets whether this is a voice channel. </summary>
bool IsVoice { get; }
/// <summary> Gets whether this is a private channel. </summary>
bool IsPrivate { get; }
/// <summary> Gets whether this is a public channel. </summary>
bool IsPublic { get; }
/// <summary> Gets the name of this channel. </summary>
string Name { get; }
/// <summary> Gets a user in this channel with the given id. </summary>
Task<IUser> GetUser(ulong id);
/// <summary> Gets a collection of all users in this channel. </summary>
Task<IEnumerable<User>> GetUsers();
Task<IEnumerable<IUser>> GetUsers();
}
}

View File

@@ -1,8 +0,0 @@
namespace Discord
{
public interface IPrivateChannel : IChannel
{
/// <summary> Gets the recipient of the messages in this private channel. </summary>
User Recipient { get; }
}
}

View File

@@ -3,36 +3,33 @@ using System.Threading.Tasks;
namespace Discord
{
public struct PermissionOverwriteEntry
{
public PermissionTarget TargetType { get; }
public ulong TargetId { get; }
public OverwritePermissions Permissions { get; }
}
public interface IPublicChannel : IChannel
{
/// <summary> Gets the server this channel is a member of. </summary>
Server Server { get; }
/// <summary> Gets a collection of permission overwrites for this channel. </summary>
IEnumerable<PermissionOverwriteEntry> PermissionOverwrites { get; }
/// <summary> Gets the name of this public channel. </summary>
string Name { get; }
/// <summary> Gets the position of this public channel relative to others of the same type. </summary>
int Position { get; }
/// <summary> Gets a user in this channel with the given id. </summary>
new Task<ServerUser> GetUser(ulong id);
/// <summary> Gets a collection of all users in this channel. </summary>
new Task<IEnumerable<ServerUser>> GetUsers();
/// <summary> Gets the permission overwrite for a specific user, or null if one does not exist. </summary>
OverwritePermissions? GetPermissionOverwrite(User user);
OverwritePermissions? GetPermissionOverwrite(ServerUser user);
/// <summary> Gets the permission overwrite for a specific role, or null if one does not exist. </summary>
OverwritePermissions? GetPermissionOverwrite(Role role);
/// <summary> Downloads a collection of all invites to this server. </summary>
Task<IEnumerable<Invite>> GetInvites();
/// <summary> Adds or updates the permission overwrite for the given user. </summary>
Task UpdatePermissionOverwrite(User user, OverwritePermissions permissions);
Task UpdatePermissionOverwrite(ServerUser user, OverwritePermissions permissions);
/// <summary> Adds or updates the permission overwrite for the given role. </summary>
Task UpdatePermissionOverwrite(Role role, OverwritePermissions permissions);
/// <summary> Removes the permission overwrite for the given user, if one exists. </summary>
Task RemovePermissionOverwrite(User user);
Task RemovePermissionOverwrite(ServerUser user);
/// <summary> Removes the permission overwrite for the given role, if one exists. </summary>
Task RemovePermissionOverwrite(Role role);

View File

@@ -10,12 +10,12 @@ namespace Discord
Task<Message> GetMessage(ulong id);
/// <summary> Gets the last N messages from this text channel. </summary>
/// <param name="limit"> The maximum number of messages to retrieve. </param>
Task<IEnumerable<Message>> GetMessages(int limit = 100);
Task<IEnumerable<Message>> GetMessages(int limit = DiscordConfig.MaxMessagesPerBatch);
/// <summary> Gets a collection of messages in this channel. </summary>
/// <param name="limit"> The maximum number of messages to retrieve. </param>
/// <param name="relativeMessageId"> The message to start downloading relative to. </param>
/// <param name="relativeDir"> The direction, from relativeMessageId, to download messages in. </param>
Task<IEnumerable<Message>> GetMessages(int limit = 100, ulong? relativeMessageId = null, Relative relativeDir = Relative.Before);
Task<IEnumerable<Message>> GetMessages(int limit = DiscordConfig.MaxMessagesPerBatch, ulong? relativeMessageId = null, Relative relativeDir = Relative.Before);
/// <summary> Sends a message to this text channel. </summary>
Task<Message> SendMessage(string text, bool isTTS = false);

View File

@@ -1,8 +0,0 @@
namespace Discord
{
public interface IVoiceChannel : IChannel
{
/// <summary> Gets the requested bitrate, in bits per second, of this voice channel. </summary>
int Bitrate { get; }
}
}

View File

@@ -4,30 +4,32 @@ using System.Threading.Tasks;
namespace Discord
{
public class PrivateChannel : ITextChannel, IPrivateChannel
public class PrivateChannel : ITextChannel, IChannel
{
/// <inheritdoc />
public ulong Id { get; }
/// <inheritdoc />
public DiscordClient Discord { get; }
/// <inheritdoc />
public EntityState State { get; }
/// <inheritdoc />
public ChannelType Type { get; }
public ulong Id { get; }
/// <inheritdoc />
public bool IsPrivate => true;
public PrivateUser Recipient { get; }
/// <inheritdoc />
public bool IsPublic => false;
/// <inheritdoc />
public bool IsText => true;
/// <inheritdoc />
public bool IsVoice => false;
/// <inheritdoc />
public User Recipient { get; }
public PrivateUser CurrentUser { get; }
/// <inheritdoc />
public Task<IEnumerable<User>> GetUsers() => null;
ChannelType IChannel.Type => ChannelType.Private | ChannelType.Text;
/// <inheritdoc />
public string Name { get; }
/// <inheritdoc />
public Task<PrivateUser> GetUser(ulong id) => null;
/// <inheritdoc />
Task<IUser> IChannel.GetUser(ulong id) => null;
/// <inheritdoc />
public Task<IEnumerable<PrivateUser>> GetUsers() => null;
/// <inheritdoc />
Task<IEnumerable<IUser>> IChannel.GetUsers() => null;
/// <inheritdoc />
public Task<Message> GetMessage(ulong id) => null;
/// <inheritdoc />

View File

@@ -5,7 +5,7 @@ using System.Threading.Tasks;
namespace Discord
{
public class TextChannel : ITextChannel, IPublicChannel, IMentionable, IModifiable<TextChannel.Properties>
public class TextChannel : ITextChannel, IMentionable, IModifiable<TextChannel.Properties>
{
public sealed class Properties
{
@@ -14,22 +14,17 @@ namespace Discord
public int Position { get; }
}
/// <inheritdoc />
public EntityState State { get; }
/// <inheritdoc />
public ulong Id { get; }
/// <inheritdoc />
public Server Server { get; }
/// <inheritdoc />
public DiscordClient Discord { get; }
/// <inheritdoc />
public EntityState State { get; }
/// <inheritdoc />
public ChannelType Type => ChannelType.Public | ChannelType.Text;
/// <inheritdoc />
public bool IsPrivate => false;
/// <inheritdoc />
public bool IsPublic => true;
/// <inheritdoc />
public bool IsText => true;
/// <inheritdoc />
public bool IsVoice => false;
/// <inheritdoc />
public string Name { get; }
@@ -37,21 +32,24 @@ namespace Discord
public string Topic { get; }
/// <inheritdoc />
public int Position { get; }
/// <inheritdoc />
public string Mention { get; }
/// <inheritdoc />
public Server Server { get; }
/// <inheritdoc />
public IEnumerable<PermissionOverwriteEntry> PermissionOverwrites { get; }
/// <inheritdoc />
public IEnumerable<User> Users { get; }
/// <inheritdoc />
public OverwritePermissions? GetPermissionOverwrite(User user) => null;
public OverwritePermissions? GetPermissionOverwrite(ServerUser user) => null;
/// <inheritdoc />
public OverwritePermissions? GetPermissionOverwrite(Role role) => null;
/// <inheritdoc />
public Task<IEnumerable<User>> GetUsers() => null;
public Task<ServerUser> GetUser(ulong id) => null;
/// <inheritdoc />
Task<IUser> IChannel.GetUser(ulong id) => null;
/// <inheritdoc />
public Task<IEnumerable<ServerUser>> GetUsers() => null;
/// <inheritdoc />
Task<IEnumerable<IUser>> IChannel.GetUsers() => null;
/// <inheritdoc />
public Task<Message> GetMessage(ulong id) => null;
/// <inheritdoc />
@@ -62,11 +60,11 @@ namespace Discord
public Task<IEnumerable<Invite>> GetInvites() => null;
/// <inheritdoc />
public Task UpdatePermissionOverwrite(User user, OverwritePermissions permissions) => null;
public Task UpdatePermissionOverwrite(ServerUser user, OverwritePermissions permissions) => null;
/// <inheritdoc />
public Task UpdatePermissionOverwrite(Role role, OverwritePermissions permissions) => null;
/// <inheritdoc />
public Task RemovePermissionOverwrite(User user) => null;
public Task RemovePermissionOverwrite(ServerUser user) => null;
/// <inheritdoc />
public Task RemovePermissionOverwrite(Role role) => null;

View File

@@ -4,7 +4,7 @@ using System.Threading.Tasks;
namespace Discord
{
public class VoiceChannel : IPublicChannel, IVoiceChannel, IModifiable<VoiceChannel.Properties>
public class VoiceChannel : IPublicChannel, IModifiable<VoiceChannel.Properties>
{
public sealed class Properties
{
@@ -16,19 +16,14 @@ namespace Discord
/// <inheritdoc />
public ulong Id { get; }
/// <inheritdoc />
public DiscordClient Discord { get; }
/// <inheritdoc />
public EntityState State { get; }
/// <inheritdoc />
public ChannelType Type { get; }
public Server Server { get; }
/// <inheritdoc />
public bool IsPrivate => false;
public DiscordClient Discord { get; }
/// <inheritdoc />
public bool IsPublic => true;
/// <inheritdoc />
public bool IsText => false;
/// <inheritdoc />
public bool IsVoice => true;
ChannelType IChannel.Type => ChannelType.Public | ChannelType.Voice;
/// <inheritdoc />
public string Name { get; }
@@ -36,26 +31,33 @@ namespace Discord
public int Position { get; }
/// <inheritdoc />
public int Bitrate { get; }
/// <inheritdoc />
public Server Server { get; }
public string Mention { get; }
/// <inheritdoc />
public IEnumerable<PermissionOverwriteEntry> PermissionOverwrites { get; }
/// <inheritdoc />
public OverwritePermissions? GetPermissionOverwrite(User user) => null;
public OverwritePermissions? GetPermissionOverwrite(ServerUser user) => null;
/// <inheritdoc />
public OverwritePermissions? GetPermissionOverwrite(Role role) => null;
/// <inheritdoc />
public Task<IEnumerable<User>> GetUsers() => null;
public Task<ServerUser> GetUser(ulong id) => null;
/// <inheritdoc />
Task<IUser> IChannel.GetUser(ulong id) => null;
/// <inheritdoc />
public Task<IEnumerable<ServerUser>> GetUsers() => null;
/// <inheritdoc />
Task<IEnumerable<IUser>> IChannel.GetUsers() => null;
/// <inheritdoc />
public Task<IEnumerable<Invite>> GetInvites() => null;
/// <inheritdoc />
public Task UpdatePermissionOverwrite(User user, OverwritePermissions permissions) => null;
public Task UpdatePermissionOverwrite(ServerUser user, OverwritePermissions permissions) => null;
/// <inheritdoc />
public Task UpdatePermissionOverwrite(Role role, OverwritePermissions permissions) => null;
/// <inheritdoc />
public Task RemovePermissionOverwrite(User user) => null;
public Task RemovePermissionOverwrite(ServerUser user) => null;
/// <inheritdoc />
public Task RemovePermissionOverwrite(Role role) => null;

View File

@@ -1,5 +1,4 @@
using System;
using System.Threading.Tasks;
using System.Threading.Tasks;
namespace Discord
{

View File

@@ -1,49 +0,0 @@
using System;
using System.Threading.Tasks;
namespace Discord
{
public class Invite : IEntity<string>
{
public class ServerInfo
{
public ulong Id { get; }
public string Name { get; }
}
public class ChannelInfo
{
public ulong Id { get; }
public string Name { get; }
}
public class InviterInfo
{
public ulong Id { get; }
public string Name { get; }
public ushort Discriminator { get; }
public string AvatarId { get; }
public string AvatarUrl { get; }
}
string IEntity<string>.Id => Code;
public DiscordClient Discord { get; }
public EntityState State { get; }
public string Code { get; }
public string XkcdCode { get; }
public ServerInfo Server { get; }
public ChannelInfo Channel { get; }
public int? MaxAge { get; }
public int Uses { get; }
public int? MaxUses { get; }
public bool IsRevoked { get; }
public bool IsTemporary { get; }
public DateTime CreatedAt { get; }
public string Url { get; }
public Task Accept() => null;
public Task Update() => null;
public Task Delete() => null;
}
}

View File

@@ -0,0 +1,37 @@
using System.Threading.Tasks;
namespace Discord
{
public class BasicInvite : IEntity<string>
{
public class TargetInfo
{
public ulong Id { get; }
public string Name { get; }
}
public class InviterInfo
{
public ulong Id { get; }
public string Name { get; }
public ushort Discriminator { get; }
public string AvatarId { get; }
public string AvatarUrl { get; }
}
string IEntity<string>.Id => Code;
public DiscordClient Discord { get; }
public EntityState State { get; }
public string Code { get; }
public string XkcdCode { get; }
public TargetInfo Server { get; }
public TargetInfo Channel { get; }
public string Url { get; }
public Task Accept() => null;
public virtual Task Update() => null;
}
}

View File

@@ -0,0 +1,18 @@
using System;
using System.Threading.Tasks;
namespace Discord
{
public class Invite : BasicInvite
{
public int? MaxAge { get; }
public int Uses { get; }
public int? MaxUses { get; }
public bool IsRevoked { get; }
public bool IsTemporary { get; }
public DateTime CreatedAt { get; }
public override Task Update() => null;
public Task Delete() => null;
}
}

View File

@@ -44,7 +44,7 @@ namespace Discord
public EntityState State { get; }
public ITextChannel Channel { get; }
public User User { get; }
public IUser User { get; }
public bool IsTTS { get; }
public string RawText { get; }
public string Text { get; }
@@ -53,9 +53,9 @@ namespace Discord
public Attachment[] Attachments { get; }
public Embed[] Embeds { get; }
public IEnumerable<User> MentionedUsers { get; }
public IEnumerable<IPublicChannel> MentionedChannels { get; }
public IEnumerable<Role> MentionedRoles { get; }
public IReadOnlyList<ServerUser> MentionedUsers { get; }
public IReadOnlyList<IPublicChannel> MentionedChannels { get; }
public IReadOnlyList<Role> MentionedRoles { get; }
public Server Server => null;
public bool IsAuthor => false;

View File

@@ -0,0 +1,9 @@
namespace Discord
{
public struct PermissionOverwriteEntry
{
public PermissionTarget TargetType { get; }
public ulong TargetId { get; }
public OverwritePermissions Permissions { get; }
}
}

View File

@@ -19,7 +19,7 @@ namespace Discord
public Color Color { get; }
public bool IsEveryone { get; }
public IEnumerable<User> Members { get; }
public IEnumerable<ServerUser> Members { get; }
public string Mention { get; }

View File

@@ -19,7 +19,7 @@ namespace Discord
public DiscordClient Discord { get; }
public EntityState State { get; }
public User CurrentUser { get; }
public ServerUser CurrentUser { get; }
public string IconId { get; }
public string SplashId { get; }
public string IconUrl { get; }
@@ -34,24 +34,24 @@ namespace Discord
public IEnumerable<IChannel> Channels { get; }
public IEnumerable<TextChannel> TextChannels { get; }
public IEnumerable<VoiceChannel> VoiceChannels { get; }
public IEnumerable<User> Users { get; }
public IEnumerable<ServerUser> Users { get; }
public IEnumerable<Role> Roles { get; }
public string Name { get; set; }
public Region Region { get; set; }
public int AFKTimeout { get; set; }
public DateTime JoinedAt { get; set; }
public User Owner { get; set; }
public ServerUser Owner { get; set; }
public VoiceChannel AFKChannel { get; set; }
public IPublicChannel GetChannel(ulong id) => null;
public IPublicChannel GetChannel(string mention) => null;
public Role GetRole(ulong id) => null;
public User GetUser(ulong id) => null;
public User GetUser(string name, ushort discriminator) => null;
public User GetUser(string mention) => null;
public Task<IEnumerable<User>> DownloadBans() => null;
public Task<IEnumerable<Invite>> DownloadInvites() => null;
public Task<IPublicChannel> GetChannel(ulong id) => null;
public Task<IPublicChannel> GetChannel(string mention) => null;
public Task<Role> GetRole(ulong id) => null;
public Task<ServerUser> GetUser(ulong id) => null;
public Task<ServerUser> GetUser(string name, ushort discriminator) => null;
public Task<ServerUser> GetUser(string mention) => null;
public Task<IEnumerable<ServerUser>> GetBans() => null;
public Task<IEnumerable<Invite>> GetInvites() => null;
public Task<TextChannel> CreateTextChannel(string name) => null;
public Task<VoiceChannel> CreateVoiceChannel(string name) => null;

View File

@@ -1,55 +0,0 @@
using System;
using System.Collections.Generic;
using System.IO;
using System.Threading.Tasks;
namespace Discord
{
public class User : IEntity<ulong>
{
public ulong Id { get; }
public DiscordClient Discord { get; }
public EntityState State { get; }
public Server Server { get; }
public string Name { get; }
public ushort Discriminator { get; }
public string AvatarId { get; }
public string CurrentGame { get; }
public UserStatus Status { get; }
public DateTime JoinedAt { get; }
public DateTime? LastActivityAt { get; }
public string Mention => null;
public bool IsSelfMuted => false;
public bool IsSelfDeafened => false;
public bool IsServerMuted => false;
public bool IsServerDeafened => false;
public bool IsServerSuppressed => false;
public DateTime? LastOnlineAt => null;
public VoiceChannel VoiceChannel => null;
public string AvatarUrl => null;
public IEnumerable<Role> Roles => null;
public IEnumerable<IPublicChannel> Channels => null;
public ServerPermissions ServerPermissions => default(ServerPermissions);
public ChannelPermissions GetPermissions(IPublicChannel channel) => default(ChannelPermissions);
public Task<PrivateChannel> GetPrivateChannel() => null;
public Task<Message> SendMessage(string text) => null;
public Task<Message> SendFile(string filePath) => null;
public Task<Message> SendFile(string filename, Stream stream) => null;
public bool HasRole(Role role) => false;
public Task AddRoles(params Role[] roles) => null;
public Task RemoveRoles(params Role[] roles) => null;
public Task Update() => null;
public Task Kick() => null;
public Task Ban(User user, int pruneDays = 0) => null;
public Task Unban(User user) => null;
public Task Unban(ulong userId) => null;
}
}

View File

@@ -0,0 +1,19 @@
using System.Threading.Tasks;
namespace Discord
{
public interface IUser : IEntity<ulong>, IMentionable
{
bool IsPrivate { get; }
string Name { get; }
ushort Discriminator { get; }
bool IsBot { get; }
string AvatarId { get; }
string AvatarUrl { get; }
string CurrentGame { get; }
UserStatus Status { get; }
Task<PrivateChannel> GetPrivateChannel();
}
}

View File

@@ -0,0 +1,43 @@
using System.Threading.Tasks;
namespace Discord
{
//TODO: Should this be linked directly to the Profile when it represents us, instead of maintaining a cache of values?
public class PrivateUser : IUser
{
/// <inheritdoc />
public EntityState State { get; internal set; }
/// <inheritdoc />
public ulong Id { get; }
/// <summary> Returns the private channel for this user. </summary>
public PrivateChannel Channel { get; }
/// <inheritdoc />
bool IUser.IsPrivate => true;
/// <inheritdoc />
public string Name { get; }
/// <inheritdoc />
public ushort Discriminator { get; }
/// <inheritdoc />
public bool IsBot { get; }
/// <inheritdoc />
public string AvatarId { get; }
/// <inheritdoc />
public string CurrentGame { get; }
/// <inheritdoc />
public UserStatus Status { get; }
/// <inheritdoc />
public DiscordClient Discord => Channel.Discord;
/// <inheritdoc />
public string AvatarUrl { get; }
/// <inheritdoc />
public string Mention { get; }
/// <inheritdoc />
Task<PrivateChannel> IUser.GetPrivateChannel() => Task.FromResult(Channel);
public Task Update() => null;
}
}

View File

@@ -0,0 +1,73 @@
using System;
using System.Collections.Generic;
using System.Threading.Tasks;
namespace Discord
{
public class ServerUser : IUser
{
/// <inheritdoc />
public EntityState State { get; }
/// <inheritdoc />
public ulong Id { get; }
/// <summary> Returns the private channel for this user. </summary>
public Server Server { get; }
/// <inheritdoc />
bool IUser.IsPrivate => false;
/// <inheritdoc />
public string Name { get; }
/// <inheritdoc />
public ushort Discriminator { get; }
/// <inheritdoc />
public bool IsBot { get; }
/// <inheritdoc />
public string AvatarId { get; }
/// <inheritdoc />
public string CurrentGame { get; }
/// <inheritdoc />
public UserStatus Status { get; }
/// <inheritdoc />
public DateTime JoinedAt { get; }
/// <inheritdoc />
public IReadOnlyList<Role> Roles { get; }
/// <summary> Returns true if this user has marked themselves as muted. </summary>
public bool IsSelfMuted { get; }
/// <summary> Returns true if this user has marked themselves as deafened. </summary>
public bool IsSelfDeafened { get; }
/// <summary> Returns true if the server is blocking audio from this user. </summary>
public bool IsServerMuted { get; }
/// <summary> Returns true if the server is blocking audio to this user. </summary>
public bool IsServerDeafened { get; }
/// <summary> Returns true if the server is temporarily blocking audio to/from this user. </summary>
public bool IsServerSuppressed { get; }
/// <summary> Gets this user's current voice channel. </summary>
public VoiceChannel VoiceChannel { get; }
/// <inheritdoc />
public DiscordClient Discord { get; }
/// <inheritdoc />
public string AvatarUrl { get; }
/// <inheritdoc />
public string Mention { get; }
public ServerPermissions ServerPermissions { get; }
public ChannelPermissions GetPermissions(IPublicChannel channel) => default(ChannelPermissions);
/// <inheritdoc />
public Task<PrivateChannel> GetPrivateChannel() => null;
public Task<IEnumerable<IPublicChannel>> GetChannels() => null;
public bool HasRole(Role role) => false;
public Task AddRoles(params Role[] roles) => null;
public Task RemoveRoles(params Role[] roles) => null;
public Task Update() => null;
public Task Kick() => null;
public Task Ban(int pruneDays = 0) => null;
public Task Unban() => null;
}
}