Browse Source

Updated reference channel entities

pull/40/head
RogueException 9 years ago
parent
commit
0759f957d8
23 changed files with 298 additions and 162 deletions
  1. +1
    -1
      ref/DiscordClient.Events.cs
  2. +3
    -3
      ref/DiscordClient.cs
  3. +0
    -22
      ref/Entities/Channels/Channel.cs
  4. +10
    -5
      ref/Entities/Channels/IChannel.cs
  5. +1
    -0
      ref/Entities/Channels/IPrivateChannel.cs
  6. +30
    -16
      ref/Entities/Channels/IPublicChannel.cs
  7. +14
    -2
      ref/Entities/Channels/ITextChannel.cs
  8. +2
    -1
      ref/Entities/Channels/IVoiceChannel.cs
  9. +41
    -17
      ref/Entities/Channels/PrivateChannel.cs
  10. +74
    -30
      ref/Entities/Channels/TextChannel.cs
  11. +57
    -32
      ref/Entities/Channels/VoiceChannel.cs
  12. +23
    -0
      ref/Entities/IEntity.cs
  13. +0
    -13
      ref/Entities/IModel.cs
  14. +11
    -0
      ref/Entities/IModifiable.cs
  15. +1
    -1
      ref/Entities/Message.cs
  16. +1
    -1
      ref/Entities/Profile.cs
  17. +1
    -1
      ref/Entities/Role.cs
  18. +2
    -2
      ref/Entities/Server.cs
  19. +9
    -4
      ref/Enums/ChannelType.cs
  20. +1
    -1
      ref/Enums/ModelState.cs
  21. +2
    -2
      ref/Events/ChannelUpdatedEventArgs.cs
  22. +0
    -8
      ref/Events/ChannelUserEventArgs.cs
  23. +14
    -0
      ref/Events/TypingEventArgs.cs

+ 1
- 1
ref/DiscordClient.Events.cs View File

@@ -23,7 +23,7 @@ namespace Discord
public event EventHandler<ServerUpdatedEventArgs> ServerUpdated = delegate { }; public event EventHandler<ServerUpdatedEventArgs> ServerUpdated = delegate { };
public event EventHandler<ServerEventArgs> ServerUnavailable = delegate { }; public event EventHandler<ServerEventArgs> ServerUnavailable = delegate { };
public event EventHandler<UserEventArgs> UserBanned = delegate { }; public event EventHandler<UserEventArgs> UserBanned = delegate { };
public event EventHandler<ChannelUserEventArgs> UserIsTyping = delegate { };
public event EventHandler<TypingEventArgs> UserIsTyping = delegate { };
public event EventHandler<UserEventArgs> UserJoined = delegate { }; public event EventHandler<UserEventArgs> UserJoined = delegate { };
public event EventHandler<UserEventArgs> UserLeft = delegate { }; public event EventHandler<UserEventArgs> UserLeft = delegate { };
public event EventHandler<UserUpdatedEventArgs> UserUpdated = delegate { }; public event EventHandler<UserUpdatedEventArgs> UserUpdated = delegate { };


+ 3
- 3
ref/DiscordClient.cs View File

@@ -29,7 +29,7 @@ namespace Discord
public string CurrentGame { get; } public string CurrentGame { get; }
public IEnumerable<Server> Servers { get; } public IEnumerable<Server> Servers { get; }
public IEnumerable<Channel> PrivateChannels { get; }
public IEnumerable<PrivateChannel> PrivateChannels { get; }
public IEnumerable<Region> Regions { get; } public IEnumerable<Region> Regions { get; }


public DiscordClient() { } public DiscordClient() { }
@@ -43,8 +43,8 @@ namespace Discord
public void SetStatus(UserStatus status) { } public void SetStatus(UserStatus status) { }
public void SetGame(string game) { } public void SetGame(string game) { }


public Channel GetChannel(ulong id) => null;
public Task<Channel> CreatePrivateChannel(ulong userId) => null;
public PrivateChannel GetPrivateChannel(ulong id) => null;
public Task<PrivateChannel> CreatePrivateChannel(ulong userId) => null;


public Task<Invite> GetInvite(string inviteIdOrXkcd) => null; public Task<Invite> GetInvite(string inviteIdOrXkcd) => null;




