diff --git a/docs/features/modes.rst b/docs/features/modes.rst deleted file mode 100644 index 63a5922c3..000000000 --- a/docs/features/modes.rst +++ /dev/null @@ -1,23 +0,0 @@ -Modes -====== - -Usage ------ -Using this library requires you to state the intention of the program using it. -By default, the library assumes your application is a bot or otherwise automated program, and locks access to certain client-only features. -As we approach the official API, Discord will be creating a divide between bots and clients, so it's important to use the mode appropriate for your program to minimize breaking changes! - -.. warning:: - This is not a complete list, new features will be added in the future. - -Client-Only Features --------------------- - -- Message Acknowledgement (Message.Acknowledge(), DiscordClient.MessageAcknowledged) -- Message Importing/Exporting -- Message Read States - -Bot-Only Features ------------------ - -- Currently, None diff --git a/docs/index.rst b/docs/index.rst index 6a9e5889d..c4469cd46 100644 --- a/docs/index.rst +++ b/docs/index.rst @@ -28,7 +28,6 @@ This Documentation is **currently undergoing a rewrite**. Some pages (marked wit :maxdepth: 2 getting_started - features/modes features/logging features/management features/permissions diff --git a/src/Discord.Net.Audio/Net/VoiceSocket.cs b/src/Discord.Net.Audio/Net/VoiceSocket.cs index 8bc195a33..985e5d549 100644 --- a/src/Discord.Net.Audio/Net/VoiceSocket.cs +++ b/src/Discord.Net.Audio/Net/VoiceSocket.cs @@ -295,10 +295,10 @@ namespace Discord.Net.WebSockets int rtpPacketLength = 0; voicePacket[0] = 0x80; //Flags; voicePacket[1] = 0x78; //Payload Type - voicePacket[8] = (byte)((_ssrc >> 24) & 0xFF); - voicePacket[9] = (byte)((_ssrc >> 16) & 0xFF); - voicePacket[10] = (byte)((_ssrc >> 8) & 0xFF); - voicePacket[11] = (byte)((_ssrc >> 0) & 0xFF); + voicePacket[8] = (byte)(_ssrc >> 24); + voicePacket[9] = (byte)(_ssrc >> 16); + voicePacket[10] = (byte)(_ssrc >> 8); + voicePacket[11] = (byte)(_ssrc >> 0); if (_isEncrypted) Buffer.BlockCopy(voicePacket, 0, nonce, 0, 12); @@ -309,12 +309,12 @@ namespace Discord.Net.WebSockets if (!hasFrame && _sendBuffer.Pop(frame)) { ushort sequence = unchecked(_sequence++); - voicePacket[2] = (byte)((sequence >> 8) & 0xFF); - voicePacket[3] = (byte)((sequence >> 0) & 0xFF); - voicePacket[4] = (byte)((timestamp >> 24) & 0xFF); - voicePacket[5] = (byte)((timestamp >> 16) & 0xFF); - voicePacket[6] = (byte)((timestamp >> 8) & 0xFF); - voicePacket[7] = (byte)((timestamp >> 0) & 0xFF); + voicePacket[2] = (byte)(sequence >> 8); + voicePacket[3] = (byte)(sequence >> 0); + voicePacket[4] = (byte)(timestamp >> 24); + voicePacket[5] = (byte)(timestamp >> 16); + voicePacket[6] = (byte)(timestamp >> 8); + voicePacket[7] = (byte)(timestamp >> 0); //Encode int encodedLength = _encoder.EncodeFrame(frame, 0, encodedFrame); diff --git a/src/Discord.Net/DiscordClient.cs b/src/Discord.Net/DiscordClient.cs index 8b5f563bb..74bd91fbc 100644 --- a/src/Discord.Net/DiscordClient.cs +++ b/src/Discord.Net/DiscordClient.cs @@ -878,24 +878,6 @@ namespace Discord Logger.Warning("MESSAGE_DELETE referenced an unknown channel."); } break; - case "MESSAGE_ACK": - { - if (Config.Mode == DiscordMode.Client) - { - var data = e.Payload.ToObject(Serializer); - var channel = GetChannel(data.ChannelId); - if (channel != null) - { - var msg = channel.GetMessage(data.MessageId, null); - if (Config.LogEvents) - Logger.Verbose($"Message Ack: {channel.Server?.Name ?? "[Private]"}/{channel.Name}"); - OnMessageAcknowledged(msg); - } - else - Logger.Warning("MESSAGE_ACK referenced an unknown channel."); - } - } - break; //Statuses case "PRESENCE_UPDATE": @@ -1014,6 +996,7 @@ namespace Discord case "GUILD_INTEGRATIONS_UPDATE": case "VOICE_SERVER_UPDATE": case "GUILD_EMOJIS_UPDATE": + case "MESSAGE_ACK": break; //Others diff --git a/src/Discord.Net/DiscordConfig.cs b/src/Discord.Net/DiscordConfig.cs index 89f746fcd..7fd338288 100644 --- a/src/Discord.Net/DiscordConfig.cs +++ b/src/Discord.Net/DiscordConfig.cs @@ -5,13 +5,6 @@ using System.Text; namespace Discord { - public enum DiscordMode - { - /// Enable bot-only functions. Use this mode if you are creating a bot, automated application, or interface. - Bot = 0, - /// Enables client-only functions. Use this mode if you are creating a custom client. - Client - } public enum LogSeverity : byte { Error = 1, @@ -52,9 +45,6 @@ namespace Discord /// Enables or disables the default event logger. public bool LogEvents { get { return _logEvents; } set { SetValue(ref _logEvents, value); } } private bool _logEvents = true; - /// Specifies the mode that this application should run in. - public DiscordMode Mode { get { return _mode; } set { SetValue(ref _mode, value); } } - private DiscordMode _mode = DiscordMode.Bot; /// User Agent string to use when connecting to Discord. public string UserAgent { get; private set; } diff --git a/src/Discord.Net/Legacy.cs b/src/Discord.Net/Legacy.cs index e74494508..2f9af0bff 100644 --- a/src/Discord.Net/Legacy.cs +++ b/src/Discord.Net/Legacy.cs @@ -11,12 +11,10 @@ namespace Discord.Legacy [Obsolete("Use User.Mention instead")] public static string User(User user) => user.Mention; - /// Returns the string used to create a channel mention. [Obsolete("Use Channel.Mention instead")] public static string Channel(Channel channel) => channel.Mention; - /// Returns the string used to create a mention to everyone in a channel. [Obsolete("Use Server.EveryoneRole.Mention instead")] public static string Everyone() @@ -180,50 +178,6 @@ namespace Discord.Legacy return channel.DownloadMessages(limit, relativeMessageId, relativeDir, useCache); } - [Obsolete("Use Message.Acknowledge")] - public static Task AckMessage(this DiscordClient client, Message message) - { - if (message == null) throw new ArgumentNullException(nameof(message)); - return message.Acknowledge(); - } - - /*[Obsolete("Use Channel.ImportMessages")] - public IEnumerable ImportMessages(Channel channel, string json) - { - if (json == null) throw new ArgumentNullException(nameof(json)); - - var dic = JArray.Parse(json) - .Select(x => - { - var msg = new Message(this, - x["Id"].Value(), - channel.Id, - x["UserId"].Value()); - - var reader = x.CreateReader(); - _messageImporter.Populate(reader, msg); - msg.Text = Mention.Resolve(msg, msg.RawText); - return msg; - }) - .ToDictionary(x => x.Id); - _messages.Import(dic); - foreach (var msg in dic.Values) - { - var user = msg.User; - if (user != null) - user.UpdateActivity(msg.EditedTimestamp ?? msg.Timestamp); - } - return dic.Values; - } - - [Obsolete("Use Channel.ExportMessages")] - public string ExportMessages(Channel channel) - { - if (channel == null) throw new ArgumentNullException(nameof(channel)); - - return JsonConvert.SerializeObject(channel.Messages); - }*/ - [Obsolete("Use Server.GetUser")] public static User GetUser(this DiscordClient client, Server server, ulong userId) { @@ -405,5 +359,21 @@ namespace Discord.Legacy if (channel == null) throw new ArgumentNullException(nameof(channel)); return channel.RemovePermissionsRule(role); } + + [Obsolete("Removed", true)] + public static Task AckMessage(this DiscordClient client, Message message) + { + throw new InvalidOperationException(); + } + [Obsolete("Use Channel.ImportMessages", true)] + public static IEnumerable ImportMessages(Channel channel, string json) + { + throw new InvalidOperationException(); + } + [Obsolete("Use Channel.ExportMessages", true)] + public static string ExportMessages(Channel channel) + { + throw new InvalidOperationException(); + } } } diff --git a/src/Discord.Net/Models/Message.cs b/src/Discord.Net/Models/Message.cs index c1fd59bb8..f1a4f5c51 100644 --- a/src/Discord.Net/Models/Message.cs +++ b/src/Discord.Net/Models/Message.cs @@ -341,17 +341,6 @@ namespace Discord catch (HttpException ex) when (ex.StatusCode == HttpStatusCode.NotFound) { } } } - - public Task Acknowledge() - { - if (Client.Config.Mode != DiscordMode.Client) - throw new InvalidOperationException("This function may only be used in Client mode."); - - if (User.Id != Client.CurrentUser.Id) - return Client.ClientAPI.Send(new AckMessageRequest(Channel.Id, Id)); - else - return TaskHelper.CompletedTask; - } /// Returns true if the logged-in user was mentioned. public bool IsMentioningMe(bool includeRoles = false)