Added remaining gateway events, added IAudioChannel, added CacheModes
This commit is contained in:
@@ -1,11 +1,8 @@
|
||||
using Discord.Rest;
|
||||
using Discord.WebSocket;
|
||||
using System;
|
||||
using System;
|
||||
using System.Collections.Concurrent;
|
||||
using System.Collections.Generic;
|
||||
using System.Collections.Immutable;
|
||||
using System.Linq;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace Discord.WebSocket
|
||||
{
|
||||
@@ -51,7 +48,7 @@ namespace Discord.WebSocket
|
||||
return result;
|
||||
return null;
|
||||
}
|
||||
public IImmutableList<SocketMessage> GetMany(ulong? fromMessageId, Direction dir, int limit = DiscordConfig.MaxMessagesPerBatch)
|
||||
public IReadOnlyCollection<SocketMessage> GetMany(ulong? fromMessageId, Direction dir, int limit = DiscordConfig.MaxMessagesPerBatch)
|
||||
{
|
||||
if (limit < 0) throw new ArgumentOutOfRangeException(nameof(limit));
|
||||
if (limit == 0) return ImmutableArray<SocketMessage>.Empty;
|
||||
|
||||
@@ -2,13 +2,12 @@
|
||||
using System.Collections.Generic;
|
||||
using System.Collections.Immutable;
|
||||
using System.Diagnostics;
|
||||
using System.Threading.Tasks;
|
||||
using Model = Discord.API.Message;
|
||||
|
||||
namespace Discord.WebSocket
|
||||
{
|
||||
[DebuggerDisplay(@"{DebuggerDisplay,nq}")]
|
||||
public abstract class SocketMessage : SocketEntity<ulong>, IMessage, IUpdateable
|
||||
public abstract class SocketMessage : SocketEntity<ulong>, IMessage
|
||||
{
|
||||
private long _timestampTicks;
|
||||
|
||||
@@ -35,14 +34,14 @@ namespace Discord.WebSocket
|
||||
ChannelId = channelId;
|
||||
Author = author;
|
||||
}
|
||||
internal static SocketMessage Create(DiscordSocketClient discord, SocketUser author, Model model)
|
||||
internal static SocketMessage Create(DiscordSocketClient discord, ClientState state, SocketUser author, Model model)
|
||||
{
|
||||
if (model.Type == MessageType.Default)
|
||||
return SocketUserMessage.Create(discord, author, model);
|
||||
return SocketUserMessage.Create(discord, state, author, model);
|
||||
else
|
||||
return SocketSystemMessage.Create(discord, author, model);
|
||||
return SocketSystemMessage.Create(discord, state, author, model);
|
||||
}
|
||||
internal virtual void Update(Model model)
|
||||
internal virtual void Update(ClientState state, Model model)
|
||||
{
|
||||
if (model.Timestamp.IsSpecified)
|
||||
_timestampTicks = model.Timestamp.Value.UtcTicks;
|
||||
@@ -50,12 +49,8 @@ namespace Discord.WebSocket
|
||||
if (model.Content.IsSpecified)
|
||||
Content = model.Content.Value;
|
||||
}
|
||||
|
||||
public async Task UpdateAsync()
|
||||
{
|
||||
var model = await Discord.ApiClient.GetChannelMessageAsync(ChannelId, Id).ConfigureAwait(false);
|
||||
Update(model);
|
||||
}
|
||||
|
||||
internal SocketMessage Clone() => MemberwiseClone() as SocketMessage;
|
||||
|
||||
//IMessage
|
||||
IUser IMessage.Author => Author;
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
using Discord.Rest;
|
||||
using Model = Discord.API.Message;
|
||||
using Model = Discord.API.Message;
|
||||
|
||||
namespace Discord.WebSocket
|
||||
{
|
||||
@@ -11,17 +10,21 @@ namespace Discord.WebSocket
|
||||
: base(discord, id, channelId, author)
|
||||
{
|
||||
}
|
||||
internal new static SocketSystemMessage Create(DiscordSocketClient discord, SocketUser author, Model model)
|
||||
internal new static SocketSystemMessage Create(DiscordSocketClient discord, ClientState state, SocketUser author, Model model)
|
||||
{
|
||||
var entity = new SocketSystemMessage(discord, model.Id, model.ChannelId, author);
|
||||
entity.Update(model);
|
||||
entity.Update(state, model);
|
||||
return entity;
|
||||
}
|
||||
internal override void Update(Model model)
|
||||
internal override void Update(ClientState state, Model model)
|
||||
{
|
||||
base.Update(model);
|
||||
base.Update(state, model);
|
||||
|
||||
Type = model.Type;
|
||||
}
|
||||
|
||||
public override string ToString() => Content;
|
||||
private string DebuggerDisplay => $"{Author}: {Content} ({Id}, {Type})";
|
||||
internal new SocketSystemMessage Clone() => MemberwiseClone() as SocketSystemMessage;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -8,7 +8,7 @@ using Model = Discord.API.Message;
|
||||
|
||||
namespace Discord.WebSocket
|
||||
{
|
||||
internal class SocketUserMessage : SocketMessage, IUserMessage
|
||||
public class SocketUserMessage : SocketMessage, IUserMessage
|
||||
{
|
||||
private bool _isMentioningEveryone, _isTTS, _isPinned;
|
||||
private long? _editedTimestampTicks;
|
||||
@@ -32,16 +32,16 @@ namespace Discord.WebSocket
|
||||
: base(discord, id, channelId, author)
|
||||
{
|
||||
}
|
||||
internal new static SocketUserMessage Create(DiscordSocketClient discord, SocketUser author, Model model)
|
||||
internal new static SocketUserMessage Create(DiscordSocketClient discord, ClientState state, SocketUser author, Model model)
|
||||
{
|
||||
var entity = new SocketUserMessage(discord, model.Id, model.ChannelId, author);
|
||||
entity.Update(model);
|
||||
entity.Update(state, model);
|
||||
return entity;
|
||||
}
|
||||
|
||||
internal override void Update(Model model)
|
||||
internal override void Update(ClientState state, Model model)
|
||||
{
|
||||
base.Update(model);
|
||||
base.Update(state, model);
|
||||
|
||||
if (model.IsTextToSpeech.IsSpecified)
|
||||
_isTTS = model.IsTextToSpeech.Value;
|
||||
@@ -129,5 +129,9 @@ namespace Discord.WebSocket
|
||||
text = MentionsHelper.ResolveEveryoneMentions(text, everyoneHandling);
|
||||
return text;
|
||||
}
|
||||
|
||||
public override string ToString() => Content;
|
||||
private string DebuggerDisplay => $"{Author}: {Content} ({Id}{(Attachments.Count > 0 ? $", {Attachments.Count} Attachments" : "")}";
|
||||
internal new SocketUserMessage Clone() => MemberwiseClone() as SocketUserMessage;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user