+ 0
- 22
ref/Entities/Channels/Channel.cs View File

@@ -1,22 +0,0 @@
using System.Collections.Generic;
using System.Threading.Tasks;

namespace Discord
{
public abstract class Channel : IChannel
{
public ulong Id { get; }

public abstract DiscordClient Client { get; }
public abstract ChannelType Type { get; }
public bool IsText { get; }
public bool IsVoice { get; }
public bool IsPrivate { get; }
public bool IsPublic { get; }

public abstract User CurrentUser { get; }
public abstract IEnumerable<User> Users { get; }

public abstract Task Save();
}
}

+ 10
- 5
ref/Entities/Channels/IChannel.cs View File

@@ -1,17 +1,22 @@
using System.Collections.Generic; using System.Collections.Generic;
using System.Threading.Tasks;


namespace Discord namespace Discord
{ {
public interface IChannel : IModel<ulong>
public interface IChannel : IEntity<ulong>
{ {
DiscordClient Client { get; }
/// <summary> Gets the type flags for this channel. </summary>
ChannelType Type { get; } ChannelType Type { get; }
/// <summary> Gets whether this is a text channel. </summary>
bool IsText { get; } bool IsText { get; }
/// <summary> Gets whether this is a voice channel. </summary>
bool IsVoice { get; } bool IsVoice { get; }
/// <summary> Gets whether this is a private channel. </summary>
bool IsPrivate { get; } bool IsPrivate { get; }
/// <summary> Gets whether this is a public channel. </summary>
bool IsPublic { get; } bool IsPublic { get; }
IEnumerable<User> Users { get; }

/// <summary> Gets a collection of all users in this channel. </summary>
Task<IEnumerable<User>> GetUsers();
} }
} }

+ 1
- 0
ref/Entities/Channels/IPrivateChannel.cs View File

@@ -2,6 +2,7 @@
{ {
public interface IPrivateChannel : IChannel public interface IPrivateChannel : IChannel
{ {
/// <summary> Gets the recipient of the messages in this private channel. </summary>
User Recipient { get; } User Recipient { get; }
} }
} }

+ 30
- 16
ref/Entities/Channels/IPublicChannel.cs View File

@@ -5,26 +5,40 @@ namespace Discord
{ {
public interface IPublicChannel : IChannel public interface IPublicChannel : IChannel
{ {
/// <summary> Gets the server this channel is a member of. </summary>
Server Server { get; } Server Server { get; }

string Name { get; set; }
int Position { get; set; }
/// <summary> Gets a collection of permission overwrites for this channel. </summary>
IEnumerable<PermissionOverwrite> PermissionOverwrites { get; } IEnumerable<PermissionOverwrite> 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; }


PermissionOverwrite? GetPermissionsRule(User user);
PermissionOverwrite? GetPermissionsRule(Role role);
Task<IEnumerable<Invite>> DownloadInvites();

Task Delete();
/// <summary> Gets the permission overwrite for a specific user, or null if one does not exist. </summary>
Task<PermissionOverwrite?> GetPermissionOverwrite(User user);
/// <summary> Gets the permission overwrite for a specific role, or null if one does not exist. </summary>
Task<PermissionOverwrite?> 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, ChannelPermissions allow, ChannelPermissions deny);
/// <summary> Adds or updates the permission overwrite for the given user. </summary>
Task UpdatePermissionOverwrite(User user, TriStateChannelPermissions permissions);
/// <summary> Adds or updates the permission overwrite for the given role. </summary>
Task UpdatePermissionOverwrite(Role role, ChannelPermissions allow, ChannelPermissions deny);
/// <summary> Adds or updates the permission overwrite for the given role. </summary>
Task UpdatePermissionOverwrite(Role role, TriStateChannelPermissions permissions);
/// <summary> Removes the permission overwrite for the given user, if one exists. </summary>
Task RemovePermissionOverwrite(User user);
/// <summary> Removes the permission overwrite for the given role, if one exists. </summary>
Task RemovePermissionOverwrite(Role role);


/// <summary> Creates a new invite to this channel. </summary>
/// <param name="maxAge"> Time (in seconds) until the invite expires. Set to null to never expire. </param>
/// <param name="maxUses"> The max amount of times this invite may be used. Set to null to have unlimited uses. </param>
/// <param name="tempMembership"> If true, a user accepting this invite will be kicked from the server after closing their client. </param>
/// <param name="withXkcd"> If true, creates a human-readable link. Not supported if maxAge is set to null. </param>
Task<Invite> CreateInvite(int? maxAge = 1800, int? maxUses = null, bool tempMembership = false, bool withXkcd = false); Task<Invite> CreateInvite(int? maxAge = 1800, int? maxUses = null, bool tempMembership = false, bool withXkcd = false);

Task AddPermissionsRule(User user, ChannelPermissions allow, ChannelPermissions deny);
Task AddPermissionsRule(User user, TriStateChannelPermissions permissions);
Task AddPermissionsRule(Role role, ChannelPermissions allow, ChannelPermissions deny);
Task AddPermissionsRule(Role role, TriStateChannelPermissions permissions);
Task RemovePermissionsRule(User user);
Task RemovePermissionsRule(Role role);
} }
} }

