using System;
using System.Collections.Generic;
using System.Collections.Immutable;
using System.Diagnostics;
using System.Threading.Tasks;
using Model = Discord.API.User;
namespace Discord.WebSocket
{
///
/// Represents a WebSocket-based webhook user.
///
[DebuggerDisplay(@"{DebuggerDisplay,nq}")]
public class SocketWebhookUser : SocketUser, IWebhookUser
{
#region SocketWebhookUser
/// Gets the guild of this webhook.
public SocketGuild Guild { get; }
///
public ulong WebhookId { get; }
///
public override string Username { get; internal set; }
///
public override ushort DiscriminatorValue { get; internal set; }
///
public override string AvatarId { get; internal set; }
///
public override string GlobalName { get; internal set; }
///
public override string AvatarDecorationHash { get; internal set; }
///
public override ulong? AvatarDecorationSkuId { get; internal set; }
///
public override PrimaryGuild? PrimaryGuild { get; internal set; }
///
public override bool IsBot { get; internal set; }
///
public override bool IsWebhook => true;
///
internal override SocketPresence Presence { get { return new SocketPresence(UserStatus.Offline, null, null); } set { } }
internal override SocketGlobalUser GlobalUser { get => throw new NotImplementedException(); set => throw new NotImplementedException(); }
internal SocketWebhookUser(SocketGuild guild, ulong id, ulong webhookId)
: base(guild.Discord, id)
{
Guild = guild;
WebhookId = webhookId;
}
internal static SocketWebhookUser Create(SocketGuild guild, ClientState state, Model model, ulong webhookId)
{
var entity = new SocketWebhookUser(guild, model.Id, webhookId);
entity.Update(state, model);
return entity;
}
private string DebuggerDisplay => DiscriminatorValue != 0
? $"{Username}#{Discriminator} ({Id}{(IsBot ? ", Bot" : "")}, Webhook)"
: $"{Username} ({Id}{(IsBot ? ", Bot" : "")}, Webhook)";
internal new SocketWebhookUser Clone() => MemberwiseClone() as SocketWebhookUser;
#endregion
#region IGuildUser
///
IGuild IGuildUser.Guild => Guild;
///
ulong IGuildUser.GuildId => Guild.Id;
///
IReadOnlyCollection IGuildUser.RoleIds => ImmutableArray.Create();
///
DateTimeOffset? IGuildUser.JoinedAt => null;
///
string IGuildUser.DisplayName => null;
///
string IGuildUser.Nickname => null;
///
string IGuildUser.DisplayAvatarId => null;
///
string IGuildUser.GuildAvatarId => null;
///
string IGuildUser.GuildBannerHash => null;
///
string IGuildUser.GetGuildAvatarUrl(ImageFormat format, ushort size) => null;
///
string IGuildUser.GetGuildBannerUrl(ImageFormat format, ushort size) => null;
///
DateTimeOffset? IGuildUser.PremiumSince => null;
///
DateTimeOffset? IGuildUser.TimedOutUntil => null;
///
bool? IGuildUser.IsPending => null;
///
int IGuildUser.Hierarchy => 0;
///
GuildPermissions IGuildUser.GuildPermissions => GuildPermissions.Webhook;
///
GuildUserFlags IGuildUser.Flags => GuildUserFlags.None;
///
ChannelPermissions IGuildUser.GetPermissions(IGuildChannel channel) => Permissions.ToChannelPerms(channel, GuildPermissions.Webhook.RawValue);
///
/// Webhook users cannot be kicked.
Task IGuildUser.KickAsync(string reason, RequestOptions options) =>
throw new NotSupportedException("Webhook users cannot be kicked.");
///
/// Webhook users cannot be modified.
Task IGuildUser.ModifyAsync(Action func, RequestOptions options) =>
throw new NotSupportedException("Webhook users cannot be modified.");
///
/// Roles are not supported on webhook users.
Task IGuildUser.AddRoleAsync(ulong roleId, RequestOptions options) =>
throw new NotSupportedException("Roles are not supported on webhook users.");
///
/// Roles are not supported on webhook users.
Task IGuildUser.AddRoleAsync(IRole role, RequestOptions options) =>
throw new NotSupportedException("Roles are not supported on webhook users.");
///
/// Roles are not supported on webhook users.
Task IGuildUser.AddRolesAsync(IEnumerable roleIds, RequestOptions options) =>
throw new NotSupportedException("Roles are not supported on webhook users.");
///
/// Roles are not supported on webhook users.
Task IGuildUser.AddRolesAsync(IEnumerable roles, RequestOptions options) =>
throw new NotSupportedException("Roles are not supported on webhook users.");
///
/// Roles are not supported on webhook users.
Task IGuildUser.RemoveRoleAsync(ulong roleId, RequestOptions options) =>
throw new NotSupportedException("Roles are not supported on webhook users.");
///
/// Roles are not supported on webhook users.
Task IGuildUser.RemoveRoleAsync(IRole role, RequestOptions options) =>
throw new NotSupportedException("Roles are not supported on webhook users.");
///
/// Roles are not supported on webhook users.
Task IGuildUser.RemoveRolesAsync(IEnumerable roles, RequestOptions options) =>
throw new NotSupportedException("Roles are not supported on webhook users.");
///
/// Roles are not supported on webhook users.
Task IGuildUser.RemoveRolesAsync(IEnumerable roles, RequestOptions options) =>
throw new NotSupportedException("Roles are not supported on webhook users.");
///
/// Timeouts are not supported on webhook users.
Task IGuildUser.SetTimeOutAsync(TimeSpan span, RequestOptions options) =>
throw new NotSupportedException("Timeouts are not supported on webhook users.");
///
/// Timeouts are not supported on webhook users.
Task IGuildUser.RemoveTimeOutAsync(RequestOptions options) =>
throw new NotSupportedException("Timeouts are not supported on webhook users.");
#endregion
#region IVoiceState
///
bool IVoiceState.IsDeafened => false;
///
bool IVoiceState.IsMuted => false;
///
bool IVoiceState.IsSelfDeafened => false;
///
bool IVoiceState.IsSelfMuted => false;
///
bool IVoiceState.IsSuppressed => false;
///
IVoiceChannel IVoiceState.VoiceChannel => null;
///
string IVoiceState.VoiceSessionId => null;
///
bool IVoiceState.IsStreaming => false;
///
bool IVoiceState.IsVideoing => false;
///
DateTimeOffset? IVoiceState.RequestToSpeakTimestamp => null;
#endregion
}
}