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:
9
Interfaces/IDiscord.cs
Normal file
9
Interfaces/IDiscord.cs
Normal file
@@ -0,0 +1,9 @@
|
||||
using yawaflua.Discord.Net.Interfaces.Models;
|
||||
|
||||
namespace yawaflua.Discord.Net.Interfaces;
|
||||
|
||||
public interface IDiscord
|
||||
{
|
||||
Task<IToken?> GetTokenAsync(string code);
|
||||
ISession? CreateSession();
|
||||
}
|
||||
7
Interfaces/Models/IAvatarDecoration.cs
Normal file
7
Interfaces/Models/IAvatarDecoration.cs
Normal file
@@ -0,0 +1,7 @@
|
||||
namespace yawaflua.Discord.Net.Interfaces.Models;
|
||||
|
||||
public interface IAvatarDecoration
|
||||
{
|
||||
public string AssetHash { get; set; }
|
||||
public ulong AssetArticular { get; set; }
|
||||
}
|
||||
17
Interfaces/Models/IConnection.cs
Normal file
17
Interfaces/Models/IConnection.cs
Normal file
@@ -0,0 +1,17 @@
|
||||
using yawaflua.Discord.Net.Entities.Enums;
|
||||
|
||||
namespace yawaflua.Discord.Net.Interfaces.Models;
|
||||
|
||||
public interface IConnection
|
||||
{
|
||||
public string Id { get; set; }
|
||||
public string Name { get; set; }
|
||||
public ConnectionType Type { get; set; }
|
||||
public bool? Revoked { get; set; }
|
||||
public object[] Integrations { get; set; }
|
||||
public bool? Verified { get; set; }
|
||||
public bool? FriendSync { get; set; }
|
||||
public bool? ShowActivity { get; set; }
|
||||
public bool? TwoWayLink { get; set; }
|
||||
public ConnectionVisibility? Visibility { get; set; }
|
||||
}
|
||||
19
Interfaces/Models/IGuild.cs
Normal file
19
Interfaces/Models/IGuild.cs
Normal file
@@ -0,0 +1,19 @@
|
||||
using yawaflua.Discord.Net.Entities.Enums;
|
||||
|
||||
namespace yawaflua.Discord.Net.Interfaces.Models;
|
||||
|
||||
public interface IGuild
|
||||
{
|
||||
public ulong Id { get; set; }
|
||||
public string Name { get; set; }
|
||||
public string? IconHash { get; set; }
|
||||
public string? BannerHash { get; set; }
|
||||
public bool IsOwner { get; set; }
|
||||
public string Permissions { get; set; }
|
||||
public IEnumerable<GuildFeature> Features { get; set; }
|
||||
public int ApproximateMemberCount { get; set; }
|
||||
public int ApproximatePresenceCount { get; set; }
|
||||
|
||||
public string GetIconUrl(int size = 128);
|
||||
public string GetBannerUrl(int size = 128);
|
||||
}
|
||||
18
Interfaces/Models/IGuildMember.cs
Normal file
18
Interfaces/Models/IGuildMember.cs
Normal file
@@ -0,0 +1,18 @@
|
||||
namespace yawaflua.Discord.Net.Interfaces.Models;
|
||||
|
||||
public interface IGuildMember
|
||||
{
|
||||
public IUser User { get; set; }
|
||||
public string? Nick { get; set; }
|
||||
public string? AvatarHash { get; set; }
|
||||
public string? BannerHash { get; set; }
|
||||
public List<IRole> Roles { get; set; }
|
||||
public DateTime JoinedAt { get; set; }
|
||||
public DateTime? PremiumSince { get; set; }
|
||||
public bool IsDeaf { get; set; }
|
||||
public bool IsMute { get; set; }
|
||||
public int Flags { get; set; }
|
||||
public bool IsPending { get; set; }
|
||||
public DateTime? CommunicationDisabledUntil { get; set; }
|
||||
public IAvatarDecoration? AvatarDecoration { get; set; }
|
||||
}
|
||||
25
Interfaces/Models/IRole.cs
Normal file
25
Interfaces/Models/IRole.cs
Normal file
@@ -0,0 +1,25 @@
|
||||
using yawaflua.Discord.Net.Entities.Enums;
|
||||
|
||||
namespace yawaflua.Discord.Net.Interfaces.Models;
|
||||
|
||||
public interface IRole
|
||||
{
|
||||
public ulong Id { get; set; }
|
||||
public string Name { get; set; }
|
||||
[Obsolete("Deprecated integer representation of hexadecimal color code")]
|
||||
public int Color { get; set; }
|
||||
|
||||
public IRoleColor Colors { get; set; }
|
||||
|
||||
public bool IsHoisted { get; set; }
|
||||
public bool IsManaged { get; set; }
|
||||
public bool IsMentionable { get; set; }
|
||||
|
||||
public int Position { get; set; }
|
||||
public ulong? Permissions { get; set; }
|
||||
|
||||
public string? IconHash { get; set; }
|
||||
public string? UnicodeEmoji { get; set; }
|
||||
|
||||
public Dictionary<RoleTags, ulong?>? Tags { get; set; }
|
||||
}
|
||||
8
Interfaces/Models/IRoleColor.cs
Normal file
8
Interfaces/Models/IRoleColor.cs
Normal file
@@ -0,0 +1,8 @@
|
||||
namespace yawaflua.Discord.Net.Interfaces.Models;
|
||||
|
||||
public interface IRoleColor
|
||||
{
|
||||
public int Primary { get; set; }
|
||||
public int? Secondary { get; set; }
|
||||
public int? Tertiary { get; set; }
|
||||
}
|
||||
16
Interfaces/Models/ISession.cs
Normal file
16
Interfaces/Models/ISession.cs
Normal file
@@ -0,0 +1,16 @@
|
||||
namespace yawaflua.Discord.Net.Interfaces.Models;
|
||||
|
||||
public interface ISession
|
||||
{
|
||||
Task<IList<IGuild>?> GetGuildsAsync(CancellationToken cancellationToken = default);
|
||||
Task<IGuildMember?> GetGuildMemberAsync(ulong guildId, CancellationToken cancellationToken = default);
|
||||
Task<IGuildMember?> AddMemberToGuildAsync(ulong guildId, ulong userId, CancellationToken cancellationToken = default);
|
||||
Task<IUser?> GetCurrentUserAsync(CancellationToken cancellationToken = default);
|
||||
|
||||
Task<IConnection?> GetConnectionAsync(CancellationToken cancellationToken = default);
|
||||
|
||||
|
||||
string GetAuthorizationUrl(string state);
|
||||
IToken GetToken(CancellationToken cancellationToken = default);
|
||||
|
||||
}
|
||||
14
Interfaces/Models/IToken.cs
Normal file
14
Interfaces/Models/IToken.cs
Normal file
@@ -0,0 +1,14 @@
|
||||
namespace yawaflua.Discord.Net.Interfaces.Models;
|
||||
|
||||
public interface IToken
|
||||
{
|
||||
public string? AccessToken { get; set; }
|
||||
public int ExpiresIn { get; set; }
|
||||
public string? RefreshToken { get; set; }
|
||||
public string? Scope { get; set; }
|
||||
public string? TokenType { get; set; }
|
||||
|
||||
Task RevokeAsync(CancellationToken cancellationToken = default);
|
||||
Task RefreshAsync(CancellationToken cancellationToken = default);
|
||||
|
||||
}
|
||||
115
Interfaces/Models/IUser.cs
Normal file
115
Interfaces/Models/IUser.cs
Normal file
@@ -0,0 +1,115 @@
|
||||
using yawaflua.Discord.Net.Entities.Enums;
|
||||
|
||||
namespace yawaflua.Discord.Net.Interfaces.Models;
|
||||
|
||||
public interface IUser
|
||||
{
|
||||
/// <summary>
|
||||
/// the user's id
|
||||
/// </summary>
|
||||
/// <seealso href="https://discord.com/developers/docs/resources/user#user-object">User-object</seealso>
|
||||
public ulong Id { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// the user's username, not unique across the platform
|
||||
/// </summary>
|
||||
/// <seealso href="https://discord.com/developers/docs/resources/user#user-object">User-object</seealso>
|
||||
public string Username { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// the user's display name, if it is set. For bots, this is the application name
|
||||
/// </summary>
|
||||
public string GlobalName { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// the user's Discord-tag (Obsolete)
|
||||
/// </summary>
|
||||
/// <seealso href="https://discord.com/developers/docs/resources/user#user-object">User-object</seealso>
|
||||
public string Discriminator { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// the user's avatar hash
|
||||
/// </summary>
|
||||
/// <seealso href="https://discord.com/developers/docs/reference#image-formatting">Image formatting</seealso>
|
||||
/// <seealso href="https://discord.com/developers/docs/resources/user#user-object">User-object</seealso>
|
||||
public string? AvatarHash { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// the user's banner hash
|
||||
/// </summary>
|
||||
/// <seealso href="https://discord.com/developers/docs/reference#image-formatting">Image formatting</seealso>
|
||||
/// <seealso href="https://discord.com/developers/docs/resources/user#user-object">User-object</seealso>
|
||||
/// <remarks>Available in the User object only if the user has a banner set.</remarks>
|
||||
/// <example>https://cdn.discordapp.com/banners/{user.id}/{banner}.png?size=512</example>
|
||||
public string? Banner { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// whether the user belongs to an OAuth2 application
|
||||
/// </summary>
|
||||
/// <seealso href="https://discord.com/developers/docs/resources/user#user-object">User-object</seealso>
|
||||
public bool? Bot { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// whether the user is an Official Discord System user (part of the urgent message system)
|
||||
/// </summary>
|
||||
/// <seealso href="https://discord.com/developers/docs/resources/user#user-object">User-object</seealso>
|
||||
public bool? System { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// whether the user has two factor enabled on their account
|
||||
/// </summary>
|
||||
/// <seealso href="https://discord.com/developers/docs/resources/user#user-object">User-object</seealso>
|
||||
public bool? MfaEnabled { get; set; }
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// the user's banner color encoded as an integer representation of hexadecimal color code
|
||||
/// </summary>
|
||||
/// <seealso href="https://discord.com/developers/docs/resources/user#user-object">User-object</seealso>
|
||||
public int? AccentColor { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// the user's chosen language option
|
||||
/// </summary>
|
||||
/// <seealso href="https://discord.com/developers/docs/resources/user#user-object">User-object</seealso>
|
||||
public string? Locale { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// whether the email on this account has been verified
|
||||
/// </summary>
|
||||
/// <seealso href="https://discord.com/developers/docs/resources/user#user-object">User-object</seealso>
|
||||
public bool? Verified { get; set; }
|
||||
/// <summary>
|
||||
/// the user's email
|
||||
/// </summary>
|
||||
/// <seealso href="https://discord.com/developers/docs/resources/user#user-object">User-object</seealso>
|
||||
public string? Email { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// the flags on a user's account
|
||||
/// </summary>
|
||||
/// <seealso href="https://discord.com/developers/docs/resources/user#user-object">User-object</seealso>
|
||||
/// <seealso href="https://discord.com/developers/docs/resources/user#user-object-user-flags">User flags</seealso>
|
||||
public UserFlag? Flags { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// the type of Nitro subscription on a user's account
|
||||
/// </summary>
|
||||
/// <seealso href="https://discord.com/developers/docs/resources/user#user-object">User-object</seealso>
|
||||
public PremiumType? PremiumType { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// the public flags on a user's account
|
||||
/// </summary>
|
||||
/// <seealso href="https://discord.com/developers/docs/resources/user#user-object">User-object</seealso>
|
||||
public UserFlag? PublicFlags { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// data for the user's avatar decoration
|
||||
/// </summary>
|
||||
/// <seealso href="https://discord.com/developers/docs/resources/user#user-object">User-object</seealso>
|
||||
public IAvatarDecoration? AvatarDecoration { get; set; }
|
||||
|
||||
public string GetAvatarUrl(int size = 128);
|
||||
public string GetBannerUrl(int size = 128);
|
||||
}
|
||||
Reference in New Issue
Block a user