+ 14
- 2
ref/Entities/Channels/ITextChannel.cs View File

@@ -6,13 +6,25 @@ namespace Discord
{ {
public interface ITextChannel : IChannel public interface ITextChannel : IChannel
{ {
Message GetMessage(ulong id);
Task<IEnumerable<Message>> DownloadMessages(int limit = 100, ulong? relativeMessageId = null, Relative relativeDir = Relative.Before);
/// <summary> Gets the message in this text channel with the given id, or null if none was found. </summary>
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);
/// <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);


/// <summary> Sends a message to this text channel. </summary>
Task<Message> SendMessage(string text, bool isTTS = false); Task<Message> SendMessage(string text, bool isTTS = false);
/// <summary> Sends a file to this text channel, with an optional caption. </summary>
Task<Message> SendFile(string filePath, string text = null, bool isTTS = false); Task<Message> SendFile(string filePath, string text = null, bool isTTS = false);
/// <summary> Sends a file to this text channel, with an optional caption. </summary>
Task<Message> SendFile(Stream stream, string filename, string text = null, bool isTTS = false); Task<Message> SendFile(Stream stream, string filename, string text = null, bool isTTS = false);


/// <summary> Broadcasts the "user is typing" message to all users in this channel, lasting 10 seconds.</summary>
Task SendIsTyping(); Task SendIsTyping();
} }
} }

+ 2
- 1
ref/Entities/Channels/IVoiceChannel.cs View File

@@ -2,6 +2,7 @@
{ {
public interface IVoiceChannel : IChannel public interface IVoiceChannel : IChannel
{ {
int Bitrate { get; set; }
/// <summary> Gets the requested bitrate, in bits per second, of this voice channel. </summary>
int Bitrate { get; }
} }
} }

+ 41
- 17
ref/Entities/Channels/PrivateChannel.cs View File

@@ -1,31 +1,55 @@
using System;
using System.Collections.Generic;
using System.Collections.Generic;
using System.IO; using System.IO;
using System.Threading.Tasks; using System.Threading.Tasks;


