@@ -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 |
@@ -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 | |||
@@ -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); | |||
@@ -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<MessageAckEvent>(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 | |||
@@ -5,13 +5,6 @@ using System.Text; | |||
namespace Discord | |||
{ | |||
public enum DiscordMode | |||
{ | |||
/// <summary> Enable bot-only functions. Use this mode if you are creating a bot, automated application, or interface. </summary> | |||
Bot = 0, | |||
/// <summary> Enables client-only functions. Use this mode if you are creating a custom client. </summary> | |||
Client | |||
} | |||
public enum LogSeverity : byte | |||
{ | |||
Error = 1, | |||
@@ -52,9 +45,6 @@ namespace Discord | |||
/// <summary> Enables or disables the default event logger. </summary> | |||
public bool LogEvents { get { return _logEvents; } set { SetValue(ref _logEvents, value); } } | |||
private bool _logEvents = true; | |||
/// <summary> Specifies the mode that this application should run in. </summary> | |||
public DiscordMode Mode { get { return _mode; } set { SetValue(ref _mode, value); } } | |||
private DiscordMode _mode = DiscordMode.Bot; | |||
/// <summary> User Agent string to use when connecting to Discord. </summary> | |||
public string UserAgent { get; private set; } | |||
@@ -11,12 +11,10 @@ namespace Discord.Legacy | |||
[Obsolete("Use User.Mention instead")] | |||
public static string User(User user) | |||
=> user.Mention; | |||
/// <summary> Returns the string used to create a channel mention. </summary> | |||
[Obsolete("Use Channel.Mention instead")] | |||
public static string Channel(Channel channel) | |||
=> channel.Mention; | |||
/// <summary> Returns the string used to create a mention to everyone in a channel. </summary> | |||
[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<Message> 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<ulong>(), | |||
channel.Id, | |||
x["UserId"].Value<ulong>()); | |||
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<Message> ImportMessages(Channel channel, string json) | |||
{ | |||
throw new InvalidOperationException(); | |||
} | |||
[Obsolete("Use Channel.ExportMessages", true)] | |||
public static string ExportMessages(Channel channel) | |||
{ | |||
throw new InvalidOperationException(); | |||
} | |||
} | |||
} |
@@ -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; | |||
} | |||
/// <summary> Returns true if the logged-in user was mentioned. </summary> | |||
public bool IsMentioningMe(bool includeRoles = false) | |||