Implemented missing method and typing notifier
This commit is contained in:
@@ -207,8 +207,6 @@ namespace Discord.Rest
|
||||
|
||||
//Typing
|
||||
public static IDisposable EnterTypingState(IChannel channel, BaseDiscordClient client)
|
||||
{
|
||||
throw new NotImplementedException(); //TODO: Impl
|
||||
}
|
||||
=> new TypingNotifier(client, channel);
|
||||
}
|
||||
}
|
||||
|
||||
44
src/Discord.Net.Rest/Utils/TypingNotifier.cs
Normal file
44
src/Discord.Net.Rest/Utils/TypingNotifier.cs
Normal file
@@ -0,0 +1,44 @@
|
||||
using System;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace Discord.Rest
|
||||
{
|
||||
internal class TypingNotifier : IDisposable
|
||||
{
|
||||
private readonly BaseDiscordClient _client;
|
||||
private readonly CancellationTokenSource _cancelToken;
|
||||
private readonly ulong _channelId;
|
||||
|
||||
public TypingNotifier(BaseDiscordClient discord, IChannel channel)
|
||||
{
|
||||
_client = discord;
|
||||
_cancelToken = new CancellationTokenSource();
|
||||
_channelId = channel.Id;
|
||||
var _ = Run();
|
||||
}
|
||||
|
||||
private async Task Run()
|
||||
{
|
||||
try
|
||||
{
|
||||
var token = _cancelToken.Token;
|
||||
while (!_cancelToken.IsCancellationRequested)
|
||||
{
|
||||
try
|
||||
{
|
||||
await _client.ApiClient.TriggerTypingIndicatorAsync(_channelId);
|
||||
}
|
||||
catch { }
|
||||
await Task.Delay(4500, token);
|
||||
}
|
||||
}
|
||||
catch (OperationCanceledException) { }
|
||||
}
|
||||
|
||||
public void Dispose()
|
||||
{
|
||||
_cancelToken.Cancel();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -24,9 +24,9 @@ namespace Discord.WebSocket
|
||||
public override string Username { get { return GlobalUser.Username; } internal set { GlobalUser.Username = value; } }
|
||||
public override ushort DiscriminatorValue { get { return GlobalUser.DiscriminatorValue; } internal set { GlobalUser.DiscriminatorValue = value; } }
|
||||
public override string AvatarId { get { return GlobalUser.AvatarId; } internal set { GlobalUser.AvatarId = value; } }
|
||||
internal override SocketPresence Presence { get { return GlobalUser.Presence; } set { GlobalUser.Presence = value; } }
|
||||
public GuildPermissions GuildPermissions => new GuildPermissions(Permissions.ResolveGuild(Guild, this));
|
||||
public IReadOnlyCollection<ulong> RoleIds => _roleIds;
|
||||
internal override SocketPresence Presence { get { return GlobalUser.Presence; } set { GlobalUser.Presence = value; } }
|
||||
|
||||
public SocketVoiceState? VoiceState => Guild.GetVoiceState(Id);
|
||||
public bool IsSelfDeafened => VoiceState?.IsSelfDeafened ?? false;
|
||||
@@ -88,9 +88,7 @@ namespace Discord.WebSocket
|
||||
=> UserHelper.KickAsync(this, Discord);
|
||||
|
||||
public ChannelPermissions GetPermissions(IGuildChannel channel)
|
||||
{
|
||||
throw new NotImplementedException(); //TODO: Impl
|
||||
}
|
||||
=> new ChannelPermissions(Permissions.ResolveChannel(Guild, this, channel, GuildPermissions.RawValue));
|
||||
|
||||
internal new SocketGuildUser Clone() => MemberwiseClone() as SocketGuildUser;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user