namespace Discord namespace Discord
{ {
public class PrivateChannel : Channel, ITextChannel, IPrivateChannel
{
public User Recipient { get; }
public IEnumerable<Message> Messages { get; }

public override DiscordClient Client => null;
public override ChannelType Type => default(ChannelType);
public class PrivateChannel : ITextChannel, IPrivateChannel
{
/// <inheritdoc />
public ulong Id { get; }
/// <inheritdoc />
public DiscordClient Client { get; }
/// <inheritdoc />
public ModelState State { get; }
/// <inheritdoc />
public ChannelType Type { get; }
/// <inheritdoc />
public bool IsPrivate => true;
/// <inheritdoc />
public bool IsPublic => false;
/// <inheritdoc />
public bool IsText => true;
/// <inheritdoc />
public bool IsVoice => false;


public override User CurrentUser => null;
public override IEnumerable<User> Users => null;
/// <inheritdoc />
public Server Server { get; }
/// <inheritdoc />
public User Recipient { get; }


public Message GetMessage(ulong id) => null;
public Task<IEnumerable<Message>> DownloadMessages(int limit) => null;
public Task<IEnumerable<Message>> DownloadMessages(int limit, ulong? relativeMessageId, Relative relativeDir) => null;
/// <inheritdoc />
public Task<IEnumerable<User>> GetUsers();
/// <inheritdoc />
public Task<Message> GetMessage(ulong id) => null;
/// <inheritdoc />
public Task<IEnumerable<Message>> GetMessages(int limit = 100) => null;
/// <inheritdoc />
public Task<IEnumerable<Message>> GetMessages(int limit = 100, ulong? relativeMessageId = null, Relative relativeDir = Relative.Before) => null;


/// <inheritdoc />
public Task<Message> SendMessage(string text, bool isTTS = false) => null; public Task<Message> SendMessage(string text, bool isTTS = false) => null;
public Task<Message> SendFile(string path, string text = null, bool isTTS = false) => null;
/// <inheritdoc />
public Task<Message> SendFile(string filePath, string text = null, bool isTTS = false) => null;
/// <inheritdoc />
public Task<Message> SendFile(Stream stream, string filename, string text = null, bool isTTS = false) => null; public Task<Message> SendFile(Stream stream, string filename, string text = null, bool isTTS = false) => null;


/// <inheritdoc />
public Task SendIsTyping() => null; public Task SendIsTyping() => null;

public override Task Save() => null;
/// <inheritdoc />
public Task Delete() => null;
/// <inheritdoc />
public Task Update() => null;
} }
} }

+ 74
- 30
ref/Entities/Channels/TextChannel.cs View File

@@ -1,50 +1,94 @@
using System.Collections.Generic;
using System;
using System.Collections.Generic;
using System.IO; using System.IO;
using System.Threading.Tasks; using System.Threading.Tasks;


