mirror of
https://github.com/yawaflua/Discord.Net.git
synced 2025-12-09 03:49:36 +02:00
Refactor and rename project to yawaflua.Discord.Net; add core entities and interfaces for Discord OAuth2 integration
This commit is contained in:
@@ -1,38 +1,85 @@
|
||||
using x3rt.DiscordOAuth2.Entities.Enums;
|
||||
using System.Text.Json.Serialization;
|
||||
using yawaflua.Discord.Net.Entities.Enums;
|
||||
using yawaflua.Discord.Net.Interfaces.Models;
|
||||
|
||||
namespace x3rt.DiscordOAuth2.Entities;
|
||||
namespace yawaflua.Discord.Net.Entities;
|
||||
|
||||
public class DiscordUser
|
||||
internal class DiscordUser : IUser
|
||||
{
|
||||
[JsonPropertyName("id")]
|
||||
public ulong Id { get; set; }
|
||||
|
||||
[JsonPropertyName("username")]
|
||||
public string Username { get; set; }
|
||||
|
||||
[JsonPropertyName("global_name")]
|
||||
public string GlobalName { get; set; }
|
||||
|
||||
[JsonPropertyName("discriminator")]
|
||||
public string Discriminator { get; set; }
|
||||
public string? Avatar { get; set; }
|
||||
|
||||
[JsonPropertyName("avatar")]
|
||||
public string? AvatarHash { get; set; }
|
||||
|
||||
[JsonPropertyName("bot")]
|
||||
public bool? Bot { get; set; }
|
||||
|
||||
[JsonPropertyName("system")]
|
||||
public bool? System { get; set; }
|
||||
|
||||
[JsonPropertyName("mfa_enabled")]
|
||||
public bool? MfaEnabled { get; set; }
|
||||
|
||||
[JsonPropertyName("banner")]
|
||||
public string? Banner { get; set; }
|
||||
|
||||
[JsonPropertyName("accent_color")]
|
||||
public int? AccentColor { get; set; }
|
||||
|
||||
[JsonPropertyName("locale")]
|
||||
public string? Locale { get; set; }
|
||||
|
||||
[JsonPropertyName("verified")]
|
||||
public bool? Verified { get; set; }
|
||||
|
||||
[JsonPropertyName("email")]
|
||||
public string? Email { get; set; }
|
||||
|
||||
[JsonPropertyName("flags")]
|
||||
public UserFlag? Flags { get; set; }
|
||||
|
||||
[JsonPropertyName("premium_type")]
|
||||
public PremiumType? PremiumType { get; set; }
|
||||
|
||||
[JsonPropertyName("public_flags")]
|
||||
public UserFlag? PublicFlags { get; set; }
|
||||
|
||||
[JsonPropertyName("avatar_decoration")]
|
||||
public AvatarDecoration? AvatarDecoration { get; set; }
|
||||
|
||||
public override string ToString()
|
||||
IAvatarDecoration IUser.AvatarDecoration
|
||||
{
|
||||
string result = "";
|
||||
foreach (var property in GetType().GetProperties())
|
||||
get => AvatarDecoration;
|
||||
set => AvatarDecoration = value as AvatarDecoration;
|
||||
}
|
||||
|
||||
public string GetAvatarUrl(int size = 128)
|
||||
{
|
||||
if (string.IsNullOrEmpty(AvatarHash))
|
||||
{
|
||||
var value = property.GetValue(this);
|
||||
if (value is not null)
|
||||
{
|
||||
result += $"{property.Name}: {value}; ";
|
||||
}
|
||||
return string.Empty;
|
||||
}
|
||||
|
||||
result = result.TrimEnd(' ', ';');
|
||||
return result;
|
||||
return $"https://cdn.discordapp.com/avatars/{Id}/{AvatarHash}.png?size={size}";
|
||||
}
|
||||
|
||||
public string GetBannerUrl(int size = 128)
|
||||
{
|
||||
if (string.IsNullOrEmpty(AvatarHash))
|
||||
{
|
||||
return string.Empty;
|
||||
}
|
||||
|
||||
return $"https://cdn.discordapp.com/banners/{Id}/{AvatarHash}.png?size={size}";
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user