Browse Source

1.0 REST Preview 2

tags/1.0-rc
RogueException 9 years ago
parent
commit
b45a0ebe6e
100 changed files with 943 additions and 1229 deletions
  1. +7
    -46
      Discord.Net.sln
  2. +0
    -8
      NuGet.config
  3. +0
    -6
      global.json
  4. +2
    -2
      src/Discord.Net/API/CDN.cs
  5. +2
    -2
      src/Discord.Net/API/Common/Channel.cs
  6. +8
    -6
      src/Discord.Net/API/Common/Connection.cs
  7. +2
    -0
      src/Discord.Net/API/Common/Guild.cs
  8. +2
    -0
      src/Discord.Net/API/Common/GuildMember.cs
  9. +0
    -0
      src/Discord.Net/API/Common/Overwrite.cs
  10. +0
    -23
      src/Discord.Net/API/Common/Unconfirmed/ExtendedGuild.cs
  11. +0
    -12
      src/Discord.Net/API/Common/Unconfirmed/ExtendedMember.cs
  12. +0
    -14
      src/Discord.Net/API/Common/Unconfirmed/MemberPresence.cs
  13. +0
    -10
      src/Discord.Net/API/Common/Unconfirmed/MemberPresenceGame.cs
  14. +0
    -12
      src/Discord.Net/API/Common/Unconfirmed/MemberReference.cs
  15. +0
    -14
      src/Discord.Net/API/Common/Unconfirmed/MessageReference.cs
  16. +0
    -12
      src/Discord.Net/API/Common/Unconfirmed/RoleReference.cs
  17. +2
    -0
      src/Discord.Net/API/Common/UserGuild.cs
  18. +3
    -11
      src/Discord.Net/API/Common/VoiceRegion.cs
  19. +12
    -16
      src/Discord.Net/API/Common/VoiceState.cs
  20. +785
    -0
      src/Discord.Net/API/DiscordRawClient.cs
  21. +0
    -26
      src/Discord.Net/API/GatewaySocket/OpCode.cs
  22. +0
    -12
      src/Discord.Net/API/GatewaySocket/Unconfirmed/Commands/Heartbeat.cs
  23. +0
    -23
      src/Discord.Net/API/GatewaySocket/Unconfirmed/Commands/Identify.cs
  24. +0
    -18
      src/Discord.Net/API/GatewaySocket/Unconfirmed/Commands/RequestMembers.cs
  25. +0
    -16
      src/Discord.Net/API/GatewaySocket/Unconfirmed/Commands/Resume.cs
  26. +0
    -22
      src/Discord.Net/API/GatewaySocket/Unconfirmed/Commands/UpdateStatus.cs
  27. +0
    -20
      src/Discord.Net/API/GatewaySocket/Unconfirmed/Commands/UpdateVoice.cs
  28. +0
    -4
      src/Discord.Net/API/GatewaySocket/Unconfirmed/Events/ChannelCreate.cs
  29. +0
    -4
      src/Discord.Net/API/GatewaySocket/Unconfirmed/Events/ChannelDelete.cs
  30. +0
    -4
      src/Discord.Net/API/GatewaySocket/Unconfirmed/Events/ChannelUpdate.cs
  31. +0
    -4
      src/Discord.Net/API/GatewaySocket/Unconfirmed/Events/GuildBanAdd.cs
  32. +0
    -4
      src/Discord.Net/API/GatewaySocket/Unconfirmed/Events/GuildBanRemove.cs
  33. +0
    -4
      src/Discord.Net/API/GatewaySocket/Unconfirmed/Events/GuildCreate.cs
  34. +0
    -4
      src/Discord.Net/API/GatewaySocket/Unconfirmed/Events/GuildDelete.cs
  35. +0
    -4
      src/Discord.Net/API/GatewaySocket/Unconfirmed/Events/GuildMemberAdd.cs
  36. +0
    -4
      src/Discord.Net/API/GatewaySocket/Unconfirmed/Events/GuildMemberRemove.cs
  37. +0
    -4
      src/Discord.Net/API/GatewaySocket/Unconfirmed/Events/GuildMemberUpdate.cs
  38. +0
    -12
      src/Discord.Net/API/GatewaySocket/Unconfirmed/Events/GuildMembersChunk.cs
  39. +0
    -12
      src/Discord.Net/API/GatewaySocket/Unconfirmed/Events/GuildRoleCreate.cs
  40. +0
    -4
      src/Discord.Net/API/GatewaySocket/Unconfirmed/Events/GuildRoleDelete.cs
  41. +0
    -12
      src/Discord.Net/API/GatewaySocket/Unconfirmed/Events/GuildRoleUpdate.cs
  42. +0
    -4
      src/Discord.Net/API/GatewaySocket/Unconfirmed/Events/GuildUpdate.cs
  43. +0
    -4
      src/Discord.Net/API/GatewaySocket/Unconfirmed/Events/MessageAck.cs
  44. +0
    -4
      src/Discord.Net/API/GatewaySocket/Unconfirmed/Events/MessageCreate.cs
  45. +0
    -4
      src/Discord.Net/API/GatewaySocket/Unconfirmed/Events/MessageDelete.cs
  46. +0
    -4
      src/Discord.Net/API/GatewaySocket/Unconfirmed/Events/MessageUpdate.cs
  47. +0
    -4
      src/Discord.Net/API/GatewaySocket/Unconfirmed/Events/PresenceUpdate.cs
  48. +0
    -40
      src/Discord.Net/API/GatewaySocket/Unconfirmed/Events/Ready.cs
  49. +0
    -10
      src/Discord.Net/API/GatewaySocket/Unconfirmed/Events/Resumed.cs
  50. +0
    -14
      src/Discord.Net/API/GatewaySocket/Unconfirmed/Events/TypingStart.cs
  51. +0
    -4
      src/Discord.Net/API/GatewaySocket/Unconfirmed/Events/UserUpdate.cs
  52. +0
    -14
      src/Discord.Net/API/GatewaySocket/Unconfirmed/Events/VoiceServerUpdate.cs
  53. +0
    -4
      src/Discord.Net/API/GatewaySocket/Unconfirmed/Events/VoiceStateUpdate.cs
  54. +0
    -28
      src/Discord.Net/API/IWebSocketMessage.cs
  55. +0
    -18
      src/Discord.Net/API/Rest/AcceptInvite.cs
  56. +0
    -20
      src/Discord.Net/API/Rest/AckMessage.cs
  57. +0
    -23
      src/Discord.Net/API/Rest/BeginGuildPrune.cs
  58. +0
    -29
      src/Discord.Net/API/Rest/CreateChannelInvite.cs
  59. +16
    -0
      src/Discord.Net/API/Rest/CreateChannelInviteParams.cs
  60. +0
    -16
      src/Discord.Net/API/Rest/CreateDMChannel.cs
  61. +10
    -0
      src/Discord.Net/API/Rest/CreateDMChannelParams.cs
  62. +0
    -24
      src/Discord.Net/API/Rest/CreateGuildBan.cs
  63. +10
    -0
      src/Discord.Net/API/Rest/CreateGuildBanParams.cs
  64. +0
    -27
      src/Discord.Net/API/Rest/CreateGuildChannel.cs
  65. +14
    -0
      src/Discord.Net/API/Rest/CreateGuildChannelParams.cs
  66. +0
    -25
      src/Discord.Net/API/Rest/CreateGuildIntegration.cs
  67. +12
    -0
      src/Discord.Net/API/Rest/CreateGuildIntegrationParams.cs
  68. +2
    -8
      src/Discord.Net/API/Rest/CreateGuildParams.cs
  69. +0
    -18
      src/Discord.Net/API/Rest/CreateGuildRole.cs
  70. +0
    -27
      src/Discord.Net/API/Rest/CreateMessage.cs
  71. +14
    -0
      src/Discord.Net/API/Rest/CreateMessageParams.cs
  72. +0
    -18
      src/Discord.Net/API/Rest/DeleteChannel.cs
  73. +0
    -20
      src/Discord.Net/API/Rest/DeleteChannelPermission.cs
  74. +0
    -18
      src/Discord.Net/API/Rest/DeleteGuild.cs
  75. +0
    -20
      src/Discord.Net/API/Rest/DeleteGuildIntegration.cs
  76. +0
    -20
      src/Discord.Net/API/Rest/DeleteGuildRole.cs
  77. +0
    -18
      src/Discord.Net/API/Rest/DeleteInvite.cs
  78. +0
    -20
      src/Discord.Net/API/Rest/DeleteMessage.cs
  79. +11
    -0
      src/Discord.Net/API/Rest/DeleteMessagesParam.cs
  80. +0
    -18
      src/Discord.Net/API/Rest/GetChannel.cs
  81. +0
    -20
      src/Discord.Net/API/Rest/GetChannelInvites.cs
  82. +0
    -34
      src/Discord.Net/API/Rest/GetChannelMessages.cs
  83. +9
    -0
      src/Discord.Net/API/Rest/GetChannelMessagesParams.cs
  84. +0
    -11
      src/Discord.Net/API/Rest/GetCurrentUser.cs
  85. +0
    -11
      src/Discord.Net/API/Rest/GetCurrentUserConnections.cs
  86. +0
    -11
      src/Discord.Net/API/Rest/GetCurrentUserDMs.cs
  87. +0
    -11
      src/Discord.Net/API/Rest/GetCurrentUserGuilds.cs
  88. +0
    -18
      src/Discord.Net/API/Rest/GetGateway.cs
  89. +2
    -2
      src/Discord.Net/API/Rest/GetGatewayResponse.cs
  90. +0
    -18
      src/Discord.Net/API/Rest/GetGuild.cs
  91. +0
    -18
      src/Discord.Net/API/Rest/GetGuildBans.cs
  92. +0
    -18
      src/Discord.Net/API/Rest/GetGuildChannels.cs
  93. +0
    -18
      src/Discord.Net/API/Rest/GetGuildEmbed.cs
  94. +0
    -18
      src/Discord.Net/API/Rest/GetGuildIntegrations.cs
  95. +0
    -18
      src/Discord.Net/API/Rest/GetGuildInvites.cs
  96. +0
    -20
      src/Discord.Net/API/Rest/GetGuildMember.cs
  97. +8
    -0
      src/Discord.Net/API/Rest/GetGuildMembersParams.cs
  98. +0
    -29
      src/Discord.Net/API/Rest/GetGuildPruneCount.cs
  99. +10
    -0
      src/Discord.Net/API/Rest/GetGuildPruneCountResponse.cs
  100. +0
    -18
      src/Discord.Net/API/Rest/GetGuildRoles.cs

+ 7
- 46
Discord.Net.sln View File

@@ -1,61 +1,22 @@
 