namespace Discord namespace Discord
{ {
public class TextChannel : Channel, ITextChannel, IPublicChannel, IMentionable
public class TextChannel : ITextChannel, IPublicChannel, IMentionable, IModifiable<TextChannel.Properties>
{ {
public Server Server { get; }
public string Mention { get; }
public IEnumerable<PermissionOverwrite> PermissionOverwrites { get; }
public IEnumerable<Message> Messages { get; }
public sealed class Properties
{
}


public string Topic { get; set; }
public bool IsTyping { get; set; }
public string Name { get; set; }
public int Position { get; set; }
/// <inheritdoc />
public ulong Id { get; }
/// <inheritdoc />
public DiscordClient Discord { get; }
/// <inheritdoc />
public ModelState 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;


public override DiscordClient Client => null;
public override ChannelType Type => default(ChannelType);
public override User CurrentUser => null;
public override IEnumerable<User> Users => null;
/// <inheritdoc />
public string Name { get; }
/// <inheritdoc />
public string Topic { get; }
/// <inheritdoc />
public int Position { get; }
/// <inheritdoc />
public string Mention { get; }
/// <inheritdoc />
public Server Server { get; }
/// <inheritdoc />
public IEnumerable<PermissionOverwrite> PermissionOverwrites { get; }
/// <inheritdoc />
public IEnumerable<User> Users { get; }


public Message GetMessage(ulong id) => null;
public PermissionOverwrite? GetPermissionsRule(User user) => null;
public PermissionOverwrite? GetPermissionsRule(Role role) => null;
/// <inheritdoc />
public Task<IEnumerable<User>> GetUsers() => null;
/// <inheritdoc />
public Task<Message> GetMessage(ulong id) => null;
/// <inheritdoc />
public Task<IEnumerable<Message>> GetMessages(int limit = 100) => null;
/// <inheritdoc />
public Task<IEnumerable<Message>> GetMessages(int limit = 100, ulong? relativeMessageId = null, Relative relativeDir = Relative.Before) => null;
/// <inheritdoc />
public Task<PermissionOverwrite?> GetPermissionOverwrite(User user) => null;
/// <inheritdoc />
public Task<PermissionOverwrite?> GetPermissionOverwrite(Role role) => null;
/// <inheritdoc />
public Task<IEnumerable<Invite>> GetInvites() => null;


public Task<IEnumerable<Message>> DownloadMessages(int limit) => null;
public Task<IEnumerable<Message>> DownloadMessages(int limit, ulong? relativeMessageId, Relative relativeDir) => null;
public Task<IEnumerable<Invite>> DownloadInvites() => null;
/// <inheritdoc />
public Task UpdatePermissionOverwrite(User user, ChannelPermissions allow, ChannelPermissions deny) => null;
/// <inheritdoc />
public Task UpdatePermissionOverwrite(User user, TriStateChannelPermissions permissions) => null;
/// <inheritdoc />
public Task UpdatePermissionOverwrite(Role role, ChannelPermissions allow, ChannelPermissions deny) => null;
/// <inheritdoc />
public Task UpdatePermissionOverwrite(Role role, TriStateChannelPermissions permissions) => null;
/// <inheritdoc />
public Task RemovePermissionOverwrite(User user) => null;
/// <inheritdoc />
public Task RemovePermissionOverwrite(Role role) => null;


/// <inheritdoc />
public Task<Message> SendMessage(string text, bool isTTS = false) => null; public Task<Message> SendMessage(string text, bool isTTS = false) => null;
public Task<Message> SendFile(string path, string text = null, bool isTTS = false) => null;
/// <inheritdoc />
public Task<Message> SendFile(string filePath, string text = null, bool isTTS = false) => null;
/// <inheritdoc />
public Task<Message> SendFile(Stream stream, string filename, string text = null, bool isTTS = false) => null; public Task<Message> SendFile(Stream stream, string filename, string text = null, bool isTTS = false) => null;


/// <inheritdoc />
public Task SendIsTyping() => null; public Task SendIsTyping() => null;


public Task<Invite> CreateInvite(int? maxAge = 1800, int? maxUses = default(int?), bool tempMembership = false, bool withXkcd = false) => null;

public Task AddPermissionsRule(User user, ChannelPermissions allow, ChannelPermissions deny) => null;
public Task AddPermissionsRule(User user, TriStateChannelPermissions permissions) => null;
public Task AddPermissionsRule(Role role, ChannelPermissions allow, ChannelPermissions deny) => null;
public Task AddPermissionsRule(Role role, TriStateChannelPermissions permissions) => null;
public Task RemovePermissionsRule(User user) => null;
public Task RemovePermissionsRule(Role role) => null;
/// <inheritdoc />
public Task<Invite> CreateInvite(int? maxAge = 1800, int? maxUses = null, bool tempMembership = false, bool withXkcd = false) => null;


/// <inheritdoc />
public Task Delete() => null; public Task Delete() => null;
public override Task Save() => null;
/// <inheritdoc />
public Task Update() => null;
/// <inheritdoc />
public Task Modify(Action<Properties> func) => null;
} }
} }

+ 57
- 32
ref/Entities/Channels/VoiceChannel.cs View File

@@ -1,49 +1,74 @@
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.IO;
using System.Threading.Tasks; using System.Threading.Tasks;


