Made API models internal. Removed Discord.Net.API.
This commit is contained in:
25
src/Discord.Net.WebSocket/API/Gateway/ExtendedGuild.cs
Normal file
25
src/Discord.Net.WebSocket/API/Gateway/ExtendedGuild.cs
Normal file
@@ -0,0 +1,25 @@
|
||||
#pragma warning disable CS1591
|
||||
using Newtonsoft.Json;
|
||||
using System;
|
||||
|
||||
namespace Discord.API.Gateway
|
||||
{
|
||||
internal class ExtendedGuild : Guild
|
||||
{
|
||||
[JsonProperty("unavailable")]
|
||||
public bool? Unavailable { get; set; }
|
||||
[JsonProperty("member_count")]
|
||||
public int MemberCount { get; set; }
|
||||
[JsonProperty("large")]
|
||||
public bool Large { get; set; }
|
||||
|
||||
[JsonProperty("presences")]
|
||||
public Presence[] Presences { get; set; }
|
||||
[JsonProperty("members")]
|
||||
public GuildMember[] Members { get; set; }
|
||||
[JsonProperty("channels")]
|
||||
public Channel[] Channels { get; set; }
|
||||
[JsonProperty("joined_at")]
|
||||
public DateTimeOffset JoinedAt { get; set; }
|
||||
}
|
||||
}
|
||||
33
src/Discord.Net.WebSocket/API/Gateway/GatewayOpCode.cs
Normal file
33
src/Discord.Net.WebSocket/API/Gateway/GatewayOpCode.cs
Normal file
@@ -0,0 +1,33 @@
|
||||
#pragma warning disable CS1591
|
||||
namespace Discord.API.Gateway
|
||||
{
|
||||
internal enum GatewayOpCode : 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. </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 members that were withheld by large_threshold </summary>
|
||||
RequestGuildMembers = 8,
|
||||
/// <summary> C←S - Used to notify the client that their session has expired and cannot be resumed. </summary>
|
||||
InvalidSession = 9,
|
||||
/// <summary> C←S - Used to provide information to the client immediately on connection. </summary>
|
||||
Hello = 10,
|
||||
/// <summary> C←S - Used to reply to a client's heartbeat. </summary>
|
||||
HeartbeatAck = 11,
|
||||
/// <summary> C→S - Used to request presence updates from particular guilds. </summary>
|
||||
GuildSync = 12
|
||||
}
|
||||
}
|
||||
13
src/Discord.Net.WebSocket/API/Gateway/GuildBanEvent.cs
Normal file
13
src/Discord.Net.WebSocket/API/Gateway/GuildBanEvent.cs
Normal file
@@ -0,0 +1,13 @@
|
||||
#pragma warning disable CS1591
|
||||
using Newtonsoft.Json;
|
||||
|
||||
namespace Discord.API.Gateway
|
||||
{
|
||||
internal class GuildBanEvent
|
||||
{
|
||||
[JsonProperty("guild_id")]
|
||||
public ulong GuildId { get; set; }
|
||||
[JsonProperty("user")]
|
||||
public User User { get; set; }
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,13 @@
|
||||
#pragma warning disable CS1591
|
||||
using Newtonsoft.Json;
|
||||
|
||||
namespace Discord.API.Gateway
|
||||
{
|
||||
internal class GuildEmojiUpdateEvent
|
||||
{
|
||||
[JsonProperty("guild_id")]
|
||||
public ulong GuildId { get; set; }
|
||||
[JsonProperty("emojis")]
|
||||
public Emoji[] Emojis { get; set; }
|
||||
}
|
||||
}
|
||||
11
src/Discord.Net.WebSocket/API/Gateway/GuildMemberAddEvent.cs
Normal file
11
src/Discord.Net.WebSocket/API/Gateway/GuildMemberAddEvent.cs
Normal file
@@ -0,0 +1,11 @@
|
||||
#pragma warning disable CS1591
|
||||
using Newtonsoft.Json;
|
||||
|
||||
namespace Discord.API.Gateway
|
||||
{
|
||||
internal class GuildMemberAddEvent : GuildMember
|
||||
{
|
||||
[JsonProperty("guild_id")]
|
||||
public ulong GuildId { get; set; }
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,13 @@
|
||||
#pragma warning disable CS1591
|
||||
using Newtonsoft.Json;
|
||||
|
||||
namespace Discord.API.Gateway
|
||||
{
|
||||
internal class GuildMemberRemoveEvent
|
||||
{
|
||||
[JsonProperty("guild_id")]
|
||||
public ulong GuildId { get; set; }
|
||||
[JsonProperty("user")]
|
||||
public User User { get; set; }
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
#pragma warning disable CS1591
|
||||
using Newtonsoft.Json;
|
||||
|
||||
namespace Discord.API.Gateway
|
||||
{
|
||||
internal class GuildMemberUpdateEvent : GuildMember
|
||||
{
|
||||
[JsonProperty("guild_id")]
|
||||
public ulong GuildId { get; set; }
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,13 @@
|
||||
#pragma warning disable CS1591
|
||||
using Newtonsoft.Json;
|
||||
|
||||
namespace Discord.API.Gateway
|
||||
{
|
||||
internal class GuildMembersChunkEvent
|
||||
{
|
||||
[JsonProperty("guild_id")]
|
||||
public ulong GuildId { get; set; }
|
||||
[JsonProperty("members")]
|
||||
public GuildMember[] Members { get; set; }
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,13 @@
|
||||
#pragma warning disable CS1591
|
||||
using Newtonsoft.Json;
|
||||
|
||||
namespace Discord.API.Gateway
|
||||
{
|
||||
internal class GuildRoleCreateEvent
|
||||
{
|
||||
[JsonProperty("guild_id")]
|
||||
public ulong GuildId { get; set; }
|
||||
[JsonProperty("role")]
|
||||
public Role Role { get; set; }
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,13 @@
|
||||
#pragma warning disable CS1591
|
||||
using Newtonsoft.Json;
|
||||
|
||||
namespace Discord.API.Gateway
|
||||
{
|
||||
internal class GuildRoleDeleteEvent
|
||||
{
|
||||
[JsonProperty("guild_id")]
|
||||
public ulong GuildId { get; set; }
|
||||
[JsonProperty("role_id")]
|
||||
public ulong RoleId { get; set; }
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,13 @@
|
||||
#pragma warning disable CS1591
|
||||
using Newtonsoft.Json;
|
||||
|
||||
namespace Discord.API.Gateway
|
||||
{
|
||||
internal class GuildRoleUpdateEvent
|
||||
{
|
||||
[JsonProperty("guild_id")]
|
||||
public ulong GuildId { get; set; }
|
||||
[JsonProperty("role")]
|
||||
public Role Role { get; set; }
|
||||
}
|
||||
}
|
||||
18
src/Discord.Net.WebSocket/API/Gateway/GuildSyncEvent.cs
Normal file
18
src/Discord.Net.WebSocket/API/Gateway/GuildSyncEvent.cs
Normal file
@@ -0,0 +1,18 @@
|
||||
#pragma warning disable CS1591
|
||||
using Newtonsoft.Json;
|
||||
|
||||
namespace Discord.API.Gateway
|
||||
{
|
||||
internal class GuildSyncEvent
|
||||
{
|
||||
[JsonProperty("id")]
|
||||
public ulong Id { get; set; }
|
||||
[JsonProperty("large")]
|
||||
public bool Large { get; set; }
|
||||
|
||||
[JsonProperty("presences")]
|
||||
public Presence[] Presences { get; set; }
|
||||
[JsonProperty("members")]
|
||||
public GuildMember[] Members { get; set; }
|
||||
}
|
||||
}
|
||||
11
src/Discord.Net.WebSocket/API/Gateway/HelloEvent.cs
Normal file
11
src/Discord.Net.WebSocket/API/Gateway/HelloEvent.cs
Normal file
@@ -0,0 +1,11 @@
|
||||
#pragma warning disable CS1591
|
||||
using Newtonsoft.Json;
|
||||
|
||||
namespace Discord.API.Gateway
|
||||
{
|
||||
internal class HelloEvent
|
||||
{
|
||||
[JsonProperty("heartbeat_interval")]
|
||||
public int HeartbeatInterval { get; set; }
|
||||
}
|
||||
}
|
||||
21
src/Discord.Net.WebSocket/API/Gateway/IdentifyParams.cs
Normal file
21
src/Discord.Net.WebSocket/API/Gateway/IdentifyParams.cs
Normal file
@@ -0,0 +1,21 @@
|
||||
#pragma warning disable CS1591
|
||||
using Newtonsoft.Json;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace Discord.API.Gateway
|
||||
{
|
||||
[JsonObject(MemberSerialization = MemberSerialization.OptIn)]
|
||||
internal class IdentifyParams
|
||||
{
|
||||
[JsonProperty("token")]
|
||||
public string Token { get; set; }
|
||||
[JsonProperty("properties")]
|
||||
public IDictionary<string, string> Properties { get; set; }
|
||||
[JsonProperty("large_threshold")]
|
||||
public int LargeThreshold { get; set; }
|
||||
[JsonProperty("compress")]
|
||||
public bool UseCompression { get; set; }
|
||||
[JsonProperty("shard")]
|
||||
public Optional<int[]> ShardingParams { get; set; }
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,14 @@
|
||||
#pragma warning disable CS1591
|
||||
using Newtonsoft.Json;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace Discord.API.Gateway
|
||||
{
|
||||
internal class MessageDeleteBulkEvent
|
||||
{
|
||||
[JsonProperty("channel_id")]
|
||||
public ulong ChannelId { get; set; }
|
||||
[JsonProperty("ids")]
|
||||
public IEnumerable<ulong> Ids { get; set; }
|
||||
}
|
||||
}
|
||||
16
src/Discord.Net.WebSocket/API/Gateway/Reaction.cs
Normal file
16
src/Discord.Net.WebSocket/API/Gateway/Reaction.cs
Normal file
@@ -0,0 +1,16 @@
|
||||
using Newtonsoft.Json;
|
||||
|
||||
namespace Discord.API.Gateway
|
||||
{
|
||||
internal class Reaction
|
||||
{
|
||||
[JsonProperty("user_id")]
|
||||
public ulong UserId { get; set; }
|
||||
[JsonProperty("message_id")]
|
||||
public ulong MessageId { get; set; }
|
||||
[JsonProperty("channel_id")]
|
||||
public ulong ChannelId { get; set; }
|
||||
[JsonProperty("emoji")]
|
||||
public Emoji Emoji { get; set; }
|
||||
}
|
||||
}
|
||||
38
src/Discord.Net.WebSocket/API/Gateway/ReadyEvent.cs
Normal file
38
src/Discord.Net.WebSocket/API/Gateway/ReadyEvent.cs
Normal file
@@ -0,0 +1,38 @@
|
||||
#pragma warning disable CS1591
|
||||
using Newtonsoft.Json;
|
||||
|
||||
namespace Discord.API.Gateway
|
||||
{
|
||||
internal 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("relationships")]
|
||||
public Relationship[] Relationships { get; set; }
|
||||
|
||||
//Ignored
|
||||
/*[JsonProperty("user_settings")]
|
||||
[JsonProperty("user_guild_settings")]
|
||||
[JsonProperty("tutorial")]*/
|
||||
}
|
||||
}
|
||||
13
src/Discord.Net.WebSocket/API/Gateway/RecipientEvent.cs
Normal file
13
src/Discord.Net.WebSocket/API/Gateway/RecipientEvent.cs
Normal file
@@ -0,0 +1,13 @@
|
||||
#pragma warning disable CS1591
|
||||
using Newtonsoft.Json;
|
||||
|
||||
namespace Discord.API.Gateway
|
||||
{
|
||||
internal class RecipientEvent
|
||||
{
|
||||
[JsonProperty("user")]
|
||||
public User User { get; set; }
|
||||
[JsonProperty("channel_id")]
|
||||
public ulong ChannelId { get; set; }
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
using Newtonsoft.Json;
|
||||
|
||||
namespace Discord.API.Gateway
|
||||
{
|
||||
internal class RemoveAllReactionsEvent
|
||||
{
|
||||
[JsonProperty("channel_id")]
|
||||
public ulong ChannelId { get; set; }
|
||||
[JsonProperty("message_id")]
|
||||
public ulong MessageId { get; set; }
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,18 @@
|
||||
#pragma warning disable CS1591
|
||||
using Newtonsoft.Json;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace Discord.API.Gateway
|
||||
{
|
||||
[JsonObject(MemberSerialization = MemberSerialization.OptIn)]
|
||||
internal class RequestMembersParams
|
||||
{
|
||||
[JsonProperty("query")]
|
||||
public string Query { get; set; }
|
||||
[JsonProperty("limit")]
|
||||
public int Limit { get; set; }
|
||||
|
||||
[JsonProperty("guild_id")]
|
||||
public IEnumerable<ulong> GuildIds { get; set; }
|
||||
}
|
||||
}
|
||||
16
src/Discord.Net.WebSocket/API/Gateway/ResumeParams.cs
Normal file
16
src/Discord.Net.WebSocket/API/Gateway/ResumeParams.cs
Normal file
@@ -0,0 +1,16 @@
|
||||
#pragma warning disable CS1591
|
||||
using Newtonsoft.Json;
|
||||
|
||||
namespace Discord.API.Gateway
|
||||
{
|
||||
[JsonObject(MemberSerialization = MemberSerialization.OptIn)]
|
||||
internal class ResumeParams
|
||||
{
|
||||
[JsonProperty("token")]
|
||||
public string Token { get; set; }
|
||||
[JsonProperty("session_id")]
|
||||
public string SessionId { get; set; }
|
||||
[JsonProperty("seq")]
|
||||
public int Sequence { get; set; }
|
||||
}
|
||||
}
|
||||
11
src/Discord.Net.WebSocket/API/Gateway/ResumedEvent.cs
Normal file
11
src/Discord.Net.WebSocket/API/Gateway/ResumedEvent.cs
Normal file
@@ -0,0 +1,11 @@
|
||||
#pragma warning disable CS1591
|
||||
using Newtonsoft.Json;
|
||||
|
||||
namespace Discord.API.Gateway
|
||||
{
|
||||
internal class ResumedEvent
|
||||
{
|
||||
[JsonProperty("heartbeat_interval")]
|
||||
public int HeartbeatInterval { get; set; }
|
||||
}
|
||||
}
|
||||
18
src/Discord.Net.WebSocket/API/Gateway/StatusUpdateParams.cs
Normal file
18
src/Discord.Net.WebSocket/API/Gateway/StatusUpdateParams.cs
Normal file
@@ -0,0 +1,18 @@
|
||||
#pragma warning disable CS1591
|
||||
using Newtonsoft.Json;
|
||||
|
||||
namespace Discord.API.Gateway
|
||||
{
|
||||
[JsonObject(MemberSerialization = MemberSerialization.OptIn)]
|
||||
internal class StatusUpdateParams
|
||||
{
|
||||
[JsonProperty("status")]
|
||||
public UserStatus Status { get; set; }
|
||||
[JsonProperty("since"), Int53]
|
||||
public long? IdleSince { get; set; }
|
||||
[JsonProperty("afk")]
|
||||
public bool IsAFK { get; set; }
|
||||
[JsonProperty("game")]
|
||||
public Game Game { get; set; }
|
||||
}
|
||||
}
|
||||
15
src/Discord.Net.WebSocket/API/Gateway/TypingStartEvent.cs
Normal file
15
src/Discord.Net.WebSocket/API/Gateway/TypingStartEvent.cs
Normal file
@@ -0,0 +1,15 @@
|
||||
#pragma warning disable CS1591
|
||||
using Newtonsoft.Json;
|
||||
|
||||
namespace Discord.API.Gateway
|
||||
{
|
||||
internal 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,0 +1,15 @@
|
||||
#pragma warning disable CS1591
|
||||
using Newtonsoft.Json;
|
||||
|
||||
namespace Discord.API.Gateway
|
||||
{
|
||||
internal 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,0 +1,19 @@
|
||||
#pragma warning disable CS1591
|
||||
using Newtonsoft.Json;
|
||||
|
||||
namespace Discord.API.Gateway
|
||||
{
|
||||
[JsonObject(MemberSerialization = MemberSerialization.OptIn)]
|
||||
internal class VoiceStateUpdateParams
|
||||
{
|
||||
[JsonProperty("self_mute")]
|
||||
public bool SelfMute { get; set; }
|
||||
[JsonProperty("self_deaf")]
|
||||
public bool SelfDeaf { get; set; }
|
||||
|
||||
[JsonProperty("guild_id")]
|
||||
public ulong? GuildId { get; set; }
|
||||
[JsonProperty("channel_id")]
|
||||
public ulong? ChannelId { get; set; }
|
||||
}
|
||||
}
|
||||
17
src/Discord.Net.WebSocket/API/Voice/IdentifyParams.cs
Normal file
17
src/Discord.Net.WebSocket/API/Voice/IdentifyParams.cs
Normal file
@@ -0,0 +1,17 @@
|
||||
#pragma warning disable CS1591
|
||||
using Newtonsoft.Json;
|
||||
|
||||
namespace Discord.API.Voice
|
||||
{
|
||||
internal class IdentifyParams
|
||||
{
|
||||
[JsonProperty("server_id")]
|
||||
public ulong GuildId { get; set; }
|
||||
[JsonProperty("user_id")]
|
||||
public ulong UserId { get; set; }
|
||||
[JsonProperty("session_id")]
|
||||
public string SessionId { get; set; }
|
||||
[JsonProperty("token")]
|
||||
public string Token { get; set; }
|
||||
}
|
||||
}
|
||||
17
src/Discord.Net.WebSocket/API/Voice/ReadyEvent.cs
Normal file
17
src/Discord.Net.WebSocket/API/Voice/ReadyEvent.cs
Normal file
@@ -0,0 +1,17 @@
|
||||
#pragma warning disable CS1591
|
||||
using Newtonsoft.Json;
|
||||
|
||||
namespace Discord.API.Voice
|
||||
{
|
||||
internal class ReadyEvent
|
||||
{
|
||||
[JsonProperty("ssrc")]
|
||||
public uint SSRC { get; set; }
|
||||
[JsonProperty("port")]
|
||||
public ushort Port { get; set; }
|
||||
[JsonProperty("modes")]
|
||||
public string[] Modes { get; set; }
|
||||
[JsonProperty("heartbeat_interval")]
|
||||
public int HeartbeatInterval { get; set; }
|
||||
}
|
||||
}
|
||||
13
src/Discord.Net.WebSocket/API/Voice/SelectProtocolParams.cs
Normal file
13
src/Discord.Net.WebSocket/API/Voice/SelectProtocolParams.cs
Normal file
@@ -0,0 +1,13 @@
|
||||
#pragma warning disable CS1591
|
||||
using Newtonsoft.Json;
|
||||
|
||||
namespace Discord.API.Voice
|
||||
{
|
||||
internal class SelectProtocolParams
|
||||
{
|
||||
[JsonProperty("protocol")]
|
||||
public string Protocol { get; set; }
|
||||
[JsonProperty("data")]
|
||||
public UdpProtocolInfo Data { get; set; }
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,13 @@
|
||||
#pragma warning disable CS1591
|
||||
using Newtonsoft.Json;
|
||||
|
||||
namespace Discord.API.Voice
|
||||
{
|
||||
internal class SessionDescriptionEvent
|
||||
{
|
||||
[JsonProperty("secret_key")]
|
||||
public byte[] SecretKey { get; set; }
|
||||
[JsonProperty("mode")]
|
||||
public string Mode { get; set; }
|
||||
}
|
||||
}
|
||||
13
src/Discord.Net.WebSocket/API/Voice/SpeakingParams.cs
Normal file
13
src/Discord.Net.WebSocket/API/Voice/SpeakingParams.cs
Normal file
@@ -0,0 +1,13 @@
|
||||
#pragma warning disable CS1591
|
||||
using Newtonsoft.Json;
|
||||
|
||||
namespace Discord.API.Voice
|
||||
{
|
||||
internal class SpeakingParams
|
||||
{
|
||||
[JsonProperty("speaking")]
|
||||
public bool IsSpeaking { get; set; }
|
||||
[JsonProperty("delay")]
|
||||
public int Delay { get; set; }
|
||||
}
|
||||
}
|
||||
15
src/Discord.Net.WebSocket/API/Voice/UdpProtocolInfo.cs
Normal file
15
src/Discord.Net.WebSocket/API/Voice/UdpProtocolInfo.cs
Normal file
@@ -0,0 +1,15 @@
|
||||
#pragma warning disable CS1591
|
||||
using Newtonsoft.Json;
|
||||
|
||||
namespace Discord.API.Voice
|
||||
{
|
||||
internal class UdpProtocolInfo
|
||||
{
|
||||
[JsonProperty("address")]
|
||||
public string Address { get; set; }
|
||||
[JsonProperty("port")]
|
||||
public int Port { get; set; }
|
||||
[JsonProperty("mode")]
|
||||
public string Mode { get; set; }
|
||||
}
|
||||
}
|
||||
21
src/Discord.Net.WebSocket/API/Voice/VoiceOpCode.cs
Normal file
21
src/Discord.Net.WebSocket/API/Voice/VoiceOpCode.cs
Normal file
@@ -0,0 +1,21 @@
|
||||
#pragma warning disable CS1591
|
||||
namespace Discord.API.Voice
|
||||
{
|
||||
internal enum VoiceOpCode : byte
|
||||
{
|
||||
/// <summary> C→S - Used to associate a connection with a token. </summary>
|
||||
Identify = 0,
|
||||
/// <summary> C→S - Used to specify configuration. </summary>
|
||||
SelectProtocol = 1,
|
||||
/// <summary> C←S - Used to notify that the voice connection was successful and informs the client of available protocols. </summary>
|
||||
Ready = 2,
|
||||
/// <summary> C→S - Used to keep the connection alive and measure latency. </summary>
|
||||
Heartbeat = 3,
|
||||
/// <summary> C←S - Used to reply to a client's heartbeat. </summary>
|
||||
HeartbeatAck = 3,
|
||||
/// <summary> C←S - Used to provide an encryption key to the client. </summary>
|
||||
SessionDescription = 4,
|
||||
/// <summary> C↔S - Used to inform that a certain user is speaking. </summary>
|
||||
Speaking = 5
|
||||
}
|
||||
}
|
||||
@@ -17,7 +17,6 @@
|
||||
<EmbeddedResource Include="**\*.resx" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\Discord.Net.API\Discord.Net.API.csproj" />
|
||||
<ProjectReference Include="..\Discord.Net.Core\Discord.Net.Core.csproj" />
|
||||
<ProjectReference Include="..\Discord.Net.Rest\Discord.Net.Rest.csproj" />
|
||||
</ItemGroup>
|
||||
|
||||
@@ -22,7 +22,7 @@ namespace Discord.WebSocket
|
||||
internal UserStatus Status => _shards[0].Status;
|
||||
internal Game? Game => _shards[0].Game;
|
||||
|
||||
public new DiscordSocketApiClient ApiClient => base.ApiClient as DiscordSocketApiClient;
|
||||
internal new DiscordSocketApiClient ApiClient => base.ApiClient as DiscordSocketApiClient;
|
||||
public new SocketSelfUser CurrentUser { get { return base.CurrentUser as SocketSelfUser; } private set { base.CurrentUser = value; } }
|
||||
public IReadOnlyCollection<SocketGuild> Guilds => GetGuilds().ToReadOnlyCollection(() => GetGuildCount());
|
||||
public IReadOnlyCollection<ISocketPrivateChannel> PrivateChannels => GetPrivateChannels().ToReadOnlyCollection(() => GetPrivateChannelCount());
|
||||
@@ -150,11 +150,8 @@ namespace Discord.WebSocket
|
||||
|
||||
public DiscordSocketClient GetShard(int id)
|
||||
{
|
||||
for (int i = 0; i < _shards.Length; i++)
|
||||
{
|
||||
if (_shards[i].ShardId == id)
|
||||
return _shards[i];
|
||||
}
|
||||
if (_shardIdsToIndex.TryGetValue(id, out id))
|
||||
return _shards[id];
|
||||
return null;
|
||||
}
|
||||
private int GetShardIdFor(ulong guildId)
|
||||
@@ -162,12 +159,7 @@ namespace Discord.WebSocket
|
||||
private int GetShardIdFor(IGuild guild)
|
||||
=> GetShardIdFor(guild.Id);
|
||||
private DiscordSocketClient GetShardFor(ulong guildId)
|
||||
{
|
||||
int id = GetShardIdFor(guildId);
|
||||
if (_shardIdsToIndex.TryGetValue(id, out id))
|
||||
return _shards[id];
|
||||
return null;
|
||||
}
|
||||
=> GetShard(GetShardIdFor(guildId));
|
||||
private DiscordSocketClient GetShardFor(IGuild guild)
|
||||
=> GetShardFor(guild.Id);
|
||||
|
||||
|
||||
@@ -16,7 +16,7 @@ using System.Threading.Tasks;
|
||||
|
||||
namespace Discord.API
|
||||
{
|
||||
public class DiscordSocketApiClient : DiscordRestApiClient
|
||||
internal class DiscordSocketApiClient : DiscordRestApiClient
|
||||
{
|
||||
public event Func<GatewayOpCode, Task> SentGatewayMessage { add { _sentGatewayMessageEvent.Add(value); } remove { _sentGatewayMessageEvent.Remove(value); } }
|
||||
private readonly AsyncEvent<Func<GatewayOpCode, Task>> _sentGatewayMessageEvent = new AsyncEvent<Func<GatewayOpCode, Task>>();
|
||||
|
||||
@@ -60,7 +60,7 @@ namespace Discord.WebSocket
|
||||
internal WebSocketProvider WebSocketProvider { get; private set; }
|
||||
internal bool DownloadUsersOnGuildAvailable { get; private set; }
|
||||
|
||||
public new DiscordSocketApiClient ApiClient => base.ApiClient as DiscordSocketApiClient;
|
||||
internal new DiscordSocketApiClient ApiClient => base.ApiClient as DiscordSocketApiClient;
|
||||
public new SocketSelfUser CurrentUser { get { return base.CurrentUser as SocketSelfUser; } private set { base.CurrentUser = value; } }
|
||||
public IReadOnlyCollection<SocketGuild> Guilds => State.Guilds;
|
||||
public IReadOnlyCollection<ISocketPrivateChannel> PrivateChannels => State.PrivateChannels;
|
||||
|
||||
@@ -16,7 +16,7 @@ using System.Threading.Tasks;
|
||||
|
||||
namespace Discord.Audio
|
||||
{
|
||||
public class DiscordVoiceAPIClient
|
||||
internal class DiscordVoiceAPIClient
|
||||
{
|
||||
public const int MaxBitrate = 128 * 1024;
|
||||
public const string Mode = "xsalsa20_poly1305";
|
||||
|
||||
@@ -11,7 +11,7 @@ namespace Discord.WebSocket
|
||||
IReadOnlyCollection<SocketMessage> CachedMessages { get; }
|
||||
|
||||
/// <summary> Sends a message to this message channel. </summary>
|
||||
new Task<RestUserMessage> SendMessageAsync(string text, bool isTTS = false, EmbedBuilder embed = null, RequestOptions options = null);
|
||||
new Task<RestUserMessage> SendMessageAsync(string text, bool isTTS = false, Embed embed = null, RequestOptions options = null);
|
||||
#if NETSTANDARD1_3
|
||||
/// <summary> Sends a file to this text channel, with an optional caption. </summary>
|
||||
new Task<RestUserMessage> SendFileAsync(string filePath, string text = null, bool isTTS = false, RequestOptions options = null);
|
||||
|
||||
@@ -66,7 +66,7 @@ namespace Discord.WebSocket
|
||||
public Task<IReadOnlyCollection<RestMessage>> GetPinnedMessagesAsync(RequestOptions options = null)
|
||||
=> ChannelHelper.GetPinnedMessagesAsync(this, Discord, options);
|
||||
|
||||
public Task<RestUserMessage> SendMessageAsync(string text, bool isTTS = false, EmbedBuilder embed = null, RequestOptions options = null)
|
||||
public Task<RestUserMessage> SendMessageAsync(string text, bool isTTS = false, Embed embed = null, RequestOptions options = null)
|
||||
=> ChannelHelper.SendMessageAsync(this, Discord, text, isTTS, embed, options);
|
||||
#if NETSTANDARD1_3
|
||||
public Task<RestUserMessage> SendFileAsync(string filePath, string text, bool isTTS = false, RequestOptions options = null)
|
||||
@@ -138,7 +138,7 @@ namespace Discord.WebSocket
|
||||
#endif
|
||||
async Task<IUserMessage> IMessageChannel.SendFileAsync(Stream stream, string filename, string text, bool isTTS, RequestOptions options)
|
||||
=> await SendFileAsync(stream, filename, text, isTTS, options).ConfigureAwait(false);
|
||||
async Task<IUserMessage> IMessageChannel.SendMessageAsync(string text, bool isTTS, EmbedBuilder embed, RequestOptions options)
|
||||
async Task<IUserMessage> IMessageChannel.SendMessageAsync(string text, bool isTTS, Embed embed, RequestOptions options)
|
||||
=> await SendMessageAsync(text, isTTS, embed, options).ConfigureAwait(false);
|
||||
IDisposable IMessageChannel.EnterTypingState(RequestOptions options)
|
||||
=> EnterTypingState(options);
|
||||
|
||||
@@ -95,7 +95,7 @@ namespace Discord.WebSocket
|
||||
public Task<IReadOnlyCollection<RestMessage>> GetPinnedMessagesAsync(RequestOptions options = null)
|
||||
=> ChannelHelper.GetPinnedMessagesAsync(this, Discord, options);
|
||||
|
||||
public Task<RestUserMessage> SendMessageAsync(string text, bool isTTS = false, EmbedBuilder embed = null, RequestOptions options = null)
|
||||
public Task<RestUserMessage> SendMessageAsync(string text, bool isTTS = false, Embed embed = null, RequestOptions options = null)
|
||||
=> ChannelHelper.SendMessageAsync(this, Discord, text, isTTS, embed, options);
|
||||
#if NETSTANDARD1_3
|
||||
public Task<RestUserMessage> SendFileAsync(string filePath, string text, bool isTTS = false, RequestOptions options = null)
|
||||
@@ -207,7 +207,7 @@ namespace Discord.WebSocket
|
||||
#endif
|
||||
async Task<IUserMessage> IMessageChannel.SendFileAsync(Stream stream, string filename, string text, bool isTTS, RequestOptions options)
|
||||
=> await SendFileAsync(stream, filename, text, isTTS, options).ConfigureAwait(false);
|
||||
async Task<IUserMessage> IMessageChannel.SendMessageAsync(string text, bool isTTS, EmbedBuilder embed, RequestOptions options)
|
||||
async Task<IUserMessage> IMessageChannel.SendMessageAsync(string text, bool isTTS, Embed embed, RequestOptions options)
|
||||
=> await SendMessageAsync(text, isTTS, embed, options).ConfigureAwait(false);
|
||||
IDisposable IMessageChannel.EnterTypingState(RequestOptions options)
|
||||
=> EnterTypingState(options);
|
||||
|
||||
@@ -47,7 +47,7 @@ namespace Discord.WebSocket
|
||||
var overwrites = model.PermissionOverwrites.Value;
|
||||
var newOverwrites = ImmutableArray.CreateBuilder<Overwrite>(overwrites.Length);
|
||||
for (int i = 0; i < overwrites.Length; i++)
|
||||
newOverwrites.Add(new Overwrite(overwrites[i]));
|
||||
newOverwrites.Add(overwrites[i].ToEntity());
|
||||
_overwrites = newOverwrites.ToImmutable();
|
||||
}
|
||||
|
||||
@@ -77,12 +77,12 @@ namespace Discord.WebSocket
|
||||
public async Task AddPermissionOverwriteAsync(IUser user, OverwritePermissions perms, RequestOptions options = null)
|
||||
{
|
||||
await ChannelHelper.AddPermissionOverwriteAsync(this, Discord, user, perms, options).ConfigureAwait(false);
|
||||
_overwrites = _overwrites.Add(new Overwrite(new API.Overwrite { Allow = perms.AllowValue, Deny = perms.DenyValue, TargetId = user.Id, TargetType = PermissionTarget.User }));
|
||||
_overwrites = _overwrites.Add(new Overwrite(user.Id, PermissionTarget.User, new OverwritePermissions(perms.AllowValue, perms.DenyValue)));
|
||||
}
|
||||
public async Task AddPermissionOverwriteAsync(IRole role, OverwritePermissions perms, RequestOptions options = null)
|
||||
{
|
||||
await ChannelHelper.AddPermissionOverwriteAsync(this, Discord, role, perms, options).ConfigureAwait(false);
|
||||
_overwrites.Add(new Overwrite(new API.Overwrite { Allow = perms.AllowValue, Deny = perms.DenyValue, TargetId = role.Id, TargetType = PermissionTarget.Role }));
|
||||
_overwrites = _overwrites.Add(new Overwrite(role.Id, PermissionTarget.Role, new OverwritePermissions(perms.AllowValue, perms.DenyValue)));
|
||||
}
|
||||
public async Task RemovePermissionOverwriteAsync(IUser user, RequestOptions options = null)
|
||||
{
|
||||
|
||||
@@ -72,7 +72,7 @@ namespace Discord.WebSocket
|
||||
public Task<IReadOnlyCollection<RestMessage>> GetPinnedMessagesAsync(RequestOptions options = null)
|
||||
=> ChannelHelper.GetPinnedMessagesAsync(this, Discord, options);
|
||||
|
||||
public Task<RestUserMessage> SendMessageAsync(string text, bool isTTS = false, EmbedBuilder embed = null, RequestOptions options = null)
|
||||
public Task<RestUserMessage> SendMessageAsync(string text, bool isTTS = false, Embed embed = null, RequestOptions options = null)
|
||||
=> ChannelHelper.SendMessageAsync(this, Discord, text, isTTS, embed, options);
|
||||
#if NETSTANDARD1_3
|
||||
public Task<RestUserMessage> SendFileAsync(string filePath, string text, bool isTTS = false, RequestOptions options = null)
|
||||
@@ -139,7 +139,7 @@ namespace Discord.WebSocket
|
||||
#endif
|
||||
async Task<IUserMessage> IMessageChannel.SendFileAsync(Stream stream, string filename, string text, bool isTTS, RequestOptions options)
|
||||
=> await SendFileAsync(stream, filename, text, isTTS, options).ConfigureAwait(false);
|
||||
async Task<IUserMessage> IMessageChannel.SendMessageAsync(string text, bool isTTS, EmbedBuilder embed, RequestOptions options)
|
||||
async Task<IUserMessage> IMessageChannel.SendMessageAsync(string text, bool isTTS, Embed embed, RequestOptions options)
|
||||
=> await SendMessageAsync(text, isTTS, embed, options).ConfigureAwait(false);
|
||||
IDisposable IMessageChannel.EnterTypingState(RequestOptions options)
|
||||
=> EnterTypingState(options);
|
||||
|
||||
@@ -191,7 +191,7 @@ namespace Discord.WebSocket
|
||||
{
|
||||
var emojis = ImmutableArray.CreateBuilder<GuildEmoji>(model.Emojis.Length);
|
||||
for (int i = 0; i < model.Emojis.Length; i++)
|
||||
emojis.Add(GuildEmoji.Create(model.Emojis[i]));
|
||||
emojis.Add(model.Emojis[i].ToEntity());
|
||||
_emojis = emojis.ToImmutable();
|
||||
}
|
||||
else
|
||||
@@ -244,7 +244,7 @@ namespace Discord.WebSocket
|
||||
{
|
||||
var emojis = ImmutableArray.CreateBuilder<GuildEmoji>(model.Emojis.Length);
|
||||
for (int i = 0; i < model.Emojis.Length; i++)
|
||||
emojis.Add(GuildEmoji.Create(model.Emojis[i]));
|
||||
emojis.Add(model.Emojis[i].ToEntity());
|
||||
_emojis = emojis.ToImmutable();
|
||||
}
|
||||
|
||||
|
||||
@@ -22,7 +22,7 @@ namespace Discord.WebSocket
|
||||
}
|
||||
internal static SocketReaction Create(Model model, ISocketMessageChannel channel, Optional<SocketUserMessage> message, Optional<IUser> user)
|
||||
{
|
||||
return new SocketReaction(channel, model.MessageId, message, model.UserId, user, Emoji.Create(model.Emoji));
|
||||
return new SocketReaction(channel, model.MessageId, message, model.UserId, user, new Emoji(model.Emoji.Id, model.Emoji.Name));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -79,7 +79,7 @@ namespace Discord.WebSocket
|
||||
{
|
||||
var embeds = ImmutableArray.CreateBuilder<Embed>(value.Length);
|
||||
for (int i = 0; i < value.Length; i++)
|
||||
embeds.Add(Embed.Create(value[i]));
|
||||
embeds.Add(value[i].ToEntity());
|
||||
_embeds = embeds.ToImmutable();
|
||||
}
|
||||
else
|
||||
|
||||
@@ -17,11 +17,11 @@ namespace Discord.WebSocket
|
||||
}
|
||||
internal static SocketPresence Create(Model model)
|
||||
{
|
||||
return new SocketPresence(model.Status, model.Game != null ? Discord.Game.Create(model.Game) : (Game?)null);
|
||||
return new SocketPresence(model.Status, model.Game != null ? model.Game.ToEntity() : (Game?)null);
|
||||
}
|
||||
|
||||
public override string ToString() => Status.ToString();
|
||||
internal string DebuggerDisplay => $"{Status}{(Game != null ? $", {Game.Value.Name} ({Game.Value.StreamType})" : "")}";
|
||||
private string DebuggerDisplay => $"{Status}{(Game != null ? $", {Game.Value.Name} ({Game.Value.StreamType})" : "")}";
|
||||
|
||||
internal SocketPresence Clone() => this;
|
||||
}
|
||||
|
||||
@@ -46,7 +46,7 @@ namespace Discord.WebSocket
|
||||
=> UserHelper.CreateDMChannelAsync(this, Discord, options);
|
||||
|
||||
public override string ToString() => $"{Username}#{Discriminator}";
|
||||
internal string DebuggerDisplay => $"{Username}#{Discriminator} ({Id}{(IsBot ? ", Bot" : "")})";
|
||||
private string DebuggerDisplay => $"{Username}#{Discriminator} ({Id}{(IsBot ? ", Bot" : "")})";
|
||||
internal SocketUser Clone() => MemberwiseClone() as SocketUser;
|
||||
|
||||
//IUser
|
||||
|
||||
@@ -56,7 +56,7 @@ namespace Discord.WebSocket
|
||||
}
|
||||
|
||||
public override string ToString() => VoiceChannel?.Name ?? "Unknown";
|
||||
internal string DebuggerDisplay => $"{VoiceChannel?.Name ?? "Unknown"} ({_voiceStates})";
|
||||
private string DebuggerDisplay => $"{VoiceChannel?.Name ?? "Unknown"} ({_voiceStates})";
|
||||
internal SocketVoiceState Clone() => this;
|
||||
|
||||
IVoiceChannel IVoiceState.VoiceChannel => VoiceChannel;
|
||||
|
||||
12
src/Discord.Net.WebSocket/Extensions/EntityExtensions.cs
Normal file
12
src/Discord.Net.WebSocket/Extensions/EntityExtensions.cs
Normal file
@@ -0,0 +1,12 @@
|
||||
namespace Discord.WebSocket
|
||||
{
|
||||
internal static class EntityExtensions
|
||||
{
|
||||
public static Game ToEntity(this API.Game model)
|
||||
{
|
||||
return new Game(model.Name,
|
||||
model.StreamUrl.GetValueOrDefault(null),
|
||||
model.StreamType.GetValueOrDefault(null) ?? StreamType.NotStreaming);
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user