Microsoft Visual Studio Solution File, Format Version 12.00 Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio 14
VisualStudioVersion = 14.0.25123.0
# Visual Studio 15
VisualStudioVersion = 15.0.25123.0
MinimumVisualStudioVersion = 10.0.40219.1 MinimumVisualStudioVersion = 10.0.40219.1
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "src", "src", "{8D7989F0-66CE-4DBB-8230-D8C811E9B1D7}"
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "netplatform", "netplatform", "{EA68EBE2-51C8-4440-9EF7-D633C90A5D35}"
EndProject
Project("{8BB2217D-0F2D-49D1-97BC-3654ED321F3B}") = "Discord.Net", "src\Discord.Net\Discord.Net.xproj", "{2C91BDD7-621D-460F-B768-EAD106D9BA62}"
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "test", "test", "{6317A2E6-8E36-4C3E-949B-3F10EC888AB9}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Discord.Net.Tests", "test\Discord.Net.Tests\Discord.Net.Tests.csproj", "{855D6B1D-847B-42DA-BE6A-23683EA89511}"
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution Items", "{1BE8AF3F-3CFD-433F-A380-D294A4F617C1}"
ProjectSection(SolutionItems) = preProject
global.json = global.json
EndProjectSection
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "net45", "net45", "{628A40F4-2D06-4BCE-82EF-0EE70DD5C1CA}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Discord.Net.Net45", "src\Discord.Net\Discord.Net.Net45.csproj", "{C6A50D24-CBD3-4E76-852C-4DCA60BBD608}"
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Discord.Net", "src\Discord.Net.csproj", "{18F6FE23-73F6-4CA6-BBD9-F0139DC3EE90}"
EndProject EndProject
Global Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU Debug|Any CPU = Debug|Any CPU
FullDebug|Any CPU = FullDebug|Any CPU
Release|Any CPU = Release|Any CPU Release|Any CPU = Release|Any CPU
EndGlobalSection EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution GlobalSection(ProjectConfigurationPlatforms) = postSolution
{2C91BDD7-621D-460F-B768-EAD106D9BA62}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{2C91BDD7-621D-460F-B768-EAD106D9BA62}.Debug|Any CPU.Build.0 = Debug|Any CPU
{2C91BDD7-621D-460F-B768-EAD106D9BA62}.FullDebug|Any CPU.ActiveCfg = Debug|Any CPU
{2C91BDD7-621D-460F-B768-EAD106D9BA62}.FullDebug|Any CPU.Build.0 = Debug|Any CPU
{2C91BDD7-621D-460F-B768-EAD106D9BA62}.Release|Any CPU.ActiveCfg = Release|Any CPU
{2C91BDD7-621D-460F-B768-EAD106D9BA62}.Release|Any CPU.Build.0 = Release|Any CPU
{855D6B1D-847B-42DA-BE6A-23683EA89511}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{855D6B1D-847B-42DA-BE6A-23683EA89511}.Debug|Any CPU.Build.0 = Debug|Any CPU
{855D6B1D-847B-42DA-BE6A-23683EA89511}.FullDebug|Any CPU.ActiveCfg = Debug|Any CPU
{855D6B1D-847B-42DA-BE6A-23683EA89511}.FullDebug|Any CPU.Build.0 = Debug|Any CPU
{855D6B1D-847B-42DA-BE6A-23683EA89511}.Release|Any CPU.ActiveCfg = Release|Any CPU
{855D6B1D-847B-42DA-BE6A-23683EA89511}.Release|Any CPU.Build.0 = Release|Any CPU
{C6A50D24-CBD3-4E76-852C-4DCA60BBD608}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{C6A50D24-CBD3-4E76-852C-4DCA60BBD608}.Debug|Any CPU.Build.0 = Debug|Any CPU
{C6A50D24-CBD3-4E76-852C-4DCA60BBD608}.FullDebug|Any CPU.ActiveCfg = Debug|Any CPU
{C6A50D24-CBD3-4E76-852C-4DCA60BBD608}.FullDebug|Any CPU.Build.0 = Debug|Any CPU
{C6A50D24-CBD3-4E76-852C-4DCA60BBD608}.Release|Any CPU.ActiveCfg = Release|Any CPU
{C6A50D24-CBD3-4E76-852C-4DCA60BBD608}.Release|Any CPU.Build.0 = Release|Any CPU
{18F6FE23-73F6-4CA6-BBD9-F0139DC3EE90}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{18F6FE23-73F6-4CA6-BBD9-F0139DC3EE90}.Debug|Any CPU.Build.0 = Debug|Any CPU
{18F6FE23-73F6-4CA6-BBD9-F0139DC3EE90}.Release|Any CPU.ActiveCfg = Release|Any CPU
{18F6FE23-73F6-4CA6-BBD9-F0139DC3EE90}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection EndGlobalSection
GlobalSection(SolutionProperties) = preSolution GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE HideSolutionNode = FALSE
EndGlobalSection EndGlobalSection
GlobalSection(NestedProjects) = preSolution
{EA68EBE2-51C8-4440-9EF7-D633C90A5D35} = {8D7989F0-66CE-4DBB-8230-D8C811E9B1D7}
{2C91BDD7-621D-460F-B768-EAD106D9BA62} = {EA68EBE2-51C8-4440-9EF7-D633C90A5D35}
{855D6B1D-847B-42DA-BE6A-23683EA89511} = {6317A2E6-8E36-4C3E-949B-3F10EC888AB9}
{628A40F4-2D06-4BCE-82EF-0EE70DD5C1CA} = {8D7989F0-66CE-4DBB-8230-D8C811E9B1D7}
{C6A50D24-CBD3-4E76-852C-4DCA60BBD608} = {628A40F4-2D06-4BCE-82EF-0EE70DD5C1CA}
EndGlobalSection
EndGlobal EndGlobal

+ 0
- 8
NuGet.config View File

@@ -1,8 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<packageSources>
<add key="AspNetCiDev" value="https://www.myget.org/F/aspnetcidev/api/v3/index.json" />
<add key="NuGet" value="https://api.nuget.org/v3/index.json" />
<add key="aspnet-contrib" value="https://www.myget.org/F/aspnet-contrib/api/v3/index.json" />
</packageSources>
</configuration>

+ 0
- 6
global.json View File

@@ -1,6 +0,0 @@
{
"projects": [ "src" ],
"sdk": {
"version": "1.0.0-rc2-20221"
}
}

src/Discord.Net/CDN.cs → src/Discord.Net/API/CDN.cs View File