namespace Discord namespace Discord
{ {
public class VoiceChannel : IPublicChannel, IVoiceChannel
public class VoiceChannel : IPublicChannel, IVoiceChannel, IModifiable<VoiceChannel.Properties>
{ {
public sealed class Properties
{
public int Bitrate { get; set; }
}

/// <inheritdoc />
public ulong Id { get; } public ulong Id { get; }
/// <inheritdoc />
public DiscordClient Client { get; } public DiscordClient Client { get; }
public Server Server { get; }
/// <inheritdoc />
public ModelState State { get; }
/// <inheritdoc />
public ChannelType Type { get; } public ChannelType Type { get; }
public bool IsText { get; }
public bool IsVoice { get; }
public bool IsPrivate { get; }
public bool IsPublic { get; }
public IEnumerable<PermissionOverwrite> PermissionOverwrites { get; }
public IEnumerable<User> Users { get; }

public string Name { get; set; }
public int Position { get; set; }
public int Bitrate { get; set; }
/// <inheritdoc />
public bool IsPrivate => false;
/// <inheritdoc />
public bool IsPublic => true;
/// <inheritdoc />
public bool IsText => false;
/// <inheritdoc />
public bool IsVoice => true;


public Message GetMessage(ulong id) => null;
public PermissionOverwrite? GetPermissionsRule(User user) => null;
public PermissionOverwrite? GetPermissionsRule(Role role) => null;

public Task<IEnumerable<Message>> DownloadMessages(int limit) => null;
public Task<IEnumerable<Message>> DownloadMessages(int limit, ulong? relativeMessageId, Relative relativeDir) => null;
public Task<IEnumerable<Invite>> DownloadInvites() => null;

public Task<Message> SendMessage(string text, bool isTTS = false) => null;
public Task<Message> SendFile(string path, string text = null, bool isTTS = false) => null;
public Task<Message> SendFile(Stream stream, string filename, string text = null, bool isTTS = false) => null;
/// <inheritdoc />
public string Name { get; }
/// <inheritdoc />
public int Position { get; }
/// <inheritdoc />
public int Bitrate { get; }
/// <inheritdoc />
public Server Server { get; }
/// <inheritdoc />
public IEnumerable<PermissionOverwrite> PermissionOverwrites { get; }


public Task<Invite> CreateInvite(int? maxAge = 1800, int? maxUses = default(int?), bool tempMembership = false, bool withXkcd = false) => null;
/// <inheritdoc />
public PermissionOverwrite? GetPermissionOverwrite(User user) => null;
/// <inheritdoc />
public PermissionOverwrite? GetPermissionOverwrite(Role role) => null;
/// <inheritdoc />
public Task<IEnumerable<User>> GetUsers() => null;
/// <inheritdoc />
public Task<IEnumerable<Invite>> GetInvites() => null;
/// <inheritdoc />
public Task UpdatePermissionOverwrite(User user, ChannelPermissions allow, ChannelPermissions deny) => null;
/// <inheritdoc />
public Task UpdatePermissionOverwrite(User user, TriStateChannelPermissions permissions) => null;
/// <inheritdoc />
public Task UpdatePermissionOverwrite(Role role, ChannelPermissions allow, ChannelPermissions deny) => null;
/// <inheritdoc />
public Task UpdatePermissionOverwrite(Role role, TriStateChannelPermissions permissions) => null;
/// <inheritdoc />
public Task RemovePermissionOverwrite(User user) => null;
/// <inheritdoc />
public Task RemovePermissionOverwrite(Role role) => null;


public Task AddPermissionsRule(User user, ChannelPermissions allow, ChannelPermissions deny) => null;
public Task AddPermissionsRule(User user, TriStateChannelPermissions permissions) => null;
public Task AddPermissionsRule(Role role, ChannelPermissions allow, ChannelPermissions deny) => null;
public Task AddPermissionsRule(Role role, TriStateChannelPermissions permissions) => null;
public Task RemovePermissionsRule(User user) => null;
public Task RemovePermissionsRule(Role role) => null;
/// <inheritdoc />
public Task<Invite> CreateInvite(int? maxAge = 1800, int? maxUses = null, bool tempMembership = false, bool withXkcd = false) => null;


/// <inheritdoc />
public Task Delete() => null; public Task Delete() => null;
public Task Save() => null;
/// <inheritdoc />
public Task Update() => null;
/// <inheritdoc />
public Task Modify(Action<Properties> func) => null;
} }
} }

+ 23
- 0
ref/Entities/IEntity.cs View File

@@ -0,0 +1,23 @@
using System;
using System.Threading.Tasks;

namespace Discord
{
public interface IEntity<TId> : IEntity
{
/// <summary> Gets the unique identifier for this object. </summary>
TId Id { get; }
}
public interface IEntity
{
/// <summary> Gets the DiscordClient that manages this object. </summary>
DiscordClient Client { get; }
/// <summary> Gets the state of this object. </summary>
ModelState State { get; }

/// <summary> Deletes this object. </summary>
Task Delete();
/// <summary> Downloads the latest values and updates this object. </summary>
Task Update();
}
}

+ 0
- 13
ref/Entities/IModel.cs View File

@@ -1,13 +0,0 @@
using System.Threading.Tasks;

namespace Discord
{
public interface IModel<TId> : IModel
{
TId Id { get; }
}
public interface IModel
{
Task Save();
}
}

