| @@ -0,0 +1,21 @@ | |||
| <?xml version="1.0" encoding="utf-8"?> | |||
| <Project ToolsVersion="14.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> | |||
| <PropertyGroup> | |||
| <VisualStudioVersion Condition="'$(VisualStudioVersion)' == ''">14.0</VisualStudioVersion> | |||
| <VSToolsPath Condition="'$(VSToolsPath)' == ''">$(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion)</VSToolsPath> | |||
| </PropertyGroup> | |||
| <Import Project="$(VSToolsPath)\DNX\Microsoft.DNX.Props" Condition="'$(VSToolsPath)' != ''" /> | |||
| <PropertyGroup Label="Globals"> | |||
| <ProjectGuid>5b2afee6-fff6-4ba2-be12-61b283b72ac0</ProjectGuid> | |||
| <RootNamespace>Discord</RootNamespace> | |||
| <BaseIntermediateOutputPath Condition="'$(BaseIntermediateOutputPath)'=='' ">..\..\artifacts\obj\$(MSBuildProjectName)</BaseIntermediateOutputPath> | |||
| <OutputPath Condition="'$(OutputPath)'=='' ">..\..\artifacts\bin\$(MSBuildProjectName)\</OutputPath> | |||
| </PropertyGroup> | |||
| <PropertyGroup> | |||
| <SchemaVersion>2.0</SchemaVersion> | |||
| </PropertyGroup> | |||
| <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|AnyCPU'"> | |||
| <ProduceOutputsOnBuild>True</ProduceOutputsOnBuild> | |||
| </PropertyGroup> | |||
| <Import Project="$(VSToolsPath)\DNX\Microsoft.DNX.targets" Condition="'$(VSToolsPath)' != ''" /> | |||
| </Project> | |||
| @@ -0,0 +1,32 @@ | |||
| using System; | |||
| namespace Discord | |||
| { | |||
| public partial class DiscordClient | |||
| { | |||
| public event EventHandler Ready = delegate { }; | |||
| public event EventHandler<ChannelEventArgs> ChannelCreated = delegate { }; | |||
| public event EventHandler<ChannelEventArgs> ChannelDestroyed = delegate { }; | |||
| public event EventHandler<ChannelUpdatedEventArgs> ChannelUpdated = delegate { }; | |||
| public event EventHandler<MessageEventArgs> MessageAcknowledged = delegate { }; | |||
| public event EventHandler<MessageEventArgs> MessageDeleted = delegate { }; | |||
| public event EventHandler<MessageEventArgs> MessageReceived = delegate { }; | |||
| public event EventHandler<MessageEventArgs> MessageSent = delegate { }; | |||
| public event EventHandler<MessageUpdatedEventArgs> MessageUpdated = delegate { }; | |||
| public event EventHandler<ProfileUpdatedEventArgs> ProfileUpdated = delegate { }; | |||
| public event EventHandler<RoleEventArgs> RoleCreated = delegate { }; | |||
| public event EventHandler<RoleUpdatedEventArgs> RoleUpdated = delegate { }; | |||
| public event EventHandler<RoleEventArgs> RoleDeleted = delegate { }; | |||
| public event EventHandler<ServerEventArgs> JoinedServer = delegate { }; | |||
| public event EventHandler<ServerEventArgs> LeftServer = delegate { }; | |||
| public event EventHandler<ServerEventArgs> ServerAvailable = delegate { }; | |||
| public event EventHandler<ServerUpdatedEventArgs> ServerUpdated = delegate { }; | |||
| public event EventHandler<ServerEventArgs> ServerUnavailable = delegate { }; | |||
| public event EventHandler<UserEventArgs> UserBanned = delegate { }; | |||
| public event EventHandler<ChannelUserEventArgs> UserIsTyping = delegate { }; | |||
| public event EventHandler<UserEventArgs> UserJoined = delegate { }; | |||
| public event EventHandler<UserEventArgs> UserLeft = delegate { }; | |||
| public event EventHandler<UserUpdatedEventArgs> UserUpdated = delegate { }; | |||
| public event EventHandler<UserEventArgs> UserUnbanned = delegate { }; | |||
| } | |||
| } | |||
| @@ -0,0 +1,59 @@ | |||
| using Discord.Net; | |||
| using Discord.Net.Rest; | |||
| using Discord.Net.WebSockets; | |||
| using Newtonsoft.Json; | |||
| using System; | |||
| using System.Collections.Generic; | |||
| using System.IO; | |||
| using System.Net; | |||
| using System.Threading; | |||
| using System.Threading.Tasks; | |||
| namespace Discord | |||
| { | |||
| /// <summary> Provides a connection to the DiscordApp service. </summary> | |||
| public partial class DiscordClient : IDisposable | |||
| { | |||
| public DiscordConfig Config { get; } | |||
| public RestClient ClientAPI { get; } | |||
| public RestClient StatusAPI { get; } | |||
| public GatewaySocket GatewaySocket { get; } | |||
| public MessageQueue MessageQueue { get; } | |||
| public JsonSerializer Serializer { get; } | |||
| public ConnectionState State { get; } | |||
| public CancellationToken CancelToken { get; } | |||
| public Profile CurrentUser { get; } | |||
| public string SessionId { get; } | |||
| public UserStatus Status { get; } | |||
| public string CurrentGame { get; } | |||
| public IEnumerable<Server> Servers { get; } | |||
| public IEnumerable<Channel> PrivateChannels { get; } | |||
| public IEnumerable<Region> Regions { get; } | |||
| public DiscordClient() { } | |||
| public DiscordClient(DiscordConfig config) { } | |||
| public DiscordClient(Action<DiscordConfig> configFunc) { } | |||
| public Task<string> Connect(string email, string password, string token = null) => null; | |||
| public Task Connect(string token) => null; | |||
| public Task Disconnect() => null; | |||
| public void SetStatus(UserStatus status) { } | |||
| public void SetGame(string game) { } | |||
| public Channel GetChannel(ulong id) => null; | |||
| public Task<Channel> CreatePrivateChannel(ulong userId) => null; | |||
| public Task<Invite> GetInvite(string inviteIdOrXkcd) => null; | |||
| public Region GetRegion(string id) => null; | |||
| public Server GetServer(ulong id) => null; | |||
| public IEnumerable<Server> FindServers(string name) => null; | |||
| public Task<Server> CreateServer(string name, Region region, ImageType iconType = ImageType.None, Stream icon = null) => null; | |||
| public void Dispose() { } | |||
| } | |||
| } | |||
| @@ -0,0 +1,36 @@ | |||
| using System; | |||
| namespace Discord | |||
| { | |||
| public class DiscordConfig | |||
| { | |||
| public const int MaxMessageSize = 2000; | |||
| public const string LibName = "Discord.Net"; | |||
| public static readonly string LibVersion = null; | |||
| public const string LibUrl = "https://github.com/RogueException/Discord.Net"; | |||
| public const string ClientAPIUrl = "https://discordapp.com/api/"; | |||
| public const string StatusAPIUrl = "https://srhpyqt94yxb.statuspage.io/api/v2/"; //"https://status.discordapp.com/api/v2/"; | |||
| public const string CDNUrl = "https://cdn.discordapp.com/"; | |||
| public const string InviteUrl = "https://discord.gg/"; | |||
| public string AppName { get; set; } = null; | |||
| public string AppUrl { get; set; } = null; | |||
| public string AppVersion { get; set; } = null; | |||
| public LogSeverity LogLevel { get; set; } = LogSeverity.Info; | |||
| public int ConnectionTimeout { get; set; } = 30000; | |||
| public int ReconnectDelay { get; set; } = 1000; | |||
| public int FailedReconnectDelay { get; set; } = 15000; | |||
| public bool CacheToken { get; set; } = true; | |||
| public int MessageCacheSize { get; set; } = 100; | |||
| public bool UsePermissionsCache { get; set; } = true; | |||
| public bool EnablePreUpdateEvents { get; set; } = true; | |||
| public int LargeThreshold { get; set; } = 250; | |||
| public EventHandler<LogMessageEventArgs> LogHandler { get; set; } | |||
| public string UserAgent { get; } | |||
| } | |||
| } | |||
| @@ -0,0 +1,22 @@ | |||
| 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(); | |||
| } | |||
| } | |||
| @@ -0,0 +1,17 @@ | |||
| using System.Collections.Generic; | |||
| namespace Discord | |||
| { | |||
| public interface IChannel : IModel<ulong> | |||
| { | |||
| DiscordClient Client { get; } | |||
| ChannelType Type { get; } | |||
| bool IsText { get; } | |||
| bool IsVoice { get; } | |||
| bool IsPrivate { get; } | |||
| bool IsPublic { get; } | |||
| IEnumerable<User> Users { get; } | |||
| } | |||
| } | |||
| @@ -2,5 +2,6 @@ | |||
| { | |||
| public interface IPrivateChannel : IChannel | |||
| { | |||
| User Recipient { get; } | |||
| } | |||
| } | |||
| @@ -0,0 +1,30 @@ | |||
| using System.Collections.Generic; | |||
| using System.Threading.Tasks; | |||
| namespace Discord | |||
| { | |||
| public interface IPublicChannel : IChannel | |||
| { | |||
| Server Server { get; } | |||
| string Name { get; set; } | |||
| int Position { get; set; } | |||
| IEnumerable<PermissionOverwrite> PermissionOverwrites { get; } | |||
| PermissionOverwrite? GetPermissionsRule(User user); | |||
| PermissionOverwrite? GetPermissionsRule(Role role); | |||
| Task<IEnumerable<Invite>> DownloadInvites(); | |||
| Task Delete(); | |||
| 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); | |||
| } | |||
| } | |||
| @@ -0,0 +1,18 @@ | |||
| using System.Collections.Generic; | |||
| using System.IO; | |||
| using System.Threading.Tasks; | |||
| namespace Discord | |||
| { | |||
| public interface ITextChannel : IChannel | |||
| { | |||
| Message GetMessage(ulong id); | |||
| Task<IEnumerable<Message>> DownloadMessages(int limit = 100, ulong? relativeMessageId = null, Relative relativeDir = Relative.Before); | |||
| Task<Message> SendMessage(string text, bool isTTS = false); | |||
| Task<Message> SendFile(string filePath, string text = null, bool isTTS = false); | |||
| Task<Message> SendFile(Stream stream, string filename, string text = null, bool isTTS = false); | |||
| Task SendIsTyping(); | |||
| } | |||
| } | |||
| @@ -0,0 +1,7 @@ | |||
| namespace Discord | |||
| { | |||
| public interface IVoiceChannel : IChannel | |||
| { | |||
| int Bitrate { get; set; } | |||
| } | |||
| } | |||
| @@ -0,0 +1,31 @@ | |||
| using System; | |||
| using System.Collections.Generic; | |||
| using System.IO; | |||
| using System.Threading.Tasks; | |||
| 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 override User CurrentUser => null; | |||
| public override IEnumerable<User> Users => null; | |||
| 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; | |||
| 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; | |||
| public Task SendIsTyping() => null; | |||
| public override Task Save() => null; | |||
| } | |||
| } | |||
| @@ -0,0 +1,50 @@ | |||
| using System.Collections.Generic; | |||
| using System.IO; | |||
| using System.Threading.Tasks; | |||
| namespace Discord | |||
| { | |||
| public class TextChannel : Channel, ITextChannel, IPublicChannel, IMentionable | |||
| { | |||
| public Server Server { get; } | |||
| public string Mention { get; } | |||
| public IEnumerable<PermissionOverwrite> PermissionOverwrites { get; } | |||
| public IEnumerable<Message> Messages { get; } | |||
| public string Topic { get; set; } | |||
| public bool IsTyping { get; set; } | |||
| public string Name { get; set; } | |||
| public int Position { get; set; } | |||
| public override DiscordClient Client => null; | |||
| public override ChannelType Type => default(ChannelType); | |||
| public override User CurrentUser => null; | |||
| public override IEnumerable<User> Users => null; | |||
| 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; | |||
| 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; | |||
| public Task Delete() => null; | |||
| public override Task Save() => null; | |||
| } | |||
| } | |||
| @@ -0,0 +1,49 @@ | |||
| using System; | |||
| using System.Collections.Generic; | |||
| using System.IO; | |||
| using System.Threading.Tasks; | |||
| namespace Discord | |||
| { | |||
| public class VoiceChannel : IPublicChannel, IVoiceChannel | |||
| { | |||
| public ulong Id { get; } | |||
| public DiscordClient Client { get; } | |||
| public Server Server { 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; } | |||
| 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; | |||
| 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; | |||
| public Task Delete() => null; | |||
| public Task Save() => null; | |||
| } | |||
| } | |||
| @@ -0,0 +1,17 @@ | |||
| namespace Discord | |||
| { | |||
| public class Color | |||
| { | |||
| public static readonly Color Default = new Color(0); | |||
| public uint RawValue { get; } | |||
| public Color(uint rawValue) { } | |||
| public Color(byte r, byte g, byte b) { } | |||
| public Color(float r, float g, float b) { } | |||
| public byte R { get; } | |||
| public byte G { get; } | |||
| public byte B { get; } | |||
| } | |||
| } | |||
| @@ -0,0 +1,7 @@ | |||
| namespace Discord | |||
| { | |||
| public interface IMentionable | |||
| { | |||
| string Mention { get; } | |||
| } | |||
| } | |||
| @@ -0,0 +1,13 @@ | |||
| using System.Threading.Tasks; | |||
| namespace Discord | |||
| { | |||
| public interface IModel<TId> : IModel | |||
| { | |||
| TId Id { get; } | |||
| } | |||
| public interface IModel | |||
| { | |||
| Task Save(); | |||
| } | |||
| } | |||
| @@ -0,0 +1,48 @@ | |||
| using System; | |||
| using System.Threading.Tasks; | |||
| namespace Discord | |||
| { | |||
| public class Invite : IModel<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; } | |||
| } | |||
| public DiscordClient Client { get; } | |||
| string IModel<string>.Id => Code; | |||
| 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 Delete() => null; | |||
| public Task Accept() => null; | |||
| public Task Save() => null; | |||
| } | |||
| } | |||
| @@ -0,0 +1,68 @@ | |||
| using System; | |||
| using System.Collections.Generic; | |||
| using System.Threading.Tasks; | |||
| namespace Discord | |||
| { | |||
| public class Message : IModel<ulong> | |||
| { | |||
| public class Attachment : File | |||
| { | |||
| public string Id { get; } | |||
| public int Size { get; } | |||
| public string Filename { get; } | |||
| } | |||
| public class Embed | |||
| { | |||
| public string Url { get; } | |||
| public string Type { get; } | |||
| public string Title { get; } | |||
| public string Description { get; } | |||
| public EmbedLink Author { get; } | |||
| public EmbedLink Provider { get; } | |||
| public File Thumbnail { get; } | |||
| public File Video { get; } | |||
| } | |||
| public class EmbedLink | |||
| { | |||
| public string Url { get; } | |||
| public string Name { get; } | |||
| } | |||
| public class File | |||
| { | |||
| public string Url { get; } | |||
| public string ProxyUrl { get; } | |||
| public int? Width { get; } | |||
| public int? Height { get; } | |||
| } | |||
| public DiscordClient Client { get; } | |||
| public ulong Id { get; } | |||
| public ITextChannel Channel { get; } | |||
| public User User { get; } | |||
| public bool IsTTS { get; } | |||
| public MessageState State { get; } | |||
| public string RawText { get; } | |||
| public string Text { get; } | |||
| public DateTime Timestamp { get; } | |||
| public DateTime? EditedTimestamp { get; } | |||
| public Attachment[] Attachments { get; } | |||
| public Embed[] Embeds { get; } | |||
| public IEnumerable<User> MentionedUsers { get; } | |||
| public IEnumerable<IPublicChannel> MentionedChannels { get; } | |||
| public IEnumerable<Role> MentionedRoles { get; } | |||
| public Server Server => null; | |||
| public bool IsAuthor => false; | |||
| public Task Delete() => null; | |||
| public Task Save() => null; | |||
| public bool IsMentioningMe(bool includeRoles = false) => false; | |||
| } | |||
| } | |||
| @@ -0,0 +1,54 @@ | |||
| namespace Discord | |||
| { | |||
| public struct ChannelPermissions | |||
| { | |||
| public static ChannelPermissions None { get; } | |||
| public static ChannelPermissions TextOnly { get; } | |||
| public static ChannelPermissions PrivateOnly { get; } | |||
| public static ChannelPermissions VoiceOnly { get; } | |||
| public static ChannelPermissions All(Channel channel) => default(ChannelPermissions); | |||
| public static ChannelPermissions All(ChannelType channelType, bool isPrivate) => default(ChannelPermissions); | |||
| public uint RawValue { get; } | |||
| public bool CreateInstantInvit { get; } | |||
| public bool ManagePermission { get; } | |||
| public bool ManageChannel { get; } | |||
| public bool ReadMessages { get; } | |||
| public bool SendMessages { get; } | |||
| public bool SendTTSMessages { get; } | |||
| public bool ManageMessages { get; } | |||
| public bool EmbedLinks { get; } | |||
| public bool AttachFiles { get; } | |||
| public bool ReadMessageHistory { get; } | |||
| public bool MentionEveryone { get; } | |||
| public bool Connect { get; } | |||
| public bool Speak { get; } | |||
| public bool MuteMembers { get; } | |||
| public bool DeafenMembers { get; } | |||
| public bool MoveMembers { get; } | |||
| public bool UseVoiceActivation { get; } | |||
| public ChannelPermissions(bool? createInstantInvite = null, bool? managePermissions = null, | |||
| bool? manageChannel = null, bool? readMessages = null, bool? sendMessages = null, bool? sendTTSMessages = null, | |||
| bool? manageMessages = null, bool? embedLinks = null, bool? attachFiles = null, bool? readMessageHistory = null, | |||
| bool? mentionEveryone = null, bool? connect = null, bool? speak = null, bool? muteMembers = null, bool? deafenMembers = null, | |||
| bool? moveMembers = null, bool? useVoiceActivation = null) | |||
| : this() | |||
| { | |||
| } | |||
| public ChannelPermissions(uint rawValue) | |||
| : this() | |||
| { | |||
| } | |||
| public ChannelPermissions Modify(ChannelPermissions basePerms, bool? createInstantInvite = null, bool? managePermissions = null, | |||
| bool? manageChannel = null, bool? readMessages = null, bool? sendMessages = null, bool? sendTTSMessages = null, | |||
| bool? manageMessages = null, bool? embedLinks = null, bool? attachFiles = null, bool? readMessageHistory = null, | |||
| bool? mentionEveryone = null, bool? connect = null, bool? speak = null, bool? muteMembers = null, bool? deafenMembers = null, | |||
| bool? moveMembers = null, bool? useVoiceActivation = null) | |||
| => default(ChannelPermissions); | |||
| } | |||
| } | |||
| @@ -0,0 +1,9 @@ | |||
| namespace Discord | |||
| { | |||
| public struct PermissionOverwrite | |||
| { | |||
| public PermissionTarget TargetType { get; } | |||
| public ulong TargetId { get; } | |||
| public TriStateChannelPermissions Permissions { get; } | |||
| } | |||
| } | |||
| @@ -0,0 +1,55 @@ | |||
| namespace Discord | |||
| { | |||
| public struct ServerPermissions | |||
| { | |||
| public static ServerPermissions None { get; } | |||
| public static ServerPermissions All { get; } | |||
| public uint RawValue { get; } | |||
| public bool CreateInstantInvite { get; } | |||
| public bool BanMembers { get; } | |||
| public bool KickMembers { get; } | |||
| public bool ManageRoles { get; } | |||
| public bool ManageChannels { get; } | |||
| public bool ManageServer { get; } | |||
| public bool ReadMessages { get; } | |||
| public bool SendMessages { get; } | |||
| public bool SendTTSMessages { get; } | |||
| public bool ManageMessages { get; } | |||
| public bool EmbedLinks { get; } | |||
| public bool AttachFiles { get; } | |||
| public bool ReadMessageHistory { get; } | |||
| public bool MentionEveryone { get; } | |||
| public bool Connect { get; } | |||
| public bool Speak { get; } | |||
| public bool MuteMembers { get; } | |||
| public bool DeafenMembers { get; } | |||
| public bool MoveMembers { get; } | |||
| public bool UseVoiceActivation { get; } | |||
| public ServerPermissions(bool? createInstantInvite = null, bool? manageRoles = null, | |||
| bool? kickMembers = null, bool? banMembers = null, bool? manageChannel = null, bool? manageServer = null, | |||
| bool? readMessages = null, bool? sendMessages = null, bool? sendTTSMessages = null, bool? manageMessages = null, | |||
| bool? embedLinks = null, bool? attachFiles = null, bool? readMessageHistory = null, bool? mentionEveryone = null, | |||
| bool? connect = null, bool? speak = null, bool? muteMembers = null, bool? deafenMembers = null, | |||
| bool? moveMembers = null, bool? useVoiceActivation = null) | |||
| : this() | |||
| { | |||
| } | |||
| public ServerPermissions(uint rawValue) | |||
| : this() | |||
| { | |||
| } | |||
| public ServerPermissions Modify(ServerPermissions basePerms, bool? createInstantInvite = null, bool? manageRoles = null, | |||
| bool? kickMembers = null, bool? banMembers = null, bool? manageChannel = null, bool? manageServer = null, | |||
| bool? readMessages = null, bool? sendMessages = null, bool? sendTTSMessages = null, bool? manageMessages = null, | |||
| bool? embedLinks = null, bool? attachFiles = null, bool? readMessageHistory = null, bool? mentionEveryone = null, | |||
| bool? connect = null, bool? speak = null, bool? muteMembers = null, bool? deafenMembers = null, | |||
| bool? moveMembers = null, bool? useVoiceActivation = null) | |||
| => default(ServerPermissions); | |||
| } | |||
| } | |||
| @@ -0,0 +1,50 @@ | |||
| namespace Discord | |||
| { | |||
| public struct TriStateChannelPermissions | |||
| { | |||
| public static TriStateChannelPermissions InheritAll { get; } | |||
| public uint AllowValue { get; } | |||
| public uint DenyValue { get; } | |||
| public PermValue CreateInstantInvite { get; } | |||
| public PermValue ManagePermissions { get; } | |||
| public PermValue ManageChannel { get; } | |||
| public PermValue ReadMessages { get; } | |||
| public PermValue SendMessages { get; } | |||
| public PermValue SendTTSMessages { get; } | |||
| public PermValue ManageMessages { get; } | |||
| public PermValue EmbedLinks { get; } | |||
| public PermValue AttachFiles { get; } | |||
| public PermValue ReadMessageHistory { get; } | |||
| public PermValue MentionEveryone { get; } | |||
| public PermValue Connect { get; } | |||
| public PermValue Speak { get; } | |||
| public PermValue MuteMembers { get; } | |||
| public PermValue DeafenMembers { get; } | |||
| public PermValue MoveMembers { get; } | |||
| public PermValue UseVoiceActivation { get; } | |||
| public TriStateChannelPermissions(PermValue? createInstantInvite = null, PermValue? managePermissions = null, | |||
| PermValue? manageChannel = null, PermValue? readMessages = null, PermValue? sendMessages = null, PermValue? sendTTSMessages = null, | |||
| PermValue? manageMessages = null, PermValue? embedLinks = null, PermValue? attachFiles = null, PermValue? readMessageHistory = null, | |||
| PermValue? mentionEveryone = null, PermValue? connect = null, PermValue? speak = null, PermValue? muteMembers = null, PermValue? deafenMembers = null, | |||
| PermValue? moveMembers = null, PermValue? useVoiceActivation = null) | |||
| : this() | |||
| { | |||
| } | |||
| public TriStateChannelPermissions(uint allow = 0, uint deny = 0) | |||
| : this() | |||
| { | |||
| } | |||
| public TriStateChannelPermissions Modify(PermValue? createInstantInvite = null, PermValue? managePermissions = null, | |||
| PermValue? manageChannel = null, PermValue? readMessages = null, PermValue? sendMessages = null, PermValue? sendTTSMessages = null, | |||
| PermValue? manageMessages = null, PermValue? embedLinks = null, PermValue? attachFiles = null, PermValue? readMessageHistory = null, | |||
| PermValue? mentionEveryone = null, PermValue? connect = null, PermValue? speak = null, PermValue? muteMembers = null, PermValue? deafenMembers = null, | |||
| PermValue? moveMembers = null, PermValue? useVoiceActivation = null) | |||
| => default(TriStateChannelPermissions); | |||
| } | |||
| } | |||
| @@ -0,0 +1,23 @@ | |||
| using System.Threading.Tasks; | |||
| namespace Discord | |||
| { | |||
| public class Profile : IModel<ulong> | |||
| { | |||
| public DiscordClient Client { get; } | |||
| public ulong Id { get; } | |||
| public string AvatarId { get; } | |||
| public string AvatarUrl { get; } | |||
| public ushort Discriminator { get; } | |||
| public string CurrentGame { get; } | |||
| public UserStatus Status { get; } | |||
| public string Mention { get; } | |||
| public string Email { get; } | |||
| public bool? IsVerified { get; } | |||
| public string Name { get; set; } | |||
| public Task Save() => null; | |||
| } | |||
| } | |||
| @@ -0,0 +1,20 @@ | |||
| namespace Discord | |||
| { | |||
| public class Region | |||
| { | |||
| public string Id { get; } | |||
| public string Name { get; } | |||
| public string Hostname { get; } | |||
| public int Port { get; } | |||
| public bool Vip { get; } | |||
| internal Region(string id, string name, string hostname, int port, bool vip) | |||
| { | |||
| Id = id; | |||
| Name = name; | |||
| Hostname = hostname; | |||
| Port = port; | |||
| Vip = vip; | |||
| } | |||
| } | |||
| } | |||
| @@ -0,0 +1,29 @@ | |||
| using System.Collections.Generic; | |||
| using System.Threading.Tasks; | |||
| namespace Discord | |||
| { | |||
| public class Role : IModel<ulong>, IMentionable | |||
| { | |||
| public DiscordClient Client { get; } | |||
| public ulong Id { get; } | |||
| public Server Server { get; } | |||
| public string Name { get; } | |||
| public bool IsHoisted { get; } | |||
| public int Position { get; } | |||
| public bool IsManaged { get; } | |||
| public ServerPermissions Permissions { get; } | |||
| public Color Color { get; } | |||
| public bool IsEveryone { get; } | |||
| public IEnumerable<User> Members { get; } | |||
| public string Mention { get; } | |||
| public Task Delete() => null; | |||
| public Task Save() => null; | |||
| } | |||
| } | |||
| @@ -0,0 +1,70 @@ | |||
| using System; | |||
| using System.Collections.Generic; | |||
| using System.Threading.Tasks; | |||
| namespace Discord | |||
| { | |||
| public class Server : IModel<ulong> | |||
| { | |||
| public class Emoji | |||
| { | |||
| public string Id { get; } | |||
| public string Name { get; } | |||
| public bool IsManaged { get; } | |||
| public bool RequireColons { get; } | |||
| public IEnumerable<Role> Roles { get; } | |||
| } | |||
| public ulong Id { get; } | |||
| public User CurrentUser { get; } | |||
| public string IconId { get; } | |||
| public string SplashId { get; } | |||
| public string IconUrl { get; } | |||
| public string SplashUrl { get; } | |||
| public int ChannelCount { get; } | |||
| public int UserCount { get; } | |||
| public int RoleCount { get; } | |||
| public TextChannel DefaultChannel { get; } | |||
| public Role EveryoneRole { get; } | |||
| public IEnumerable<string> Features { get; } | |||
| public IEnumerable<Emoji> CustomEmojis { get; } | |||
| public IEnumerable<Channel> Channels { get; } | |||
| public IEnumerable<TextChannel> TextChannels { get; } | |||
| public IEnumerable<VoiceChannel> VoiceChannels { get; } | |||
| public IEnumerable<User> 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 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 Leave() => null; | |||
| public Task Delete() => null; | |||
| public Task Save() => null; | |||
| public Task<Channel> CreateChannel(string name, ChannelType type) => null; | |||
| public Task<Invite> CreateInvite(int? maxAge = 1800, int? maxUses = null, bool tempMembership = false, bool withXkcd = false) => null; | |||
| public Task<Role> CreateRole(string name, ServerPermissions? permissions = null, Color color = null, bool isHoisted = false) => null; | |||
| public Task Ban(User user, int pruneDays = 0) => null; | |||
| public Task Unban(User user) => null; | |||
| public Task Unban(ulong userId) => null; | |||
| public Task ReorderChannels(IEnumerable<Channel> channels) => null; | |||
| public Task ReorderRoles(IEnumerable<Role> roles, Role after = null) => null; | |||
| public Task<int> PruneUsers(int days = 30, bool simulate = false) => null; | |||
| } | |||
| } | |||
| @@ -0,0 +1,55 @@ | |||
| using System; | |||
| using System.Collections.Generic; | |||
| using System.IO; | |||
| using System.Threading.Tasks; | |||
| namespace Discord | |||
| { | |||
| public class User : IModel<ulong> | |||
| { | |||
| public DiscordClient Client { get; } | |||
| public ulong Id { 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 Channel PrivateChannel => null; | |||
| 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 Channel VoiceChannel => null; | |||
| public string AvatarUrl => null; | |||
| public IEnumerable<Role> Roles => null; | |||
| public IEnumerable<Channel> Channels => null; | |||
| public Task Kick() => null; | |||
| public ServerPermissions ServerPermissions => default(ServerPermissions); | |||
| public ChannelPermissions GetPermissions(Channel channel) => default(ChannelPermissions); | |||
| public Task<Channel> CreatePMChannel() => 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 Save() => null; | |||
| } | |||
| } | |||
| @@ -0,0 +1,8 @@ | |||
| namespace Discord | |||
| { | |||
| public enum ChannelType | |||
| { | |||
| Text, | |||
| Voice | |||
| } | |||
| } | |||
| @@ -0,0 +1,10 @@ | |||
| namespace Discord | |||
| { | |||
| public enum ConnectionState | |||
| { | |||
| Disconnected, | |||
| Connecting, | |||
| Connected, | |||
| Disconnecting | |||
| } | |||
| } | |||
| @@ -0,0 +1,9 @@ | |||
| namespace Discord | |||
| { | |||
| public enum ImageType | |||
| { | |||
| None, | |||
| Jpeg, | |||
| Png | |||
| } | |||
| } | |||
| @@ -0,0 +1,11 @@ | |||
| namespace Discord | |||
| { | |||
| public enum LogSeverity | |||
| { | |||
| Error = 1, | |||
| Warning = 2, | |||
| Info = 3, | |||
| Verbose = 4, | |||
| Debug = 5 | |||
| } | |||
| } | |||
| @@ -0,0 +1,18 @@ | |||
| namespace Discord | |||
| { | |||
| public enum MessageState : byte | |||
| { | |||
| /// <summary> Message did not originate from this session, or was successfully sent. </summary> | |||
| Normal = 0, | |||
| /// <summary> Message is current queued. </summary> | |||
| Queued, | |||
| /// <summary> Message was deleted. </summary> | |||
| Deleted, | |||
| /// <summary> Message was deleted before it was sent. </summary> | |||
| Aborted, | |||
| /// <summary> Message failed to be sent. </summary> | |||
| Failed, | |||
| /// <summary> Message has been removed from cache and will no longer receive updates. </summary> | |||
| Detached | |||
| } | |||
| } | |||
| @@ -0,0 +1,9 @@ | |||
| namespace Discord | |||
| { | |||
| public enum PermValue | |||
| { | |||
| Allow, | |||
| Deny, | |||
| Inherit | |||
| } | |||
| } | |||
| @@ -0,0 +1,31 @@ | |||
| namespace Discord | |||
| { | |||
| internal enum PermissionBits | |||
| { | |||
| //General | |||
| CreateInstantInvite = 0, | |||
| KickMembers = 1, | |||
| BanMembers = 2, | |||
| ManageRolesOrPermissions = 3, | |||
| ManageChannel = 4, | |||
| ManageServer = 5, | |||
| //Text | |||
| ReadMessages = 10, | |||
| SendMessages = 11, | |||
| SendTTSMessages = 12, | |||
| ManageMessages = 13, | |||
| EmbedLinks = 14, | |||
| AttachFiles = 15, | |||
| ReadMessageHistory = 16, | |||
| MentionEveryone = 17, | |||
| //Voice | |||
| Connect = 20, | |||
| Speak = 21, | |||
| MuteMembers = 22, | |||
| DeafenMembers = 23, | |||
| MoveMembers = 24, | |||
| UseVoiceActivation = 25 | |||
| } | |||
| } | |||
| @@ -0,0 +1,8 @@ | |||
| namespace Discord | |||
| { | |||
| public enum PermissionTarget | |||
| { | |||
| Role, | |||
| User | |||
| } | |||
| } | |||
| @@ -0,0 +1,8 @@ | |||
| namespace Discord | |||
| { | |||
| public enum Relative | |||
| { | |||
| Before, | |||
| After | |||
| } | |||
| } | |||
| @@ -0,0 +1,9 @@ | |||
| namespace Discord | |||
| { | |||
| public enum UserStatus | |||
| { | |||
| Online, | |||
| Idle, | |||
| Offline | |||
| } | |||
| } | |||
| @@ -0,0 +1,10 @@ | |||
| using System; | |||
| namespace Discord | |||
| { | |||
| public class ChannelEventArgs : EventArgs | |||
| { | |||
| public Channel Channel => null; | |||
| public Server Server => null; | |||
| } | |||
| } | |||
| @@ -0,0 +1,11 @@ | |||
| using System; | |||
| namespace Discord | |||
| { | |||
| public class ChannelUpdatedEventArgs : EventArgs | |||
| { | |||
| public Channel Before => null; | |||
| public Channel After => null; | |||
| public Server Server => null; | |||
| } | |||
| } | |||
| @@ -0,0 +1,8 @@ | |||
| namespace Discord | |||
| { | |||
| public class ChannelUserEventArgs | |||
| { | |||
| public Channel Channel => null; | |||
| public User User => null; | |||
| } | |||
| } | |||
| @@ -0,0 +1,10 @@ | |||
| using System; | |||
| namespace Discord | |||
| { | |||
| public class DisconnectedEventArgs : EventArgs | |||
| { | |||
| public bool WasUnexpected => false; | |||
| public Exception Exception => null; | |||
| } | |||
| } | |||
| @@ -0,0 +1,12 @@ | |||
| using System; | |||
| namespace Discord | |||
| { | |||
| public class LogMessageEventArgs : EventArgs | |||
| { | |||
| public LogSeverity Severity => default(LogSeverity); | |||
| public string Source => null; | |||
| public string Message => null; | |||
| public Exception Exception => null; | |||
| } | |||
| } | |||
| @@ -0,0 +1,12 @@ | |||
| using System; | |||
| namespace Discord | |||
| { | |||
| public class MessageEventArgs : EventArgs | |||
| { | |||
| public Message Message => null; | |||
| public User User => null; | |||
| public Channel Channel => null; | |||
| public Server Server => null; | |||
| } | |||
| } | |||
| @@ -0,0 +1,13 @@ | |||
| using System; | |||
| namespace Discord | |||
| { | |||
| public class MessageUpdatedEventArgs : EventArgs | |||
| { | |||
| public Message Before => null; | |||
| public Message After => null; | |||
| public User User => null; | |||
| public Channel Channel => null; | |||
| public Server Server => null; | |||
| } | |||
| } | |||
| @@ -0,0 +1,10 @@ | |||
| using System; | |||
| namespace Discord | |||
| { | |||
| public class ProfileUpdatedEventArgs : EventArgs | |||
| { | |||
| public Profile Before => null; | |||
| public Profile After => null; | |||
| } | |||
| } | |||
| @@ -0,0 +1,10 @@ | |||
| using System; | |||
| namespace Discord | |||
| { | |||
| public class RoleEventArgs : EventArgs | |||
| { | |||
| public Role Role => null; | |||
| public Server Server => null; | |||
| } | |||
| } | |||
| @@ -0,0 +1,11 @@ | |||
| using System; | |||
| namespace Discord | |||
| { | |||
| public class RoleUpdatedEventArgs : EventArgs | |||
| { | |||
| public Role Before => null; | |||
| public Role After => null; | |||
| public Server Server => null; | |||
| } | |||
| } | |||
| @@ -0,0 +1,9 @@ | |||
| using System; | |||
| namespace Discord | |||
| { | |||
| public class ServerEventArgs : EventArgs | |||
| { | |||
| public Server Server => null; | |||
| } | |||
| } | |||
| @@ -0,0 +1,10 @@ | |||
| using System; | |||
| namespace Discord | |||
| { | |||
| public class ServerUpdatedEventArgs : EventArgs | |||
| { | |||
| public Server Before => null; | |||
| public Server After => null; | |||
| } | |||
| } | |||
| @@ -0,0 +1,9 @@ | |||
| using System; | |||
| namespace Discord | |||
| { | |||
| public class UserEventArgs : EventArgs | |||
| { | |||
| public User User => null; | |||
| public Server Server => null; | |||
| } | |||
| } | |||
| @@ -0,0 +1,10 @@ | |||
| using System; | |||
| namespace Discord | |||
| { | |||
| public class UserUpdatedEventArgs : EventArgs | |||
| { | |||
| public User Before => null; | |||
| public User After => null; | |||
| public Server Server => null; | |||
| } | |||
| } | |||
| @@ -0,0 +1,14 @@ | |||
| namespace Discord | |||
| { | |||
| public static class Format | |||
| { | |||
| public static string Escape(string text) => null; | |||
| public static string Bold(string text, bool escape = true) => null; | |||
| public static string Italics(string text, bool escape = true) => null; | |||
| public static string Underline(string text, bool escape = true) => null; | |||
| public static string Strikeout(string text, bool escape = true) => null; | |||
| public static string Code(string text, string language = null) => null; | |||
| } | |||
| } | |||
| @@ -0,0 +1,30 @@ | |||
| using System; | |||
| namespace Discord.Logging | |||
| { | |||
| public interface ILogger | |||
| { | |||
| LogSeverity Level { get; } | |||
| void Log(LogSeverity severity, string message, Exception exception = null); | |||
| void Error(string message, Exception exception = null); | |||
| void Error(Exception exception); | |||
| void Warning(string message, Exception exception = null); | |||
| void Warning(Exception exception); | |||
| void Info(string message, Exception exception = null); | |||
| void Info(Exception exception); | |||
| void Verbose(string message, Exception exception = null); | |||
| void Verbose(Exception exception); | |||
| void Debug(string message, Exception exception = null); | |||
| void Debug(Exception exception); | |||
| #if DOTNET5_4 | |||
| void Log(LogSeverity severity, FormattableString message, Exception exception = null); | |||
| void Error(FormattableString message, Exception exception = null); | |||
| void Warning(FormattableString message, Exception exception = null); | |||
| void Info(FormattableString message, Exception exception = null); | |||
| void Verbose(FormattableString message, Exception exception = null); | |||
| void Debug(FormattableString message, Exception exception = null); | |||
| #endif | |||
| } | |||
| } | |||
| @@ -0,0 +1,9 @@ | |||
| namespace Discord.Net | |||
| { | |||
| public class MessageQueue | |||
| { | |||
| public int Count { get; } | |||
| public void Clear() { } | |||
| } | |||
| } | |||
| @@ -0,0 +1,16 @@ | |||
| using System; | |||
| using System.Net; | |||
| namespace Discord.Net | |||
| { | |||
| public class HttpException : Exception | |||
| { | |||
| public HttpStatusCode StatusCode { get; } | |||
| public HttpException(HttpStatusCode statusCode) | |||
| : base($"The server responded with error {(int)statusCode} ({statusCode})") | |||
| { | |||
| StatusCode = statusCode; | |||
| } | |||
| } | |||
| } | |||
| @@ -0,0 +1,17 @@ | |||
| namespace Discord.Net.Rest | |||
| { | |||
| public class CompletedRequestEventArgs : RequestEventArgs | |||
| { | |||
| public object Response { get; set; } | |||
| public string ResponseJson { get; set; } | |||
| public double Milliseconds { get; set; } | |||
| public CompletedRequestEventArgs(IRestRequest request, object response, string responseJson, double milliseconds) | |||
| : base(request) | |||
| { | |||
| Response = response; | |||
| ResponseJson = responseJson; | |||
| Milliseconds = milliseconds; | |||
| } | |||
| } | |||
| } | |||
| @@ -0,0 +1,23 @@ | |||
| namespace Discord.Net.Rest | |||
| { | |||
| public interface IRestRequest | |||
| { | |||
| string Method { get; } | |||
| string Endpoint { get; } | |||
| object Payload { get; } | |||
| } | |||
| public interface IRestRequest<ResponseT> : IRestRequest | |||
| where ResponseT : class | |||
| { | |||
| } | |||
| public interface IRestFileRequest : IRestRequest | |||
| { | |||
| string Filename { get; } | |||
| Stream Stream { get; } | |||
| } | |||
| public interface IRestFileRequest<ResponseT> : IRestFileRequest, IRestRequest<Message> | |||
| where ResponseT : class | |||
| { | |||
| } | |||
| } | |||
| @@ -0,0 +1,12 @@ | |||
| using System; | |||
| namespace Discord.Net.Rest | |||
| { | |||
| public class RequestEventArgs : EventArgs | |||
| { | |||
| public IRestRequest Request { get; set; } | |||
| public bool Cancel { get; set; } | |||
| public RequestEventArgs(IRestRequest request) { } | |||
| } | |||
| } | |||
| @@ -0,0 +1,25 @@ | |||
| using System; | |||
| using System.Threading; | |||
| using System.Threading.Tasks; | |||
| namespace Discord.Net.Rest | |||
| { | |||
| public abstract partial class RestClient | |||
| { | |||
| public event EventHandler<RequestEventArgs> SendingRequest = delegate { }; | |||
| public event EventHandler<CompletedRequestEventArgs> SentRequest = delegate { }; | |||
| public CancellationToken CancelToken { get; set; } | |||
| public string Token { get; set; } | |||
| public Task<ResponseT> Send<ResponseT>(IRestRequest<ResponseT> request) | |||
| where ResponseT : class | |||
| => null; | |||
| public Task Send(IRestRequest request) => null; | |||
| public Task<ResponseT> Send<ResponseT>(IRestFileRequest<ResponseT> request) | |||
| where ResponseT : class | |||
| => null; | |||
| public Task Send(IRestFileRequest request) => null; | |||
| } | |||
| } | |||
| @@ -0,0 +1,9 @@ | |||
| using System; | |||
| namespace Discord.Net | |||
| { | |||
| public class TimeoutException : OperationCanceledException | |||
| { | |||
| public TimeoutException() { } | |||
| } | |||
| } | |||
| @@ -0,0 +1,12 @@ | |||
| using System; | |||
| namespace Discord.Net | |||
| { | |||
| public class WebSocketException : Exception | |||
| { | |||
| public int Code { get; } | |||
| public string Reason { get; } | |||
| public WebSocketException(int code, string reason) { } | |||
| } | |||
| } | |||
| @@ -0,0 +1,11 @@ | |||
| using System; | |||
| namespace Discord.Net.WebSockets | |||
| { | |||
| public class BinaryMessageEventArgs : EventArgs | |||
| { | |||
| public byte[] Data { get; } | |||
| public BinaryMessageEventArgs(byte[] data) { } | |||
| } | |||
| } | |||
| @@ -0,0 +1,31 @@ | |||
| using Discord.Logging; | |||
| using Discord.Net.Rest; | |||
| using System; | |||
| using System.Collections.Generic; | |||
| using System.Threading; | |||
| using System.Threading.Tasks; | |||
| namespace Discord.Net.WebSockets | |||
| { | |||
| public class GatewaySocket : WebSocket | |||
| { | |||
| public string SessionId { get; private set; } | |||
| public event EventHandler<WebSocketEventEventArgs> ReceivedDispatch = delegate { }; | |||
| public GatewaySocket(DiscordConfig config, ILogger logger) : base(config, logger) { } | |||
| public Task Connect(RestClient rest, CancellationToken parentCancelToken) => null; | |||
| public Task Disconnect() => null; | |||
| public void SendIdentify(string token) { } | |||
| public void SendResume() { } | |||
| public override void SendHeartbeat() { } | |||
| public void SendUpdateStatus(long? idleSince, string gameName) { } | |||
| public void SendUpdateVoice(ulong? serverId, ulong? channelId, bool isSelfMuted, bool isSelfDeafened) { } | |||
| public void SendRequestMembers(IEnumerable<ulong> serverId, string query, int limit) { } | |||
| public override void WaitForConnection(CancellationToken cancelToken) { } | |||
| } | |||
| } | |||
| @@ -0,0 +1,18 @@ | |||
| using System; | |||
| using System.Collections.Generic; | |||
| using System.Threading; | |||
| using System.Threading.Tasks; | |||
| namespace Discord.Net.WebSockets | |||
| { | |||
| public interface IWebSocketEngine | |||
| { | |||
| event EventHandler<BinaryMessageEventArgs> BinaryMessage; | |||
| event EventHandler<TextMessageEventArgs> TextMessage; | |||
| Task Connect(string host, CancellationToken cancelToken); | |||
| Task Disconnect(); | |||
| void QueueMessage(string message); | |||
| IEnumerable<Task> GetTasks(CancellationToken cancelToken); | |||
| } | |||
| } | |||
| @@ -0,0 +1,11 @@ | |||
| using System; | |||
| namespace Discord.Net.WebSockets | |||
| { | |||
| public class TextMessageEventArgs : EventArgs | |||
| { | |||
| public string Message { get; } | |||
| public TextMessageEventArgs(string msg) { Message = msg; } | |||
| } | |||
| } | |||
| @@ -0,0 +1,22 @@ | |||
| using Discord.Logging; | |||
| using System; | |||
| using System.Threading; | |||
| namespace Discord.Net.WebSockets | |||
| { | |||
| public abstract partial class WebSocket | |||
| { | |||
| public CancellationToken CancelToken { get; } | |||
| public ConnectionState State { get; } | |||
| public string Host { get; } | |||
| public event EventHandler Connected = delegate { }; | |||
| public event EventHandler<DisconnectedEventArgs> Disconnected = delegate { }; | |||
| public WebSocket(DiscordConfig config, ILogger logger) { } | |||
| public abstract void SendHeartbeat(); | |||
| public virtual void WaitForConnection(CancellationToken cancelToken) { } | |||
| } | |||
| } | |||
| @@ -0,0 +1,17 @@ | |||
| using Newtonsoft.Json.Linq; | |||
| using System; | |||
| namespace Discord.Net.WebSockets | |||
| { | |||
| public class WebSocketEventEventArgs : EventArgs | |||
| { | |||
| public string Type { get; } | |||
| public JToken Payload { get; } | |||
| internal WebSocketEventEventArgs(string type, JToken data) | |||
| { | |||
| Type = type; | |||
| Payload = data; | |||
| } | |||
| } | |||
| } | |||
| @@ -0,0 +1,81 @@ | |||
| { | |||
| "version": "0.9.0-rc3-3", | |||
| "description": "An unofficial .Net API wrapper for the Discord client.", | |||
| "authors": [ | |||
| "RogueException" | |||
| ], | |||
| "tags": [ | |||
| "discord", | |||
| "discordapp" | |||
| ], | |||
| "projectUrl": "https://github.com/RogueException/Discord.Net", | |||
| "licenseUrl": "http://opensource.org/licenses/MIT", | |||
| "repository": { | |||
| "type": "git", | |||
| "url": "git://github.com/RogueException/Discord.Net" | |||
| }, | |||
| "compile": [ "**/*.cs", "../Discord.Net.Shared/*.cs" ], | |||
| "compilationOptions": { | |||
| "allowUnsafe": true, | |||
| "warningsAsErrors": true | |||
| }, | |||
| "configurations": { | |||
| "TestResponses": { | |||
| "compilationOptions": { | |||
| "define": [ | |||
| "DEBUG", | |||
| "TRACE", | |||
| "TEST_RESPONSES" | |||
| ] | |||
| } | |||
| } | |||
| }, | |||
| "dependencies": { | |||
| "Newtonsoft.Json": "8.0.1", | |||
| "Nito.AsyncEx": "3.0.1" | |||
| }, | |||
| "frameworks": { | |||
| "dotnet5.4": { | |||
| "dependencies": { | |||
| "System.Collections": "4.0.11-beta-23516", | |||
| "System.Collections.Concurrent": "4.0.11-beta-23516", | |||
| "System.Dynamic.Runtime": "4.0.11-beta-23516", | |||
| "System.IO.FileSystem": "4.0.1-beta-23516", | |||
| "System.IO.Compression": "4.1.0-beta-23516", | |||
| "System.Linq": "4.0.1-beta-23516", | |||
| "System.Net.Http": "4.0.1-beta-23516", | |||
| "System.Net.NameResolution": "4.0.0-beta-23516", | |||
| "System.Net.Sockets": "4.1.0-beta-23409", | |||
| "System.Net.Requests": "4.0.11-beta-23516", | |||
| "System.Net.WebSockets.Client": "4.0.0-beta-23516", | |||
| "System.Reflection": "4.1.0-beta-23516", | |||
| "System.Reflection.Emit.Lightweight": "4.0.1-beta-23516", | |||
| "System.Runtime.InteropServices": "4.0.21-beta-23516", | |||
| "System.Runtime.Serialization.Primitives": "4.1.0-beta-23516", | |||
| "System.Security.Cryptography.Algorithms": "4.0.0-beta-23516", | |||
| "System.Text.RegularExpressions": "4.0.11-beta-23516", | |||
| "System.Threading": "4.0.11-beta-23516" | |||
| } | |||
| }, | |||
| "net45": { | |||
| "frameworkAssemblies": { | |||
| "System.Runtime": { | |||
| "type": "build", | |||
| "version": "" | |||
| }, | |||
| "System.Threading.Tasks": { | |||
| "type": "build", | |||
| "version": "" | |||
| } | |||
| }, | |||
| "dependencies": { | |||
| "WebSocket4Net": "0.14.1", | |||
| "RestSharp": "105.2.3" | |||
| } | |||
| } | |||
| } | |||
| } | |||