@@ -1,8 +1,8 @@
namespace Discord
namespace Discord.API
{ {
internal static class CDN internal static class CDN
{ {
public static string GetUserAvatarUrl(ulong userId, string avatarId)
public static string GetUserAvatarUrl(ulong userId, string avatarId)
=> avatarId != null ? $"{DiscordConfig.ClientAPIUrl}users/{userId}/avatars/{avatarId}.jpg" : null; => avatarId != null ? $"{DiscordConfig.ClientAPIUrl}users/{userId}/avatars/{avatarId}.jpg" : null;
public static string GetGuildIconUrl(ulong guildId, string iconId) public static string GetGuildIconUrl(ulong guildId, string iconId)
=> iconId != null ? $"{DiscordConfig.ClientAPIUrl}guilds/{guildId}/icons/{iconId}.jpg" : null; => iconId != null ? $"{DiscordConfig.ClientAPIUrl}guilds/{guildId}/icons/{iconId}.jpg" : null;

+ 2
- 2
src/Discord.Net/API/Common/Channel.cs View File

@@ -14,11 +14,11 @@ namespace Discord.API


//GuildChannel //GuildChannel
[JsonProperty("guild_id")] [JsonProperty("guild_id")]
public ulong GuildId { get; set; }
public ulong? GuildId { get; set; }
[JsonProperty("name")] [JsonProperty("name")]
public string Name { get; set; } public string Name { get; set; }
[JsonProperty("type")] [JsonProperty("type")]
public string Type { get; set; }
public ChannelType Type { get; set; }
[JsonProperty("position")] [JsonProperty("position")]
public int Position { get; set; } public int Position { get; set; }
[JsonProperty("permission_overwrites")] [JsonProperty("permission_overwrites")]


src/Discord.Net/API/Common/Unconfirmed/Connection.cs → src/Discord.Net/API/Common/Connection.cs View File

@@ -1,18 +1,20 @@
using Newtonsoft.Json; using Newtonsoft.Json;
using System.Collections.Generic;


namespace Discord.API namespace Discord.API
{ {
public class Connection public class Connection
{ {
[JsonProperty("integrations")]
public Integration[] Integrations { get; set; }
[JsonProperty("revoked")]
public bool Revoked { get; set; }
[JsonProperty("type")]
public string Type { get; set; }
[JsonProperty("id")] [JsonProperty("id")]
public string Id { get; set; } public string Id { get; set; }
[JsonProperty("type")]
public string Type { get; set; }
[JsonProperty("name")] [JsonProperty("name")]
public string Name { get; set; } public string Name { get; set; }
[JsonProperty("revoked")]
public bool Revoked { get; set; }

[JsonProperty("integrations")]
public IEnumerable<ulong> Integrations { get; set; }
} }
} }

+ 2
- 0
src/Discord.Net/API/Common/Guild.cs View File

@@ -26,6 +26,8 @@ namespace Discord.API
public ulong? EmbedChannelId { get; set; } public ulong? EmbedChannelId { get; set; }
[JsonProperty("verification_level")] [JsonProperty("verification_level")]
public int VerificationLevel { get; set; } public int VerificationLevel { get; set; }
[JsonProperty("voice_states")]
public VoiceState[] VoiceStates { get; set; }
[JsonProperty("roles")] [JsonProperty("roles")]
public Role[] Roles { get; set; } public Role[] Roles { get; set; }
[JsonProperty("emojis")] [JsonProperty("emojis")]


+ 2
- 0
src/Discord.Net/API/Common/GuildMember.cs View File

@@ -7,6 +7,8 @@ namespace Discord.API
{ {
[JsonProperty("user")] [JsonProperty("user")]
public User User { get; set; } public User User { get; set; }
[JsonProperty("nick")]
public string Nick { get; set; }
[JsonProperty("roles")] [JsonProperty("roles")]
public ulong[] Roles { get; set; } public ulong[] Roles { get; set; }
[JsonProperty("joined_at")] [JsonProperty("joined_at")]


src/Discord.Net/API/Common/Unconfirmed/Overwrite.cs → src/Discord.Net/API/Common/Overwrite.cs View File


+ 0
- 23
src/Discord.Net/API/Common/Unconfirmed/ExtendedGuild.cs View File

@@ -1,23 +0,0 @@
using Newtonsoft.Json;

namespace Discord.API
{
public class ExtendedGuild : Guild
{
[JsonProperty("member_count")]
public int? MemberCount { get; set; }
[JsonProperty("large")]
public bool IsLarge { get; set; }
[JsonProperty("unavailable")]
public bool? Unavailable { get; set; }

[JsonProperty("channels")]
public Channel[] Channels { get; set; }
[JsonProperty("members")]
public ExtendedMember[] Members { get; set; }
[JsonProperty("presences")]
public MemberPresence[] Presences { get; set; }
[JsonProperty("voice_states")]
public MemberVoiceState[] VoiceStates { get; set; }
}
}

+ 0
- 12
src/Discord.Net/API/Common/Unconfirmed/ExtendedMember.cs View File

@@ -1,12 +0,0 @@
using Newtonsoft.Json;

namespace Discord.API
{
public class ExtendedMember : GuildMember
{
[JsonProperty("mute")]
public bool? IsMuted { get; set; }
[JsonProperty("deaf")]
public bool? IsDeafened { get; set; }
}
}

+ 0
- 14
src/Discord.Net/API/Common/Unconfirmed/MemberPresence.cs View File

@@ -1,14 +0,0 @@
using Newtonsoft.Json;

namespace Discord.API
{
public class MemberPresence : MemberReference
{
[JsonProperty("game")]
public MemberPresenceGame Game { get; set; }
[JsonProperty("status")]
public UserStatus Status { get; set; }
[JsonProperty("roles")]
public ulong[] Roles { get; set; }
}
}

+ 0
- 10
src/Discord.Net/API/Common/Unconfirmed/MemberPresenceGame.cs View File

@@ -1,10 +0,0 @@
using Newtonsoft.Json;

namespace Discord.API
{
public class MemberPresenceGame
{
[JsonProperty("name")]
public string Name { get; set; }
}
}

+ 0
- 12
src/Discord.Net/API/Common/Unconfirmed/MemberReference.cs View File

@@ -1,12 +0,0 @@
using Newtonsoft.Json;

namespace Discord.API
{
public class MemberReference
{
[JsonProperty("guild_id")]
public ulong? GuildId { get; set; }
[JsonProperty("user")]
public User User { get; set; }
}
}

+ 0
- 14
src/Discord.Net/API/Common/Unconfirmed/MessageReference.cs View File

@@ -1,14 +0,0 @@
using Newtonsoft.Json;

namespace Discord.API
{
public class MessageReference
{
[JsonProperty("id")]
public ulong Id { get; set; }
[JsonProperty("message_id")] //Only used in MESSAGE_ACK
public ulong MessageId { get { return Id; } set { Id = value; } }
[JsonProperty("channel_id")]
public ulong ChannelId { get; set; }
}
}

+ 0
- 12
src/Discord.Net/API/Common/Unconfirmed/RoleReference.cs View File

@@ -1,12 +0,0 @@
using Newtonsoft.Json;

namespace Discord.API
{
public class RoleReference
{
[JsonProperty("guild_id")]
public ulong GuildId { get; set; }
[JsonProperty("role_id")]
public ulong RoleId { get; set; }
}
}

+ 2
- 0
src/Discord.Net/API/Common/UserGuild.cs View File

@@ -12,5 +12,7 @@ namespace Discord.API
public string Icon { get; set; } public string Icon { get; set; }
[JsonProperty("owner")] [JsonProperty("owner")]
public bool Owner { get; set; } public bool Owner { get; set; }
[JsonProperty("permissions")]
public uint Permissions { get; set; }
} }
} }

src/Discord.Net/API/Rest/GetVoiceRegions.cs → src/Discord.Net/API/Common/VoiceRegion.cs View File

@@ -1,16 +1,8 @@
using Discord.Net.Rest;
using Newtonsoft.Json;
using Newtonsoft.Json;


namespace Discord.API.Rest
namespace Discord.API
{ {
public class GetVoiceRegionsRequest : IRestRequest<GetVoiceRegionsResponse[]>
{
string IRestRequest.Method => "GET";
string IRestRequest.Endpoint => $"voice/regions";
object IRestRequest.Payload => null;
}
public class GetVoiceRegionsResponse
public class VoiceRegion
{ {
[JsonProperty("id")] [JsonProperty("id")]
public string Id { get; set; } public string Id { get; set; }

src/Discord.Net/API/Common/Unconfirmed/MemberVoiceState.cs → src/Discord.Net/API/Common/VoiceState.cs View File

@@ -2,29 +2,25 @@


namespace Discord.API namespace Discord.API
{ {
public class MemberVoiceState
public class VoiceState
{ {
[JsonProperty("guild_id")] [JsonProperty("guild_id")]
public ulong GuildId { get; set; }
public ulong? GuildId { get; set; }
[JsonProperty("channel_id")]
public ulong ChannelId { get; set; }
[JsonProperty("user_id")] [JsonProperty("user_id")]
public ulong UserId { get; set; } public ulong UserId { get; set; }

[JsonProperty("channel_id")]
public ulong? ChannelId { get; set; }
[JsonProperty("session_id")] [JsonProperty("session_id")]
public string SessionId { get; set; } public string SessionId { get; set; }
[JsonProperty("token")]
public string Token { get; set; }

[JsonProperty("self_mute")]
public bool? IsSelfMuted { get; set; }
[JsonProperty("self_deaf")]
public bool? IsSelfDeafened { get; set; }
[JsonProperty("mute")]
public bool? IsMuted { get; set; }
[JsonProperty("deaf")] [JsonProperty("deaf")]
public bool? IsDeafened { get; set; }
public bool Deaf { get; set; }
[JsonProperty("mute")]
public bool Mute { get; set; }
[JsonProperty("self_deaf")]
public bool SelfDeaf { get; set; }
[JsonProperty("self_mute")]
public bool SelfMute { get; set; }
[JsonProperty("suppress")] [JsonProperty("suppress")]
public bool? IsSuppressed { get; set; }
public bool Suppress { get; set; }
} }
} }

+ 785
- 0
src/Discord.Net/API/DiscordRawClient.cs View File

@@ -0,0 +1,785 @@
using Discord.API.Rest;
using Discord.Net;
using Discord.Net.Converters;
using Discord.Net.Rest;
using Newtonsoft.Json;
using System;
using System.Collections.Generic;
using System.Collections.Immutable;
using System.Diagnostics;
using System.Globalization;
using System.IO;
using System.Linq;
using System.Net;
using System.Text;
using System.Threading;
using System.Threading.Tasks;

namespace Discord.API
{
public class DiscordRawClient
{
internal event EventHandler<SentRequestEventArgs> SentRequest;

private readonly IRestClient _restClient;
private readonly CancellationToken _cancelToken;
private readonly JsonSerializer _serializer;

internal DiscordRawClient(RestClientProvider restClientProvider, CancellationToken cancelToken, TokenType authTokenType, string authToken)
{
_cancelToken = cancelToken;

switch (authTokenType)
{
case TokenType.Bot:
authToken = $"Bot {authToken}";
break;
case TokenType.Bearer:
authToken = $"Bearer {authToken}";
break;
case TokenType.User:
break;
default:
throw new ArgumentException("Unknown oauth token type", nameof(authTokenType));
}

_restClient = restClientProvider(DiscordConfig.ClientAPIUrl, cancelToken);
_restClient.SetHeader("authorization", authToken);
_restClient.SetHeader("user-agent", DiscordConfig.UserAgent);

_serializer = new JsonSerializer();
_serializer.Converters.Add(new ChannelTypeConverter());
_serializer.Converters.Add(new ImageConverter());
_serializer.Converters.Add(new NullableUInt64Converter());
_serializer.Converters.Add(new PermissionTargetConverter());
_serializer.Converters.Add(new StringEntityConverter());
_serializer.Converters.Add(new UInt64ArrayConverter());
_serializer.Converters.Add(new UInt64Converter());
_serializer.Converters.Add(new UInt64EntityConverter());
_serializer.Converters.Add(new UserStatusConverter());
}

//Core
public async Task<TResponse> Send<TResponse>(string method, string endpoint)
where TResponse : class
{
var stopwatch = Stopwatch.StartNew();
Stream responseStream;
try
{
responseStream = await _restClient.Send(method, endpoint, (string)null).ConfigureAwait(false);
}
catch (HttpException ex)
{
if (!HandleException(ex))
throw;
return null;
}
int bytes = (int)responseStream.Length;
stopwatch.Stop();
var response = Deserialize<TResponse>(responseStream);

double milliseconds = ToMilliseconds(stopwatch);
SentRequest(this, new SentRequestEventArgs(method, endpoint, bytes, milliseconds));

return response;
}
public async Task Send(string method, string endpoint)
{
var stopwatch = Stopwatch.StartNew();
try
{
await _restClient.Send(method, endpoint, (string)null).ConfigureAwait(false);
}
catch (HttpException ex)
{
if (!HandleException(ex))
throw;
return;
}
stopwatch.Stop();

double milliseconds = ToMilliseconds(stopwatch);
SentRequest(this, new SentRequestEventArgs(method, endpoint, 0, milliseconds));
}
public async Task<TResponse> Send<TResponse>(string method, string endpoint, object payload)
where TResponse : class
{
string requestStream = Serialize(payload);
var stopwatch = Stopwatch.StartNew();
Stream responseStream;
try
{
responseStream = await _restClient.Send(method, endpoint, requestStream).ConfigureAwait(false);
}
catch (HttpException ex)
{
if (!HandleException(ex))
throw;
return null;
}
int bytes = (int)responseStream.Length;
stopwatch.Stop();
var response = Deserialize<TResponse>(responseStream);

double milliseconds = ToMilliseconds(stopwatch);
SentRequest(this, new SentRequestEventArgs(method, endpoint, bytes, milliseconds));

return response;
}
public async Task Send(string method, string endpoint, object payload)
{
string requestStream = Serialize(payload);
var stopwatch = Stopwatch.StartNew();
try
{
await _restClient.Send(method, endpoint, requestStream).ConfigureAwait(false);
}
catch (HttpException ex)
{
if (!HandleException(ex))
throw;
return;
}
stopwatch.Stop();

double milliseconds = ToMilliseconds(stopwatch);
SentRequest(this, new SentRequestEventArgs(method, endpoint, 0, milliseconds));
}
public async Task<TResponse> Send<TResponse>(string method, string endpoint, Stream file, IReadOnlyDictionary<string, string> multipartArgs)
where TResponse : class
{
var stopwatch = Stopwatch.StartNew();
var responseStream = await _restClient.Send(method, endpoint).ConfigureAwait(false);
stopwatch.Stop();
var response = Deserialize<TResponse>(responseStream);

double milliseconds = ToMilliseconds(stopwatch);
SentRequest(this, new SentRequestEventArgs(method, endpoint, (int)responseStream.Length, milliseconds));

return response;
}
public async Task Send(string method, string endpoint, Stream file, IReadOnlyDictionary<string, string> multipartArgs)
{
var stopwatch = Stopwatch.StartNew();
await _restClient.Send(method, endpoint).ConfigureAwait(false);
stopwatch.Stop();

double milliseconds = ToMilliseconds(stopwatch);
SentRequest(this, new SentRequestEventArgs(method, endpoint, 0, milliseconds));
}

//Gateway
public async Task<GetGatewayResponse> GetGateway()
{
return await Send<GetGatewayResponse>("GET", "gateway").ConfigureAwait(false);
}

//Channels
public async Task<Channel> GetChannel(ulong channelId)
{
if (channelId == 0) throw new ArgumentOutOfRangeException(nameof(channelId));

try
{
return await Send<Channel>("GET", $"channels/{channelId}").ConfigureAwait(false);
}
catch (HttpException ex) when (ex.StatusCode == HttpStatusCode.NotFound) { return null; }
}
public async Task<Channel> GetChannel(ulong guildId, ulong channelId)
{
if (channelId == 0) throw new ArgumentOutOfRangeException(nameof(channelId));

try
{
var model = await Send<Channel>("GET", $"channels/{channelId}").ConfigureAwait(false);
if (model.GuildId != guildId)
return null;
return model;
}
catch (HttpException ex) when (ex.StatusCode == HttpStatusCode.NotFound) { return null; }
}
public async Task<IEnumerable<Channel>> GetGuildChannels(ulong guildId)
{
if (guildId == 0) throw new ArgumentOutOfRangeException(nameof(guildId));
return await Send<IEnumerable<Channel>>("GET", $"guild/{guildId}/channels").ConfigureAwait(false);
}
public async Task<Channel> CreateGuildChannel(ulong guildId, CreateGuildChannelParams args)
{
if (args == null) throw new ArgumentNullException(nameof(args));
if (guildId == 0) throw new ArgumentOutOfRangeException(nameof(guildId));
if (args.Bitrate <= 0) throw new ArgumentOutOfRangeException(nameof(args.Bitrate));
if (args.Name == "") throw new ArgumentOutOfRangeException(nameof(args.Name));

return await Send<Channel>("POST", $"guilds/{guildId}/channels", args).ConfigureAwait(false);
}
public async Task<Channel> DeleteChannel(ulong channelId)
{
if (channelId == 0) throw new ArgumentOutOfRangeException(nameof(channelId));

return await Send<Channel>("DELETE", $"channels/{channelId}").ConfigureAwait(false);
}
public async Task<Channel> ModifyGuildChannel(ulong channelId, ModifyGuildChannelParams args)
{
if (args == null) throw new ArgumentNullException(nameof(args));
if (channelId == 0) throw new ArgumentOutOfRangeException(nameof(channelId));
if (args.Name == "") throw new ArgumentOutOfRangeException(nameof(args.Name));
if (args.Position < 0) throw new ArgumentOutOfRangeException(nameof(args.Position));

return await Send<Channel>("PATCH", $"channels/{channelId}", args).ConfigureAwait(false);
}
public async Task<Channel> ModifyGuildChannel(ulong channelId, ModifyTextChannelParams args)
{
if (args == null) throw new ArgumentNullException(nameof(args));
if (channelId == 0) throw new ArgumentOutOfRangeException(nameof(channelId));
if (args.Name == "") throw new ArgumentOutOfRangeException(nameof(args.Name));
if (args.Position < 0) throw new ArgumentOutOfRangeException(nameof(args.Position));

return await Send<Channel>("PATCH", $"channels/{channelId}", args).ConfigureAwait(false);
}
public async Task<Channel> ModifyGuildChannel(ulong channelId, ModifyVoiceChannelParams args)
{
if (args == null) throw new ArgumentNullException(nameof(args));
if (channelId == 0) throw new ArgumentOutOfRangeException(nameof(channelId));
if (args.Bitrate <= 0) throw new ArgumentOutOfRangeException(nameof(args.Bitrate));
if (args.Name == "") throw new ArgumentOutOfRangeException(nameof(args.Name));
if (args.Position < 0) throw new ArgumentOutOfRangeException(nameof(args.Position));

return await Send<Channel>("PATCH", $"channels/{channelId}", args).ConfigureAwait(false);
}
public async Task ModifyGuildChannels(ulong guildId, IEnumerable<ModifyGuildChannelsParams> args)
{
if (args == null) throw new ArgumentNullException(nameof(args));
if (guildId == 0) throw new ArgumentOutOfRangeException(nameof(guildId));

var channels = args.ToArray();
switch (channels.Length)
{
case 0:
throw new ArgumentOutOfRangeException(nameof(args));
case 1:
await ModifyGuildChannel(channels[0].Id, new ModifyGuildChannelParams { Position = channels[0].Position }).ConfigureAwait(false);
break;
default:
await Send("PATCH", $"guilds/{guildId}/channels", channels).ConfigureAwait(false);
break;
}
}

//Channel Permissions
public async Task ModifyChannelPermissions(ulong channelId, ulong targetId, ModifyChannelPermissionsParams args)
{
if (args == null) throw new ArgumentNullException(nameof(args));
await Send("PUT", $"channels/{channelId}/permissions/{targetId}", args).ConfigureAwait(false);
}
public async Task DeleteChannelPermission(ulong channelId, ulong targetId)
{
await Send("DELETE", $"channels/{channelId}/permissions/{targetId}").ConfigureAwait(false);
}

//Guilds
public async Task<Guild> GetGuild(ulong guildId)
{
if (guildId == 0) throw new ArgumentOutOfRangeException(nameof(guildId));

try
{
return await Send<Guild>("GET", $"guilds/{guildId}").ConfigureAwait(false);
}
catch (HttpException ex) when (ex.StatusCode == HttpStatusCode.NotFound) { return null; }
}
public async Task<Guild> CreateGuild(CreateGuildParams args)
{
if (args == null) throw new ArgumentNullException(nameof(args));
if (string.IsNullOrEmpty(args.Name)) throw new ArgumentNullException(nameof(args.Name));
if (string.IsNullOrEmpty(args.Region)) throw new ArgumentNullException(nameof(args.Region));

return await Send<Guild>("POST", "guilds", args).ConfigureAwait(false);
}
public async Task<Guild> DeleteGuild(ulong guildId)
{
if (guildId == 0) throw new ArgumentOutOfRangeException(nameof(guildId));

return await Send<Guild>("DELETE", $"guilds/{guildId}").ConfigureAwait(false);
}
public async Task<Guild> LeaveGuild(ulong guildId)
{
if (guildId == 0) throw new ArgumentOutOfRangeException(nameof(guildId));

return await Send<Guild>("DELETE", $"users/@me/guilds/{guildId}").ConfigureAwait(false);
}
public async Task<Guild> ModifyGuild(ulong guildId, ModifyGuildParams args)
{
if (args == null) throw new ArgumentNullException(nameof(args));
if (guildId == 0) throw new ArgumentOutOfRangeException(nameof(guildId));
if (args.AFKChannelId == 0) throw new ArgumentOutOfRangeException(nameof(args.AFKChannelId));
if (args.AFKTimeout < 0) throw new ArgumentOutOfRangeException(nameof(args.AFKTimeout));
if (args.Name == "") throw new ArgumentOutOfRangeException(nameof(args.Name));
//if (args.OwnerId == 0) throw new ArgumentOutOfRangeException(nameof(args.OwnerId));
//if (args.Region == "") throw new ArgumentOutOfRangeException(nameof(args.Region));
if (args.VerificationLevel < 0) throw new ArgumentOutOfRangeException(nameof(args.VerificationLevel));

return await Send<Guild>("PATCH", $"guilds/{guildId}", args).ConfigureAwait(false);
}
public async Task<GetGuildPruneCountResponse> BeginGuildPrune(ulong guildId, GuildPruneParams args)
{
if (args == null) throw new ArgumentNullException(nameof(args));
if (guildId == 0) throw new ArgumentOutOfRangeException(nameof(guildId));
if (args.Days < 0) throw new ArgumentOutOfRangeException(nameof(args.Days));

return await Send<GetGuildPruneCountResponse>("POST", $"guilds/{guildId}/prune", args).ConfigureAwait(false);
}
public async Task<GetGuildPruneCountResponse> GetGuildPruneCount(ulong guildId, GuildPruneParams args)
{
if (args == null) throw new ArgumentNullException(nameof(args));
if (guildId == 0) throw new ArgumentOutOfRangeException(nameof(guildId));
if (args.Days < 0) throw new ArgumentOutOfRangeException(nameof(args.Days));

return await Send<GetGuildPruneCountResponse>("GET", $"guilds/{guildId}/prune", args).ConfigureAwait(false);
}

//Guild Bans
public async Task<IEnumerable<User>> GetGuildBans(ulong guildId)
{
if (guildId == 0) throw new ArgumentOutOfRangeException(nameof(guildId));
return await Send<IEnumerable<User>>("GET", $"guilds/{guildId}/bans").ConfigureAwait(false);
}
public async Task CreateGuildBan(ulong guildId, ulong userId, CreateGuildBanParams args)
{
if (args == null) throw new ArgumentNullException(nameof(args));
if (guildId == 0) throw new ArgumentOutOfRangeException(nameof(guildId));
if (userId == 0) throw new ArgumentOutOfRangeException(nameof(userId));
if (args.PruneDays < 0) throw new ArgumentOutOfRangeException(nameof(args.PruneDays));

await Send("PUT", $"guilds/{guildId}/bans/{userId}", args).ConfigureAwait(false);
}
public async Task RemoveGuildBan(ulong guildId, ulong userId)
{
if (guildId == 0) throw new ArgumentOutOfRangeException(nameof(guildId));
if (userId == 0) throw new ArgumentOutOfRangeException(nameof(userId));

await Send("DELETE", $"guilds/{guildId}/bans/{userId}").ConfigureAwait(false);
}

//Guild Embeds
public async Task<GuildEmbed> GetGuildEmbed(ulong guildId)
{
if (guildId == 0) throw new ArgumentOutOfRangeException(nameof(guildId));

try
{
return await Send<GuildEmbed>("GET", $"guilds/{guildId}/embed").ConfigureAwait(false);
}
catch (HttpException ex) when (ex.StatusCode == HttpStatusCode.NotFound) { return null; }
}
public async Task<GuildEmbed> ModifyGuildEmbed(ulong guildId, ModifyGuildEmbedParams args)
{
if (args == null) throw new ArgumentNullException(nameof(args));
if (guildId == 0) throw new ArgumentOutOfRangeException(nameof(guildId));

return await Send<GuildEmbed>("PATCH", $"guilds/{guildId}/embed", args).ConfigureAwait(false);
}

//Guild Integrations
public async Task<IEnumerable<Integration>> GetGuildIntegrations(ulong guildId)
{
if (guildId == 0) throw new ArgumentOutOfRangeException(nameof(guildId));

return await Send<IEnumerable<Integration>>("GET", $"guilds/{guildId}/integrations").ConfigureAwait(false);
}
public async Task<Integration> CreateGuildIntegration(ulong guildId, CreateGuildIntegrationParams args)
{
if (args == null) throw new ArgumentNullException(nameof(args));
if (guildId == 0) throw new ArgumentOutOfRangeException(nameof(guildId));
if (args.Id == 0) throw new ArgumentOutOfRangeException(nameof(args.Id));

return await Send<Integration>("POST", $"guilds/{guildId}/integrations").ConfigureAwait(false);
}
public async Task<Integration> DeleteGuildIntegration(ulong guildId, ulong integrationId)
{
if (guildId == 0) throw new ArgumentOutOfRangeException(nameof(guildId));
if (integrationId == 0) throw new ArgumentOutOfRangeException(nameof(integrationId));

return await Send<Integration>("DELETE", $"guilds/{guildId}/integrations/{integrationId}").ConfigureAwait(false);
}
public async Task<Integration> ModifyGuildIntegration(ulong guildId, ulong integrationId, ModifyGuildIntegrationParams args)
{
if (args == null) throw new ArgumentNullException(nameof(args));
if (guildId == 0) throw new ArgumentOutOfRangeException(nameof(guildId));
if (integrationId == 0) throw new ArgumentOutOfRangeException(nameof(integrationId));
if (args.ExpireBehavior < 0) throw new ArgumentOutOfRangeException(nameof(args.ExpireBehavior));
if (args.ExpireGracePeriod < 0) throw new ArgumentOutOfRangeException(nameof(args.ExpireGracePeriod));

return await Send<Integration>("PATCH", $"guilds/{guildId}/integrations/{integrationId}", args).ConfigureAwait(false);
}
public async Task<Integration> SyncGuildIntegration(ulong guildId, ulong integrationId)
{
if (guildId == 0) throw new ArgumentOutOfRangeException(nameof(guildId));
if (integrationId == 0) throw new ArgumentOutOfRangeException(nameof(integrationId));

return await Send<Integration>("POST", $"guilds/{guildId}/integrations/{integrationId}/sync").ConfigureAwait(false);
}

//Guild Invites
public async Task<Invite> GetInvite(string inviteIdOrXkcd)
{
if (string.IsNullOrEmpty(inviteIdOrXkcd)) throw new ArgumentOutOfRangeException(nameof(inviteIdOrXkcd));

try
{
return await Send<Invite>("GET", $"invites/{inviteIdOrXkcd}").ConfigureAwait(false);
}
catch (HttpException ex) when (ex.StatusCode == HttpStatusCode.NotFound) { return null; }
}
public async Task<IEnumerable<InviteMetadata>> GetGuildInvites(ulong guildId)
{
if (guildId == 0) throw new ArgumentOutOfRangeException(nameof(guildId));

return await Send<IEnumerable<InviteMetadata>>("GET", $"guilds/{guildId}/invites").ConfigureAwait(false);
}
public async Task<InviteMetadata[]> GetChannelInvites(ulong channelId)
{
if (channelId == 0) throw new ArgumentOutOfRangeException(nameof(channelId));

return await Send<InviteMetadata[]>("GET", $"channels/{channelId}/invites").ConfigureAwait(false);
}
public async Task<InviteMetadata> CreateChannelInvite(ulong channelId, CreateChannelInviteParams args)
{
if (args == null) throw new ArgumentNullException(nameof(args));
if (channelId == 0) throw new ArgumentOutOfRangeException(nameof(channelId));
if (args.MaxAge < 0) throw new ArgumentOutOfRangeException(nameof(args.MaxAge));
if (args.MaxUses < 0) throw new ArgumentOutOfRangeException(nameof(args.MaxUses));

return await Send<InviteMetadata>("POST", $"channels/{channelId}/invites", args).ConfigureAwait(false);
}
public async Task<Invite> DeleteInvite(string inviteCode)
{
if (string.IsNullOrEmpty(inviteCode)) throw new ArgumentOutOfRangeException(nameof(inviteCode));

return await Send<Invite>("DELETE", $"invites/{inviteCode}").ConfigureAwait(false);
}
public async Task AcceptInvite(string inviteCode)
{
if (string.IsNullOrEmpty(inviteCode)) throw new ArgumentOutOfRangeException(nameof(inviteCode));

await Send("POST", $"invites/{inviteCode}").ConfigureAwait(false);
}

//Guild Members
public async Task<GuildMember> GetGuildMember(ulong guildId, ulong userId)
{
if (guildId == 0) throw new ArgumentOutOfRangeException(nameof(guildId));
if (userId == 0) throw new ArgumentOutOfRangeException(nameof(userId));

try
{
return await Send<GuildMember>("GET", $"guilds/{guildId}/members/{userId}").ConfigureAwait(false);
}
catch (HttpException ex) when (ex.StatusCode == HttpStatusCode.NotFound) { return null; }
}
public async Task<IEnumerable<GuildMember>> GetGuildMembers(ulong guildId, GetGuildMembersParams args)
{
if (args == null) throw new ArgumentNullException(nameof(args));
if (guildId == 0) throw new ArgumentOutOfRangeException(nameof(guildId));
if (args.Limit <= 0) throw new ArgumentOutOfRangeException(nameof(args.Limit));
if (args.Offset < 0) throw new ArgumentOutOfRangeException(nameof(args.Offset));

int limit = args.Limit ?? int.MaxValue;
int offset = args.Offset;

List<GuildMember[]> result;
if (args.Limit != null)
result = new List<GuildMember[]>((limit + DiscordConfig.MaxUsersPerBatch - 1) / DiscordConfig.MaxUsersPerBatch);
else
result = new List<GuildMember[]>();

while (true)
{
int runLimit = (limit >= DiscordConfig.MaxUsersPerBatch) ? DiscordConfig.MaxUsersPerBatch : limit;
string endpoint = $"guild/{guildId}/members?limit={limit}&offset={offset}";
var models = await Send<GuildMember[]>("GET", endpoint).ConfigureAwait(false);

//Was this an empty batch?
if (models.Length == 0) break;

result.Add(models);

limit -= DiscordConfig.MaxUsersPerBatch;

//Was this an incomplete (the last) batch?
if (models.Length != DiscordConfig.MaxUsersPerBatch) break;
}

if (result.Count > 1)
return result.SelectMany(x => x);
else
return result[0];
}
public async Task RemoveGuildMember(ulong guildId, ulong userId)
{
if (guildId == 0) throw new ArgumentOutOfRangeException(nameof(guildId));
if (userId == 0) throw new ArgumentOutOfRangeException(nameof(userId));

await Send("DELETE", $"guilds/{guildId}/members/{userId}").ConfigureAwait(false);
}
public async Task<GuildMember> ModifyGuildMember(ulong guildId, ulong userId, ModifyGuildMemberParams args)
{
if (args == null) throw new ArgumentNullException(nameof(args));
if (guildId == 0) throw new ArgumentOutOfRangeException(nameof(guildId));
if (userId == 0) throw new ArgumentOutOfRangeException(nameof(userId));
return await Send<GuildMember>("PATCH", $"guilds/{guildId}/members/{userId}", args).ConfigureAwait(false);
}

//Guild Roles
public async Task<IEnumerable<Role>> GetGuildRoles(ulong guildId)
{
if (guildId == 0) throw new ArgumentOutOfRangeException(nameof(guildId));

return await Send<IEnumerable<Role>>("GET", $"guild/{guildId}/roles").ConfigureAwait(false);
}
public async Task<Role> CreateGuildRole(ulong guildId)
{
if (guildId == 0) throw new ArgumentOutOfRangeException(nameof(guildId));

return await Send<Role>("POST", $"guilds/{guildId}/roles").ConfigureAwait(false);
}
public async Task DeleteGuildRole(ulong guildId, ulong roleId)
{
if (guildId == 0) throw new ArgumentOutOfRangeException(nameof(guildId));
if (roleId == 0) throw new ArgumentOutOfRangeException(nameof(roleId));

await Send("DELETE", $"guilds/{guildId}/roles/{roleId}").ConfigureAwait(false);
}
public async Task<Role> ModifyGuildRole(ulong guildId, ulong roleId, ModifyGuildRoleParams args)
{
if (args == null) throw new ArgumentNullException(nameof(args));
if (guildId == 0) throw new ArgumentOutOfRangeException(nameof(guildId));
if (roleId == 0) throw new ArgumentOutOfRangeException(nameof(roleId));
if (args.Color < 0) throw new ArgumentOutOfRangeException(nameof(args.Color));
if (args.Name == "") throw new ArgumentOutOfRangeException(nameof(args.Name));
if (args.Position < 0) throw new ArgumentOutOfRangeException(nameof(args.Position));

return await Send<Role>("PATCH", $"guilds/{guildId}/roles/{roleId}", args).ConfigureAwait(false);
}
public async Task<IEnumerable<Role>> ModifyGuildRoles(ulong guildId, IEnumerable<ModifyGuildRolesParams> args)
{
if (args == null) throw new ArgumentNullException(nameof(args));
if (guildId == 0) throw new ArgumentOutOfRangeException(nameof(guildId));

var roles = args.ToArray();
switch (roles.Length)
{
case 0:
throw new ArgumentOutOfRangeException(nameof(args));
case 1:
return ImmutableArray.Create(await ModifyGuildRole(guildId, roles[0].Id, roles[0]).ConfigureAwait(false));
default:
return await Send<IEnumerable<Role>>("PATCH", $"guilds/{guildId}/roles", args).ConfigureAwait(false);
}
}

//Messages
public async Task<IEnumerable<Message>> GetChannelMessages(ulong channelId, GetChannelMessagesParams args)
{
if (args == null) throw new ArgumentNullException(nameof(args));
if (channelId == 0) throw new ArgumentOutOfRangeException(nameof(channelId));
if (args.Limit <= 0) throw new ArgumentOutOfRangeException(nameof(args.Limit));

int limit = args.Limit;
ulong? relativeId = args.RelativeMessageId;
string relativeDir = args.RelativeDirection == Direction.After ? "after" : "before";
int runs = limit / DiscordConfig.MaxMessagesPerBatch;
int lastRunCount = limit - runs * DiscordConfig.MaxMessagesPerBatch;
var result = new API.Message[runs][];

int i = 0;
for (; i < runs; i++)
{
string endpoint;
if (relativeId != null)
endpoint = $"channels/{channelId}/messages?limit={limit}&{relativeDir}={relativeId}";
else
endpoint = $"channels/{channelId}/messages?limit={limit}";
var models = await Send<Message[]>("GET", endpoint).ConfigureAwait(false);

//Was this an empty batch?
if (models.Length == 0) break;

result[i] = models;

limit = (i == runs - 1) ? lastRunCount : DiscordConfig.MaxMessagesPerBatch;
relativeId = args.RelativeDirection == Direction.Before ? models[0].Id : models[models.Length - 1].Id;

//Was this an incomplete (the last) batch?
if (models.Length != DiscordConfig.MaxMessagesPerBatch) { i++; break; }
}

if (runs > 1)
return result.Take(runs).SelectMany(x => x);
else
return result[0];
}
public async Task<Message> CreateMessage(ulong channelId, CreateMessageParams args)
{
if (args == null) throw new ArgumentNullException(nameof(args));
if (channelId == 0) throw new ArgumentOutOfRangeException(nameof(channelId));

return await Send<Message>("POST", $"channels/{channelId}/messages", args).ConfigureAwait(false);
}
public async Task<Message> UploadFile(ulong channelId, Stream file, UploadFileParams args)
{
if (args == null) throw new ArgumentNullException(nameof(args));
if (channelId == 0) throw new ArgumentOutOfRangeException(nameof(channelId));

return await Send<Message>("POST", $"channels/{channelId}/messages", file, args.ToDictionary()).ConfigureAwait(false);
}
public async Task DeleteMessage(ulong channelId, ulong messageId)
{
if (channelId == 0) throw new ArgumentOutOfRangeException(nameof(channelId));
if (messageId == 0) throw new ArgumentOutOfRangeException(nameof(messageId));

await Send("DELETE", $"channels/{channelId}/messages/{messageId}").ConfigureAwait(false);
}
public async Task DeleteMessages(ulong channelId, DeleteMessagesParam args)
{
if (args == null) throw new ArgumentNullException(nameof(args));
if (args.MessageIds == null) throw new ArgumentNullException(nameof(args.MessageIds));

var messageIds = args.MessageIds.ToArray();
switch (messageIds.Length)
{
case 0:
throw new ArgumentOutOfRangeException(nameof(args.MessageIds));
case 1:
await DeleteMessage(channelId, messageIds[0]).ConfigureAwait(false);
break;
default:
await Send("POST", $"channels/{channelId}/messages/bulk_delete", args).ConfigureAwait(false);
break;
}
}
public async Task<Message> ModifyMessage(ulong channelId, ulong messageId, ModifyMessageParams args)
{
if (args == null) throw new ArgumentNullException(nameof(args));
if (channelId == 0) throw new ArgumentOutOfRangeException(nameof(channelId));
if (messageId == 0) throw new ArgumentOutOfRangeException(nameof(messageId));

return await Send<Message>("PATCH", $"channels/{channelId}/messages/{messageId}", args).ConfigureAwait(false);
}
public async Task AckMessage(ulong channelId, ulong messageId)
{
if (channelId == 0) throw new ArgumentOutOfRangeException(nameof(channelId));
if (messageId == 0) throw new ArgumentOutOfRangeException(nameof(messageId));

await Send("POST", $"channels/{channelId}/messages/{messageId}/ack").ConfigureAwait(false);
}
public async Task TriggerTypingIndicator(ulong channelId)
{
if (channelId == 0) throw new ArgumentOutOfRangeException(nameof(channelId));

await Send("POST", $"channels/{channelId}/typing").ConfigureAwait(false);
}

//Users
public async Task<User> GetUser(ulong userId)
{
if (userId == 0) throw new ArgumentOutOfRangeException(nameof(userId));

try
{
return await Send<User>("GET", $"users/{userId}").ConfigureAwait(false);
}
catch (HttpException ex) when (ex.StatusCode == HttpStatusCode.NotFound) { return null; }
}
public async Task<User> GetUser(string username, ushort discriminator)
{
if (string.IsNullOrEmpty(username)) throw new ArgumentOutOfRangeException(nameof(username));

try
{
var models = await QueryUsers($"{username}#{discriminator}", 1).ConfigureAwait(false);
return models.FirstOrDefault();
}
catch (HttpException ex) when (ex.StatusCode == HttpStatusCode.NotFound) { return null; }
}
public async Task<IEnumerable<User>> QueryUsers(string query, int limit)
{
if (string.IsNullOrEmpty(query)) throw new ArgumentOutOfRangeException(nameof(query));
if (limit <= 0) throw new ArgumentOutOfRangeException(nameof(limit));

return await Send<IEnumerable<User>>("GET", $"users?q={Uri.EscapeDataString(query)}&limit={limit}").ConfigureAwait(false);
}

//Current User/DMs
public async Task<User> GetCurrentUser()
{
return await Send<User>("GET", "users/@me").ConfigureAwait(false);
}
public async Task<IEnumerable<Connection>> GetCurrentUserConnections()
{
return await Send<IEnumerable<Connection>>("GET", "users/@me/connections").ConfigureAwait(false);
}
public async Task<IEnumerable<Channel>> GetCurrentUserDMs()
{
return await Send<IEnumerable<Channel>>("GET", "users/@me/channels").ConfigureAwait(false);
}
public async Task<IEnumerable<UserGuild>> GetCurrentUserGuilds()
{
return await Send<IEnumerable<UserGuild>>("GET", "users/@me/guilds").ConfigureAwait(false);
}
public async Task<User> ModifyCurrentUser(ModifyCurrentUserParams args)
{
if (args == null) throw new ArgumentNullException(nameof(args));
if (args.Email == "") throw new ArgumentOutOfRangeException(nameof(args.Email));
if (args.Username == "") throw new ArgumentOutOfRangeException(nameof(args.Username));

return await Send<User>("PATCH", "users/@me", args).ConfigureAwait(false);
}
public async Task<Channel> CreateDMChannel(CreateDMChannelParams args)
{
if (args == null) throw new ArgumentNullException(nameof(args));
if (args.RecipientId == 0) throw new ArgumentOutOfRangeException(nameof(args.RecipientId));

return await Send<Channel>("POST", $"users/@me/channels", args).ConfigureAwait(false);
}

//Voice Regions
public async Task<IEnumerable<VoiceRegion>> GetVoiceRegions()
{
return await Send<IEnumerable<VoiceRegion>>("GET", "voice/regions").ConfigureAwait(false);
}
public async Task<IEnumerable<VoiceRegion>> GetGuildVoiceRegions(ulong guildId)
{
if (guildId == 0) throw new ArgumentOutOfRangeException(nameof(guildId));

return await Send<IEnumerable<VoiceRegion>>("GET", $"guilds/{guildId}/regions").ConfigureAwait(false);
}

//Helpers
private static double ToMilliseconds(Stopwatch stopwatch) => Math.Round((double)stopwatch.ElapsedTicks / (double)Stopwatch.Frequency * 1000.0, 2);
private string Serialize(object value)
{
var sb = new StringBuilder(256);
using (TextWriter text = new StringWriter(sb, CultureInfo.InvariantCulture))
using (JsonWriter writer = new JsonTextWriter(text))
_serializer.Serialize(writer, value);
return sb.ToString();
}
private T Deserialize<T>(Stream jsonStream)
{
using (TextReader text = new StreamReader(jsonStream))
using (JsonReader reader = new JsonTextReader(text))
return _serializer.Deserialize<T>(reader);
}

private bool HandleException(Exception ex)
{
//TODO: Implement... maybe via SentRequest? Need to bubble this up to DiscordClient or a MessageQueue
return false;
}
}
}

+ 0
- 26
src/Discord.Net/API/GatewaySocket/OpCode.cs View File

@@ -1,26 +0,0 @@
namespace Discord.API.GatewaySocket
{
public enum OpCode : byte
{
/// <summary> C←S - Used to send most events. </summary>
Dispatch = 0,
/// <summary> C↔S - Used to keep the connection alive and measure latency. </summary>
Heartbeat = 1,
/// <summary> C→S - Used to associate a connection with a token and specify configuration. </summary>
Identify = 2,
/// <summary> C→S - Used to update client's status and current game id. </summary>
StatusUpdate = 3,
/// <summary> C→S - Used to join a particular voice channel. </summary>
VoiceStateUpdate = 4,
/// <summary> C→S - Used to ensure the guild's voice server is alive. Only send this if voice connection fails or suddenly drops. </summary>
VoiceServerPing = 5,
/// <summary> C→S - Used to resume a connection after a redirect occurs. </summary>
Resume = 6,
/// <summary> C←S - Used to notify a client that they must reconnect to another gateway. </summary>
Reconnect = 7,
/// <summary> C→S - Used to request all members that were withheld by large_threshold. </summary>
RequestGuildMembers = 8,
/// <summary> C←S - Used to notify the client of an invalid session id. </summary>
InvalidSession = 9
}
}

+ 0
- 12
src/Discord.Net/API/GatewaySocket/Unconfirmed/Commands/Heartbeat.cs View File

@@ -1,12 +0,0 @@
using Newtonsoft.Json;
using System;

namespace Discord.API.GatewaySocket
{
[JsonObject(MemberSerialization.OptIn)]
public class HeartbeatCommand : IWebSocketMessage
{
int IWebSocketMessage.OpCode => (int)OpCode.Heartbeat;
object IWebSocketMessage.Payload => DateTimeOffset.UtcNow.ToUnixTimeMilliseconds();
}
}

+ 0
- 23
src/Discord.Net/API/GatewaySocket/Unconfirmed/Commands/Identify.cs View File

@@ -1,23 +0,0 @@
using Newtonsoft.Json;
using System.Collections.Generic;

namespace Discord.API.GatewaySocket
{
[JsonObject(MemberSerialization.OptIn)]
public class IdentifyCommand : IWebSocketMessage
{
int IWebSocketMessage.OpCode => (int)OpCode.Identify;
object IWebSocketMessage.Payload => this;

[JsonProperty("v")]
public int Version { get; set; }
[JsonProperty("token")]
public string Token { get; set; }
[JsonProperty("properties")]
public IReadOnlyDictionary<string, string> Properties { get; set; }
[JsonProperty("large_threshold", NullValueHandling = NullValueHandling.Ignore)]
public int LargeThreshold { get; set; }
[JsonProperty("compress")]
public bool UseCompression { get; set; }
}
}

+ 0
- 18
src/Discord.Net/API/GatewaySocket/Unconfirmed/Commands/RequestMembers.cs View File

@@ -1,18 +0,0 @@
using Newtonsoft.Json;

namespace Discord.API.GatewaySocket
{
[JsonObject(MemberSerialization.OptIn)]
public class RequestMembersCommand : IWebSocketMessage
{
int IWebSocketMessage.OpCode => (int)OpCode.RequestGuildMembers;
object IWebSocketMessage.Payload => this;

[JsonProperty("guild_id")]
public ulong[] GuildId { get; set; }
[JsonProperty("query")]
public string Query { get; set; }
[JsonProperty("limit")]
public int Limit { get; set; }
}
}

+ 0
- 16
src/Discord.Net/API/GatewaySocket/Unconfirmed/Commands/Resume.cs View File

@@ -1,16 +0,0 @@
using Newtonsoft.Json;

namespace Discord.API.GatewaySocket
{
[JsonObject(MemberSerialization.OptIn)]
public class ResumeCommand : IWebSocketMessage
{
int IWebSocketMessage.OpCode => (int)OpCode.Resume;
object IWebSocketMessage.Payload => this;

[JsonProperty("session_id")]
public string SessionId { get; set; }
[JsonProperty("seq")]
public uint Sequence { get; set; }
}
}

+ 0
- 22
src/Discord.Net/API/GatewaySocket/Unconfirmed/Commands/UpdateStatus.cs View File

@@ -1,22 +0,0 @@
using Newtonsoft.Json;

namespace Discord.API.GatewaySocket
{
[JsonObject(MemberSerialization.OptIn)]
public class UpdateStatusCommand : IWebSocketMessage
{
int IWebSocketMessage.OpCode => (int)OpCode.StatusUpdate;
object IWebSocketMessage.Payload => this;

public class GameInfo
{
[JsonProperty("name")]
public string Name { get; set; }
}

[JsonProperty("idle_since")]
public long? IdleSince { get; set; }
[JsonProperty("game")]
public GameInfo Game { get; set; }
}
}

+ 0
- 20
src/Discord.Net/API/GatewaySocket/Unconfirmed/Commands/UpdateVoice.cs View File

@@ -1,20 +0,0 @@
using Newtonsoft.Json;

namespace Discord.API.GatewaySocket
{
[JsonObject(MemberSerialization.OptIn)]
public class UpdateVoiceCommand : IWebSocketMessage
{
int IWebSocketMessage.OpCode => (int)OpCode.VoiceStateUpdate;
object IWebSocketMessage.Payload => this;

[JsonProperty("guild_id")]
public ulong? GuildId { get; set; }
[JsonProperty("channel_id")]
public ulong? ChannelId { get; set; }
[JsonProperty("self_mute")]
public bool IsSelfMuted { get; set; }
[JsonProperty("self_deaf")]
public bool IsSelfDeafened { get; set; }
}
}

+ 0
- 4
src/Discord.Net/API/GatewaySocket/Unconfirmed/Events/ChannelCreate.cs View File

@@ -1,4 +0,0 @@
namespace Discord.API.GatewaySocket
{
public class ChannelCreateEvent : Channel { }
}

+ 0
- 4
src/Discord.Net/API/GatewaySocket/Unconfirmed/Events/ChannelDelete.cs View File

@@ -1,4 +0,0 @@
namespace Discord.API.GatewaySocket
{
public class ChannelDeleteEvent : Channel { }
}

+ 0
- 4
src/Discord.Net/API/GatewaySocket/Unconfirmed/Events/ChannelUpdate.cs View File

@@ -1,4 +0,0 @@
namespace Discord.API.GatewaySocket
{
public class ChannelUpdateEvent : Channel { }
}

+ 0
- 4
src/Discord.Net/API/GatewaySocket/Unconfirmed/Events/GuildBanAdd.cs View File

@@ -1,4 +0,0 @@
namespace Discord.API.GatewaySocket
{
public class GuildBanAddEvent : MemberReference { }
}

+ 0
- 4
src/Discord.Net/API/GatewaySocket/Unconfirmed/Events/GuildBanRemove.cs View File

@@ -1,4 +0,0 @@
namespace Discord.API.GatewaySocket
{
public class GuildBanRemoveEvent : MemberReference { }
}

+ 0
- 4
src/Discord.Net/API/GatewaySocket/Unconfirmed/Events/GuildCreate.cs View File

@@ -1,4 +0,0 @@
namespace Discord.API.GatewaySocket
{
public class GuildCreateEvent : ExtendedGuild { }
}

+ 0
- 4
src/Discord.Net/API/GatewaySocket/Unconfirmed/Events/GuildDelete.cs View File

@@ -1,4 +0,0 @@
namespace Discord.API.GatewaySocket
{
public class GuildDeleteEvent : ExtendedGuild { }
}

+ 0
- 4
src/Discord.Net/API/GatewaySocket/Unconfirmed/Events/GuildMemberAdd.cs View File

@@ -1,4 +0,0 @@
namespace Discord.API.GatewaySocket
{
public class GuildMemberAddEvent : ExtendedMember { }
}

+ 0
- 4
src/Discord.Net/API/GatewaySocket/Unconfirmed/Events/GuildMemberRemove.cs View File

@@ -1,4 +0,0 @@
namespace Discord.API.GatewaySocket
{
public class GuildMemberRemoveEvent : MemberReference { }
}

+ 0
- 4
src/Discord.Net/API/GatewaySocket/Unconfirmed/Events/GuildMemberUpdate.cs View File

@@ -1,4 +0,0 @@
namespace Discord.API.GatewaySocket
{
public class GuildMemberUpdateEvent : GuildMember { }
}

+ 0
- 12
src/Discord.Net/API/GatewaySocket/Unconfirmed/Events/GuildMembersChunk.cs View File

@@ -1,12 +0,0 @@
using Newtonsoft.Json;

namespace Discord.API.GatewaySocket
{
public class GuildMembersChunkEvent
{
[JsonProperty("guild_id")]
public ulong GuildId { get; set; }
[JsonProperty("members")]
public ExtendedMember[] Members { get; set; }
}
}

+ 0
- 12
src/Discord.Net/API/GatewaySocket/Unconfirmed/Events/GuildRoleCreate.cs View File

@@ -1,12 +0,0 @@
using Newtonsoft.Json;

namespace Discord.API.GatewaySocket
{
public class GuildRoleCreateEvent
{
[JsonProperty("guild_id")]
public ulong GuildId { get; set; }
[JsonProperty("role")]
public Role Data { get; set; }
}
}

+ 0
- 4
src/Discord.Net/API/GatewaySocket/Unconfirmed/Events/GuildRoleDelete.cs View File

@@ -1,4 +0,0 @@
namespace Discord.API.GatewaySocket
{
public class GuildRoleDeleteEvent : RoleReference { }
}

+ 0
- 12
src/Discord.Net/API/GatewaySocket/Unconfirmed/Events/GuildRoleUpdate.cs View File

@@ -1,12 +0,0 @@
using Newtonsoft.Json;

namespace Discord.API.GatewaySocket
{
public class GuildRoleUpdateEvent
{
[JsonProperty("guild_id")]
public ulong GuildId { get; set; }
[JsonProperty("role")]
public Role Data { get; set; }
}
}

+ 0
- 4
src/Discord.Net/API/GatewaySocket/Unconfirmed/Events/GuildUpdate.cs View File

@@ -1,4 +0,0 @@
namespace Discord.API.GatewaySocket
{
public class GuildUpdateEvent : Guild { }
}

+ 0
- 4
src/Discord.Net/API/GatewaySocket/Unconfirmed/Events/MessageAck.cs View File

@@ -1,4 +0,0 @@
namespace Discord.API.GatewaySocket
{
public class MessageAckEvent : MessageReference { }
}

+ 0
- 4
src/Discord.Net/API/GatewaySocket/Unconfirmed/Events/MessageCreate.cs View File

@@ -1,4 +0,0 @@
namespace Discord.API.GatewaySocket
{
public class MessageCreateEvent : Message { }
}

+ 0
- 4
src/Discord.Net/API/GatewaySocket/Unconfirmed/Events/MessageDelete.cs View File

@@ -1,4 +0,0 @@
namespace Discord.API.GatewaySocket
{
public class MessageDeleteEvent : MessageReference { }
}

+ 0
- 4
src/Discord.Net/API/GatewaySocket/Unconfirmed/Events/MessageUpdate.cs View File

@@ -1,4 +0,0 @@
namespace Discord.API.GatewaySocket
{
public class MessageUpdateEvent : Message { }
}

+ 0
- 4
src/Discord.Net/API/GatewaySocket/Unconfirmed/Events/PresenceUpdate.cs View File

@@ -1,4 +0,0 @@
namespace Discord.API.GatewaySocket
{
public class PresenceUpdateEvent : MemberPresence { }
}

+ 0
- 40
src/Discord.Net/API/GatewaySocket/Unconfirmed/Events/Ready.cs View File

@@ -1,40 +0,0 @@
using Newtonsoft.Json;

namespace Discord.API.GatewaySocket
{
public class ReadyEvent
{
public class ReadState
{
[JsonProperty("id")]
public string ChannelId { get; set; }
[JsonProperty("mention_count")]
public int MentionCount { get; set; }
[JsonProperty("last_message_id")]
public string LastMessageId { get; set; }
}

[JsonProperty("v")]
public int Version { get; set; }
[JsonProperty("user")]
public User User { get; set; }
[JsonProperty("session_id")]
public string SessionId { get; set; }
[JsonProperty("read_state")]
public ReadState[] ReadStates { get; set; }
[JsonProperty("guilds")]
public ExtendedGuild[] Guilds { get; set; }
[JsonProperty("private_channels")]
public Channel[] PrivateChannels { get; set; }
[JsonProperty("heartbeat_interval")]
public int HeartbeatInterval { get; set; }

//Ignored
[JsonProperty("user_settings")]
public object UserSettings { get; set; }
[JsonProperty("user_guild_settings")]
public object UserGuildSettings { get; set; }
[JsonProperty("tutorial")]
public object Tutorial { get; set; }
}
}

+ 0
- 10
src/Discord.Net/API/GatewaySocket/Unconfirmed/Events/Resumed.cs View File

@@ -1,10 +0,0 @@
using Newtonsoft.Json;

namespace Discord.API.GatewaySocket
{
public class ResumedEvent
{
[JsonProperty("heartbeat_interval")]
public int HeartbeatInterval { get; set; }
}
}

+ 0
- 14
src/Discord.Net/API/GatewaySocket/Unconfirmed/Events/TypingStart.cs View File

@@ -1,14 +0,0 @@
using Newtonsoft.Json;

namespace Discord.API.GatewaySocket
{
public class TypingStartEvent
{
[JsonProperty("user_id")]
public ulong UserId { get; set; }
[JsonProperty("channel_id")]
public ulong ChannelId { get; set; }
[JsonProperty("timestamp")]
public int Timestamp { get; set; }
}
}

+ 0
- 4
src/Discord.Net/API/GatewaySocket/Unconfirmed/Events/UserUpdate.cs View File

@@ -1,4 +0,0 @@
namespace Discord.API.GatewaySocket
{
public class UserUpdateEvent : User { }
}

+ 0
- 14
src/Discord.Net/API/GatewaySocket/Unconfirmed/Events/VoiceServerUpdate.cs View File

@@ -1,14 +0,0 @@
using Newtonsoft.Json;

namespace Discord.API.GatewaySocket
{
public class VoiceServerUpdateEvent
{
[JsonProperty("guild_id")]
public ulong GuildId { get; set; }
[JsonProperty("endpoint")]
public string Endpoint { get; set; }
[JsonProperty("token")]
public string Token { get; set; }
}
}

+ 0
- 4
src/Discord.Net/API/GatewaySocket/Unconfirmed/Events/VoiceStateUpdate.cs View File

@@ -1,4 +0,0 @@
namespace Discord.API.GatewaySocket
{
public class VoiceStateUpdateEvent : MemberVoiceState { }
}

+ 0
- 28
src/Discord.Net/API/IWebSocketMessage.cs View File

@@ -1,28 +0,0 @@
using Newtonsoft.Json;

namespace Discord.API
{
public interface IWebSocketMessage
{
int OpCode { get; }
object Payload { get; }
}
public class WebSocketMessage
{
[JsonProperty("op")]
public int? Operation { get; set; }
[JsonProperty("t", NullValueHandling = NullValueHandling.Ignore)]
public string Type { get; set; }
[JsonProperty("s", NullValueHandling = NullValueHandling.Ignore)]
public uint? Sequence { get; set; }
[JsonProperty("d")]
public object Payload { get; set; }

public WebSocketMessage() { }
public WebSocketMessage(IWebSocketMessage msg)
{
Operation = msg.OpCode;
Payload = msg.Payload;
}
}
}

+ 0
- 18
src/Discord.Net/API/Rest/AcceptInvite.cs View File

@@ -1,18 +0,0 @@
using Discord.Net.Rest;

namespace Discord.API.Rest
{
public class AcceptInviteRequest : IRestRequest<Invite>
{
string IRestRequest.Method => "POST";
string IRestRequest.Endpoint => $"invites/{InviteCode}";
object IRestRequest.Payload => null;

public string InviteCode { get; }

public AcceptInviteRequest(string inviteCode)
{
InviteCode = inviteCode;
}
}
}

+ 0
- 20
src/Discord.Net/API/Rest/AckMessage.cs View File

@@ -1,20 +0,0 @@
using Discord.Net.Rest;

namespace Discord.API.Rest
{
public class AckMessageRequest : IRestRequest
{
string IRestRequest.Method => "POST";
string IRestRequest.Endpoint => $"channels/{ChannelId}/messages/{MessageId}/ack";
object IRestRequest.Payload => null;

public ulong ChannelId { get; }
public ulong MessageId { get; }

public AckMessageRequest(ulong channelId, ulong messageId)
{
ChannelId = channelId;
MessageId = messageId;
}
}
}

+ 0
- 23
src/Discord.Net/API/Rest/BeginGuildPrune.cs View File

@@ -1,23 +0,0 @@
using Discord.Net.Rest;
using Newtonsoft.Json;

namespace Discord.API.Rest
{
[JsonObject(MemberSerialization.OptIn)]
public class BeginGuildPruneRequest : IRestRequest<GetGuildPruneCountResponse>
{
string IRestRequest.Method => "POST";
string IRestRequest.Endpoint => $"guilds/{GuildId}/prune";
object IRestRequest.Payload => this;

public ulong GuildId { get; }

[JsonProperty("days")]
public int Days { get; set; } = 30;

public BeginGuildPruneRequest(ulong guildId)
{
GuildId = guildId;
}
}
}

+ 0
- 29
src/Discord.Net/API/Rest/CreateChannelInvite.cs View File

@@ -1,29 +0,0 @@
using Discord.Net.Rest;
using Newtonsoft.Json;

namespace Discord.API.Rest
{
[JsonObject(MemberSerialization.OptIn)]
public class CreateChannelInviteRequest : IRestRequest<Invite>
{
string IRestRequest.Method => "POST";
string IRestRequest.Endpoint => $"channels/{ChannelId}/invites";
object IRestRequest.Payload => this;

public ulong ChannelId { get; }

[JsonProperty("max_age")]
public int MaxAge { get; set; } = 86400; //24 Hours
[JsonProperty("max_uses")]
public int MaxUses { get; set; } = 0;
[JsonProperty("temporary")]
public bool IsTemporary { get; set; } = false;
[JsonProperty("xkcdpass")]
public bool WithXkcdPass { get; set; } = false;

public CreateChannelInviteRequest(ulong channelId)
{
ChannelId = channelId;
}
}
}

+ 16
- 0
src/Discord.Net/API/Rest/CreateChannelInviteParams.cs View File

@@ -0,0 +1,16 @@
using Newtonsoft.Json;

namespace Discord.API.Rest
{
public class CreateChannelInviteParams
{
[JsonProperty("max_age")]
public int MaxAge { get; set; } = 86400; //24 Hours
[JsonProperty("max_uses")]
public int MaxUses { get; set; } = 0;
[JsonProperty("temporary")]
public bool Temporary { get; set; } = false;
[JsonProperty("xkcdpass")]
public bool XkcdPass { get; set; } = false;
}
}

+ 0
- 16
src/Discord.Net/API/Rest/CreateDMChannel.cs View File

@@ -1,16 +0,0 @@
using Discord.Net.Rest;
using Newtonsoft.Json;

namespace Discord.API.Rest
{
[JsonObject(MemberSerialization.OptIn)]
public class CreateDMChannelRequest : IRestRequest<Channel>
{
string IRestRequest.Method => "POST";
string IRestRequest.Endpoint => $"users/@me/channels";
object IRestRequest.Payload => this;

[JsonProperty("recipient_id")]
public ulong RecipientId { get; set; }
}
}

+ 10
- 0
src/Discord.Net/API/Rest/CreateDMChannelParams.cs View File

@@ -0,0 +1,10 @@
using Newtonsoft.Json;

namespace Discord.API.Rest
{
public class CreateDMChannelParams
{
[JsonProperty("recipient_id")]
public ulong RecipientId { get; set; }
}
}

+ 0
- 24
src/Discord.Net/API/Rest/CreateGuildBan.cs View File

@@ -1,24 +0,0 @@
using Discord.Net.Rest;
using Newtonsoft.Json;

namespace Discord.API.Rest
{
public class CreateGuildBanRequest : IRestRequest
{
string IRestRequest.Method => "PUT";
string IRestRequest.Endpoint => $"guilds/{GuildId}/bans/{UserId}";
object IRestRequest.Payload => null;

public ulong GuildId { get; }
public ulong UserId { get; }

[JsonProperty("delete-message-days")]
public int PruneDays { get; set; } = 0;

public CreateGuildBanRequest(ulong guildId, ulong userId)
{
GuildId = guildId;
UserId = userId;
}
}
}

+ 10
- 0
src/Discord.Net/API/Rest/CreateGuildBanParams.cs View File

@@ -0,0 +1,10 @@
using Newtonsoft.Json;

namespace Discord.API.Rest
{
public class CreateGuildBanParams
{
[JsonProperty("delete-message-days")]
public int PruneDays { get; set; } = 0;
}
}

+ 0
- 27
src/Discord.Net/API/Rest/CreateGuildChannel.cs View File

@@ -1,27 +0,0 @@
using Discord.Net.Rest;
using Newtonsoft.Json;

namespace Discord.API.Rest
{
[JsonObject(MemberSerialization.OptIn)]
public class CreateGuildChannelRequest : IRestRequest<Channel>
{
string IRestRequest.Method => "POST";
string IRestRequest.Endpoint => $"guilds/{GuildId}/channels";
object IRestRequest.Payload => this;

public ulong GuildId { get; }

[JsonProperty("name")]
public string Name { get; set; }
[JsonProperty("type")]
public ChannelType Type { get; set; }
[JsonProperty("bitrate")]
public int Bitrate { get; set; }

public CreateGuildChannelRequest(ulong guildId)
{
GuildId = guildId;
}
}
}

+ 14
- 0
src/Discord.Net/API/Rest/CreateGuildChannelParams.cs View File

@@ -0,0 +1,14 @@
using Newtonsoft.Json;

namespace Discord.API.Rest
{
public class CreateGuildChannelParams
{
[JsonProperty("name")]
public string Name { get; set; }
[JsonProperty("type")]
public ChannelType Type { get; set; }
[JsonProperty("bitrate")]
public int Bitrate { get; set; }
}
}

+ 0
- 25
src/Discord.Net/API/Rest/CreateGuildIntegration.cs View File

@@ -1,25 +0,0 @@
using Discord.Net.Rest;
using Newtonsoft.Json;

namespace Discord.API.Rest
{
[JsonObject(MemberSerialization.OptIn)]
public class CreateGuildIntegrationRequest : IRestRequest<Integration>
{
string IRestRequest.Method => "POST";
string IRestRequest.Endpoint => $"guilds/{GuildId}/integrations";
object IRestRequest.Payload => this;

public ulong GuildId { get; }

[JsonProperty("id")]
public ulong IntegrationId { get; set; }
[JsonProperty("type")]
public string Type { get; set; }

public CreateGuildIntegrationRequest(ulong guildId)
{
GuildId = guildId;
}
}
}

+ 12
- 0
src/Discord.Net/API/Rest/CreateGuildIntegrationParams.cs View File

@@ -0,0 +1,12 @@
using Newtonsoft.Json;

namespace Discord.API.Rest
{
public class CreateGuildIntegrationParams
{
[JsonProperty("id")]
public ulong Id { get; set; }
[JsonProperty("type")]
public string Type { get; set; }
}
}

src/Discord.Net/API/Rest/CreateGuild.cs → src/Discord.Net/API/Rest/CreateGuildParams.cs View File

@@ -1,17 +1,11 @@
using Discord.Net.JsonConverters;
using Discord.Net.Rest;
using Discord.Net.Converters;
using Newtonsoft.Json; using Newtonsoft.Json;
using System.IO; using System.IO;


namespace Discord.API.Rest namespace Discord.API.Rest
{ {
[JsonObject(MemberSerialization.OptIn)]
public class CreateGuildRequest : IRestRequest<Guild>
public class CreateGuildParams
{ {
string IRestRequest.Method => "POST";
string IRestRequest.Endpoint => $"guilds";
object IRestRequest.Payload => this;

[JsonProperty("name")] [JsonProperty("name")]
public string Name { get; set; } public string Name { get; set; }
[JsonProperty("region")] [JsonProperty("region")]

+ 0
- 18
src/Discord.Net/API/Rest/CreateGuildRole.cs View File

@@ -1,18 +0,0 @@
using Discord.Net.Rest;

namespace Discord.API.Rest
{
public class CreateGuildRoleRequest : IRestRequest<Role>
{
string IRestRequest.Method => "POST";
string IRestRequest.Endpoint => $"guilds/{GuildId}/roles";
object IRestRequest.Payload => null;

public ulong GuildId { get; }

public CreateGuildRoleRequest(ulong guildId)
{
GuildId = guildId;
}
}
}

+ 0
- 27
src/Discord.Net/API/Rest/CreateMessage.cs View File

@@ -1,27 +0,0 @@
using Discord.Net.Rest;
using Newtonsoft.Json;

namespace Discord.API.Rest
{
[JsonObject(MemberSerialization.OptIn)]
public class CreateMessageRequest : IRestRequest<Message>
{
string IRestRequest.Method => "POST";
string IRestRequest.Endpoint => $"channels/{ChannelId}/messages";
object IRestRequest.Payload => this;

public ulong ChannelId { get; }

[JsonProperty("content")]
public string Content { get; set; }
[JsonProperty("nonce", NullValueHandling = NullValueHandling.Ignore)]
public string Nonce { get; set; } = null;
[JsonProperty("tts", DefaultValueHandling = DefaultValueHandling.Ignore)]
public bool IsTTS { get; set; } = false;

public CreateMessageRequest(ulong channelId)
{
ChannelId = channelId;
}
}
}

+ 14
- 0
src/Discord.Net/API/Rest/CreateMessageParams.cs View File

@@ -0,0 +1,14 @@
using Newtonsoft.Json;

namespace Discord.API.Rest
{
public class CreateMessageParams
{
[JsonProperty("content")]
public string Content { get; set; } = "";
[JsonProperty("nonce", NullValueHandling = NullValueHandling.Ignore)]
public string Nonce { get; set; } = null;
[JsonProperty("tts", DefaultValueHandling = DefaultValueHandling.Ignore)]
public bool IsTTS { get; set; } = false;
}
}

+ 0
- 18
src/Discord.Net/API/Rest/DeleteChannel.cs View File

@@ -1,18 +0,0 @@
using Discord.Net.Rest;

namespace Discord.API.Rest
{
public class DeleteChannelRequest : IRestRequest<Channel>
{
string IRestRequest.Method => "DELETE";
string IRestRequest.Endpoint => $"channels/{ChannelId}";
object IRestRequest.Payload => null;

public ulong ChannelId { get; }

public DeleteChannelRequest(ulong channelId)
{
ChannelId = channelId;
}
}
}

+ 0
- 20
src/Discord.Net/API/Rest/DeleteChannelPermission.cs View File

@@ -1,20 +0,0 @@
using Discord.Net.Rest;

namespace Discord.API.Rest
{
public class DeleteChannelPermissionsRequest : IRestRequest
{
string IRestRequest.Method => "DELETE";
string IRestRequest.Endpoint => $"channels/{ChannelId}/permissions/{TargetId}";
object IRestRequest.Payload => null;

public ulong ChannelId { get; }
public ulong TargetId { get; }

public DeleteChannelPermissionsRequest(ulong channelId, ulong targetId)
{
ChannelId = channelId;
TargetId = targetId;
}
}
}

+ 0
- 18
src/Discord.Net/API/Rest/DeleteGuild.cs View File

@@ -1,18 +0,0 @@
using Discord.Net.Rest;

namespace Discord.API.Rest
{
public class DeleteGuildRequest : IRestRequest<Guild>
{
string IRestRequest.Method => "DELETE";
string IRestRequest.Endpoint => $"guilds/{GuildId}";
object IRestRequest.Payload => null;

public ulong GuildId { get; }

public DeleteGuildRequest(ulong guildId)
{
GuildId = guildId;
}
}
}

+ 0
- 20
src/Discord.Net/API/Rest/DeleteGuildIntegration.cs View File

@@ -1,20 +0,0 @@
using Discord.Net.Rest;

namespace Discord.API.Rest
{
public class DeleteGuildIntegrationRequest : IRestRequest<Integration>
{
string IRestRequest.Method => "DELETE";
string IRestRequest.Endpoint => $"guilds/{GuildId}/integrations/{IntegrationId}";
object IRestRequest.Payload => null;

public ulong GuildId { get; }
public ulong IntegrationId { get; }

public DeleteGuildIntegrationRequest(ulong guildId, ulong integrationId)
{
GuildId = guildId;
IntegrationId = integrationId;
}
}
}

+ 0
- 20
src/Discord.Net/API/Rest/DeleteGuildRole.cs View File

@@ -1,20 +0,0 @@
using Discord.Net.Rest;

namespace Discord.API.Rest
{
public class DeleteGuildRoleRequest : IRestRequest
{
string IRestRequest.Method => "DELETE";
string IRestRequest.Endpoint => $"guilds/{GuildId}/roles/{RoleId}";
object IRestRequest.Payload => null;

public ulong GuildId { get; }
public ulong RoleId { get; }

public DeleteGuildRoleRequest(ulong guildId, ulong roleId)
{
GuildId = guildId;
RoleId = roleId;
}
}
}

+ 0
- 18
src/Discord.Net/API/Rest/DeleteInvite.cs View File

@@ -1,18 +0,0 @@
using Discord.Net.Rest;

namespace Discord.API.Rest
{
public class DeleteInviteRequest : IRestRequest<Invite>
{
string IRestRequest.Method => "DELETE";
string IRestRequest.Endpoint => $"invites/{InviteCode}";
object IRestRequest.Payload => null;

public string InviteCode { get; }

public DeleteInviteRequest(string inviteCode)
{
InviteCode = inviteCode;
}
}
}

+ 0
- 20
src/Discord.Net/API/Rest/DeleteMessage.cs View File

@@ -1,20 +0,0 @@
using Discord.Net.Rest;

namespace Discord.API.Rest
{
public class DeleteMessageRequest : IRestRequest
{
string IRestRequest.Method => "DELETE";
string IRestRequest.Endpoint => $"channels/{ChannelId}/messages/{MessageId}";
object IRestRequest.Payload => null;

public ulong ChannelId { get; }
public ulong MessageId { get; }

public DeleteMessageRequest(ulong channelId, ulong messageId)
{
ChannelId = channelId;
MessageId = messageId;
}
}
}

+ 11
- 0
src/Discord.Net/API/Rest/DeleteMessagesParam.cs View File

@@ -0,0 +1,11 @@
using Newtonsoft.Json;
using System.Collections.Generic;

namespace Discord.API.Rest
{
public class DeleteMessagesParam
{
[JsonProperty("messages")]
public IEnumerable<ulong> MessageIds { get; set; }
}
}

+ 0
- 18
src/Discord.Net/API/Rest/GetChannel.cs View File

@@ -1,18 +0,0 @@
using Discord.Net.Rest;

namespace Discord.API.Rest
{
public class GetChannelRequest : IRestRequest<Channel>
{
string IRestRequest.Method => "GET";
string IRestRequest.Endpoint => $"channels/{ChannelId}";
object IRestRequest.Payload => null;

public ulong ChannelId { get; }

public GetChannelRequest(ulong channelId)
{
ChannelId = channelId;
}
}
}

+ 0
- 20
src/Discord.Net/API/Rest/GetChannelInvites.cs View File

@@ -1,20 +0,0 @@
using Discord.Net.Rest;
using Newtonsoft.Json;

namespace Discord.API.Rest
{
[JsonObject(MemberSerialization.OptIn)]
public class GetChannelInvitesRequest : IRestRequest<InviteMetadata[]>
{
string IRestRequest.Method => "GET";
string IRestRequest.Endpoint => $"channels/{ChannelId}/invites";
object IRestRequest.Payload => null;

public ulong ChannelId { get; }

public GetChannelInvitesRequest(ulong channelId)
{
ChannelId = channelId;
}
}
}

+ 0
- 34
src/Discord.Net/API/Rest/GetChannelMessages.cs View File

@@ -1,34 +0,0 @@
using Discord.Net.Rest;
using Newtonsoft.Json;

namespace Discord.API.Rest
{
[JsonObject(MemberSerialization.OptIn)]
public class GetChannelMessagesRequest : IRestRequest<Message[]>
{
string IRestRequest.Method => "GET";
string IRestRequest.Endpoint => $"channels/{ChannelId}/messages?limit={Limit}&{RelativeDir}={RelativeId}";
object IRestRequest.Payload => null;

public ulong ChannelId { get; }

public Relative RelativeDir { get; set; }
public ulong RelativeId { get; set; } = 0;

[JsonProperty("limit")]
public int Limit { get; set; } = 100;

[JsonProperty("before")]
public ulong Before => RelativeId;
private bool ShouldSerializeBefore => RelativeDir == Relative.Before;

[JsonProperty("after")]
public ulong After => RelativeId;
private bool ShouldSerializeAfter => RelativeDir == Relative.After;

public GetChannelMessagesRequest(ulong channelId)
{
ChannelId = channelId;
}
}
}

+ 9
- 0
src/Discord.Net/API/Rest/GetChannelMessagesParams.cs View File

@@ -0,0 +1,9 @@
namespace Discord.API.Rest
{
public class GetChannelMessagesParams
{
public int Limit { get; set; } = DiscordConfig.MaxMessagesPerBatch;
public Direction RelativeDirection { get; set; } = Direction.Before;
public ulong? RelativeMessageId { get; set; } = null;
}
}

+ 0
- 11
src/Discord.Net/API/Rest/GetCurrentUser.cs View File

@@ -1,11 +0,0 @@
using Discord.Net.Rest;

namespace Discord.API.Rest
{
public class GetCurrentUserRequest : IRestRequest<User>
{
string IRestRequest.Method => "GET";
string IRestRequest.Endpoint => $"users/@me";
object IRestRequest.Payload => null;
}
}

+ 0
- 11
src/Discord.Net/API/Rest/GetCurrentUserConnections.cs View File

@@ -1,11 +0,0 @@
using Discord.Net.Rest;

namespace Discord.API.Rest
{
public class GetCurrentUserConnectionsRequest : IRestRequest<Connection[]>
{
string IRestRequest.Method => "GET";
string IRestRequest.Endpoint => $"users/@me/connections";
object IRestRequest.Payload => null;
}
}

+ 0
- 11
src/Discord.Net/API/Rest/GetCurrentUserDMs.cs View File

@@ -1,11 +0,0 @@
using Discord.Net.Rest;

namespace Discord.API.Rest
{
public class GetCurrentUserDMsRequest : IRestRequest<Channel[]>
{
string IRestRequest.Method => "GET";
string IRestRequest.Endpoint => $"users/@me/channels";
object IRestRequest.Payload => null;
}
}

+ 0
- 11
src/Discord.Net/API/Rest/GetCurrentUserGuilds.cs View File

@@ -1,11 +0,0 @@
using Discord.Net.Rest;

namespace Discord.API.Rest
{
public class GetCurrentUserGuildsRequest : IRestRequest<Guild[]>
{
string IRestRequest.Method => "GET";
string IRestRequest.Endpoint => $"users/@me/guilds";
object IRestRequest.Payload => null;
}
}

+ 0
- 18
src/Discord.Net/API/Rest/GetGateway.cs View File

@@ -1,18 +0,0 @@
using Discord.Net.Rest;
using Newtonsoft.Json;

namespace Discord.API.Rest
{
public class GetGatewayRequest : IRestRequest<GetGatewayResponse>
{
string IRestRequest.Method => "GET";
string IRestRequest.Endpoint => $"gateway";
object IRestRequest.Payload => null;
}
public class GetGatewayResponse
{
[JsonProperty("url")]
public string Url { get; set; }
}
}

src/Discord.Net/API/GatewaySocket/Unconfirmed/Events/Redirect.cs → src/Discord.Net/API/Rest/GetGatewayResponse.cs View File

@@ -1,8 +1,8 @@
using Newtonsoft.Json; using Newtonsoft.Json;


namespace Discord.API.GatewaySocket
namespace Discord.API.Rest
{ {
public class RedirectEvent
public class GetGatewayResponse
{ {
[JsonProperty("url")] [JsonProperty("url")]
public string Url { get; set; } public string Url { get; set; }

+ 0
- 18
src/Discord.Net/API/Rest/GetGuild.cs View File

@@ -1,18 +0,0 @@
using Discord.Net.Rest;

namespace Discord.API.Rest
{
public class GetGuildRequest : IRestRequest<Guild>
{
string IRestRequest.Method => "GET";
string IRestRequest.Endpoint => $"guilds/{GuildId}";
object IRestRequest.Payload => null;

public ulong GuildId { get; }

public GetGuildRequest(ulong guildId)
{
GuildId = guildId;
}
}
}

+ 0
- 18
src/Discord.Net/API/Rest/GetGuildBans.cs View File

@@ -1,18 +0,0 @@
using Discord.Net.Rest;

namespace Discord.API.Rest
{
public class GetGuildBansRequest : IRestRequest<User[]>
{
string IRestRequest.Method => "GET";
string IRestRequest.Endpoint => $"guilds/{GuildId}/bans";
object IRestRequest.Payload => null;

public ulong GuildId { get; }

public GetGuildBansRequest(ulong guildId)
{
GuildId = guildId;
}
}
}

+ 0
- 18
src/Discord.Net/API/Rest/GetGuildChannels.cs View File

@@ -1,18 +0,0 @@
using Discord.Net.Rest;

namespace Discord.API.Rest
{
public class GetGuildChannelsRequest : IRestRequest<Channel[]>
{
string IRestRequest.Method => "GET";
string IRestRequest.Endpoint => $"guild/{GuildId}/channels";
object IRestRequest.Payload => null;

public ulong GuildId { get; }

public GetGuildChannelsRequest(ulong guildId)
{
GuildId = guildId;
}
}
}

+ 0
- 18
src/Discord.Net/API/Rest/GetGuildEmbed.cs View File

@@ -1,18 +0,0 @@
using Discord.Net.Rest;

namespace Discord.API.Rest
{
public class GetGuildEmbedRequest : IRestRequest<GuildEmbed>
{
string IRestRequest.Method => "GET";
string IRestRequest.Endpoint => $"guilds/{GuildId}/embed";
object IRestRequest.Payload => null;

public ulong GuildId { get; }

public GetGuildEmbedRequest(ulong guildId)
{
GuildId = guildId;
}
}
}

+ 0
- 18
src/Discord.Net/API/Rest/GetGuildIntegrations.cs View File

@@ -1,18 +0,0 @@
using Discord.Net.Rest;

namespace Discord.API.Rest
{
public class GetGuildIntegrationsRequest : IRestRequest<Integration[]>
{
string IRestRequest.Method => "GET";
string IRestRequest.Endpoint => $"guilds/{GuildId}/integrations";
object IRestRequest.Payload => null;

public ulong GuildId { get; }

public GetGuildIntegrationsRequest(ulong guildId)
{
GuildId = guildId;
}
}
}

+ 0
- 18
src/Discord.Net/API/Rest/GetGuildInvites.cs View File

@@ -1,18 +0,0 @@
using Discord.Net.Rest;

namespace Discord.API.Rest
{
public class GetGuildInvitesRequest : IRestRequest<Invite[]>
{
string IRestRequest.Method => "GET";
string IRestRequest.Endpoint => $"guilds/{GuildId}/invites";
object IRestRequest.Payload => null;

public ulong GuildId { get; }

public GetGuildInvitesRequest(ulong guildId)
{
GuildId = guildId;
}
}
}

+ 0
- 20
src/Discord.Net/API/Rest/GetGuildMember.cs View File

@@ -1,20 +0,0 @@
using Discord.Net.Rest;

namespace Discord.API.Rest
{
public class GetGuildMemberRequest : IRestRequest<GuildMember>
{
string IRestRequest.Method => "GET";
string IRestRequest.Endpoint => $"guilds/{GuildId}/members/{UserId}";
object IRestRequest.Payload => null;

public ulong GuildId { get; }
public ulong UserId { get; }

public GetGuildMemberRequest(ulong guildId, ulong userId)
{
GuildId = guildId;
UserId = userId;
}
}
}

+ 8
- 0
src/Discord.Net/API/Rest/GetGuildMembersParams.cs View File

@@ -0,0 +1,8 @@
namespace Discord.API.Rest
{
public class GetGuildMembersParams
{
public int? Limit { get; set; } = null;
public int Offset { get; set; } = 0;
}
}

+ 0
- 29
src/Discord.Net/API/Rest/GetGuildPruneCount.cs View File

@@ -1,29 +0,0 @@
using Discord.Net.Rest;
using Newtonsoft.Json;

namespace Discord.API.Rest
{
[JsonObject(MemberSerialization.OptIn)]
public class GetGuildPruneCountRequest : IRestRequest<GetGuildPruneCountResponse>
{
string IRestRequest.Method => "GET";
string IRestRequest.Endpoint => $"guilds/{GuildId}/prune";
object IRestRequest.Payload => null;

public ulong GuildId { get; }

[JsonProperty("days")]
public int Days { get; set; } = 30;

public GetGuildPruneCountRequest(ulong guildId)
{
GuildId = guildId;
}
}

public class GetGuildPruneCountResponse
{
[JsonProperty("pruned")]
public int Pruned { get; set; }
}
}

+ 10
- 0
src/Discord.Net/API/Rest/GetGuildPruneCountResponse.cs View File

@@ -0,0 +1,10 @@
using Newtonsoft.Json;

namespace Discord.API.Rest
{
public class GetGuildPruneCountResponse
{
[JsonProperty("pruned")]
public int Pruned { get; set; }
}
}

+ 0
- 18
src/Discord.Net/API/Rest/GetGuildRoles.cs View File

@@ -1,18 +0,0 @@
using Discord.Net.Rest;

namespace Discord.API.Rest
{
public class GetGuildRolesRequest : IRestRequest<Role[]>
{
string IRestRequest.Method => "GET";
string IRestRequest.Endpoint => $"guild/{GuildId}/roles";
object IRestRequest.Payload => null;

public ulong GuildId { get; }

public GetGuildRolesRequest(ulong guildId)
{
GuildId = guildId;
}
}
}

Some files were not shown because too many files changed in this diff

Loading…
Cancel
Save