+ 11
- 0
ref/Entities/IModifiable.cs View File

@@ -0,0 +1,11 @@
using System;
using System.Threading.Tasks;

namespace Discord
{
public interface IModifiable<TModel>
{
/// <summary> Modifies one or more of the properties of this object. </summary>
Task Modify(Action<TModel> func);
}
}

+ 1
- 1
ref/Entities/Message.cs View File

@@ -4,7 +4,7 @@ using System.Threading.Tasks;


namespace Discord namespace Discord
{ {
public class Message : IModel<ulong>
public class Message : IEntity<ulong>
{ {
public class Attachment : File public class Attachment : File
{ {


+ 1
- 1
ref/Entities/Profile.cs View File

@@ -2,7 +2,7 @@


namespace Discord namespace Discord
{ {
public class Profile : IModel<ulong>
public class Profile : IEntity<ulong>
{ {
public DiscordClient Client { get; } public DiscordClient Client { get; }


+ 1
- 1
ref/Entities/Role.cs View File

@@ -3,7 +3,7 @@ using System.Threading.Tasks;


namespace Discord namespace Discord
{ {
public class Role : IModel<ulong>, IMentionable
public class Role : IEntity<ulong>, IMentionable
{ {
public DiscordClient Client { get; } public DiscordClient Client { get; }




+ 2
- 2
ref/Entities/Server.cs View File

@@ -4,7 +4,7 @@ using System.Threading.Tasks;


namespace Discord namespace Discord
{ {
public class Server : IModel<ulong>
public class Server : IEntity<ulong>
{ {
public class Emoji public class Emoji
{ {
@@ -28,7 +28,7 @@ namespace Discord
public Role EveryoneRole { get; } public Role EveryoneRole { get; }
public IEnumerable<string> Features { get; } public IEnumerable<string> Features { get; }
public IEnumerable<Emoji> CustomEmojis { get; } public IEnumerable<Emoji> CustomEmojis { get; }
public IEnumerable<Channel> Channels { get; }
public IEnumerable<IChannel> Channels { get; }
public IEnumerable<TextChannel> TextChannels { get; } public IEnumerable<TextChannel> TextChannels { get; }
public IEnumerable<VoiceChannel> VoiceChannels { get; } public IEnumerable<VoiceChannel> VoiceChannels { get; }
public IEnumerable<User> Users { get; } public IEnumerable<User> Users { get; }


+ 9
- 4
ref/Enums/ChannelType.cs View File

@@ -1,8 +1,13 @@
namespace Discord
using System;

namespace Discord
{ {
public enum ChannelType
[Flags]
public enum ChannelType : byte
{ {
Text,
Voice
Public = 0x01,
Private = 0x02,
Text = 0x10,
Voice = 0x20
} }
} }

ref/Enums/MessageState.cs → ref/Enums/ModelState.cs View File

@@ -1,6 +1,6 @@
namespace Discord namespace Discord
{ {
public enum MessageState : byte
public enum ModelState : byte
{ {
/// <summary> Message did not originate from this session, or was successfully sent. </summary> /// <summary> Message did not originate from this session, or was successfully sent. </summary>
Normal = 0, Normal = 0,

+ 2
- 2
ref/Events/ChannelUpdatedEventArgs.cs View File

@@ -4,8 +4,8 @@ namespace Discord
{ {
public class ChannelUpdatedEventArgs : EventArgs public class ChannelUpdatedEventArgs : EventArgs
{ {
public Channel Before => null;
public Channel After => null;
public IChannel Before => null;
public IChannel After => null;
public Server Server => null; public Server Server => null;
} }
} }

+ 0
- 8
ref/Events/ChannelUserEventArgs.cs View File

@@ -1,8 +0,0 @@
namespace Discord
{
public class ChannelUserEventArgs
{
public Channel Channel => null;
public User User => null;
}
}

+ 14
- 0
ref/Events/TypingEventArgs.cs View File

@@ -0,0 +1,14 @@
namespace Discord
{
public class TypingEventArgs
{
public ITextChannel Channel { get; }
public User User { get; }

public TypingEventArgs(ITextChannel channel, User user)
{
Channel = channel;
User = user;
}
}
}

Loading…
Cancel
Save