@@ -2,6 +2,7 @@ | |||
<PropertyGroup> | |||
<TargetFramework>netstandard2.0</TargetFramework> | |||
<LangVersion>7.1</LangVersion> | |||
</PropertyGroup> | |||
<ItemGroup> | |||
@@ -9,8 +10,4 @@ | |||
<PackageReference Include="Wumpus.Net.Rest" Version="0.2.2-build-00031" /> | |||
</ItemGroup> | |||
<ItemGroup> | |||
<Folder Include="Models\Guilds\" /> | |||
</ItemGroup> | |||
</Project> |
@@ -0,0 +1,11 @@ | |||
using System; | |||
using System.Collections.Generic; | |||
using System.Text; | |||
namespace Discord | |||
{ | |||
public interface IEmote | |||
{ | |||
string Name { get; } | |||
} | |||
} |
@@ -0,0 +1,7 @@ | |||
namespace Discord | |||
{ | |||
public interface IGuildEmote : IEmote | |||
{ | |||
// TODO | |||
} | |||
} |
@@ -142,5 +142,40 @@ namespace Discord | |||
/// A string containing the identifier for the voice region that this guild uses (e.g. <c>eu-central</c>). | |||
/// </returns> | |||
string VoiceRegionId { get; } | |||
/// <summary> | |||
/// Gets the <see cref="IAudioClient"/> currently associated with this guild. | |||
/// </summary> | |||
/// <returns> | |||
/// An <see cref="IAudioClient"/> currently associated with this guild. | |||
/// </returns> | |||
//IAudioClient AudioClient { get; } // TODO: how do we want to handle audio? | |||
/// <summary> | |||
/// Gets the built-in role containing all users in this guild. | |||
/// </summary> | |||
/// <returns> | |||
/// A role object that represents an <c>@everyone</c> role in this guild. | |||
/// </returns> | |||
IRole EveryoneRole { get; } | |||
/// <summary> | |||
/// Gets a collection of all custom emotes for this guild. | |||
/// </summary> | |||
/// <returns> | |||
/// A read-only collection of all custom emotes for this guild. | |||
/// </returns> | |||
IReadOnlyCollection<IGuildEmote> Emotes { get; } | |||
/// <summary> | |||
/// Gets a collection of all extra features added to this guild. | |||
/// </summary> | |||
/// <returns> | |||
/// A read-only collection of enabled features in this guild. | |||
/// </returns> | |||
IReadOnlyCollection<string> Features { get; } | |||
/// <summary> | |||
/// Gets a collection of all roles in this guild. | |||
/// </summary> | |||
/// <returns> | |||
/// A read-only collection of roles found within this guild. | |||
/// </returns> | |||
IReadOnlyCollection<IRole> Roles { get; } | |||
} | |||
} |
@@ -0,0 +1,7 @@ | |||
namespace Discord | |||
{ | |||
public interface IMentionable | |||
{ | |||
string Mention { get; } | |||
} | |||
} |
@@ -0,0 +1,85 @@ | |||
using System; | |||
using System.Threading.Tasks; | |||
using Color = Wumpus.Entities.Color; // TODO: do we need to impl our own color struct? | |||
using GuildPermissions = Wumpus.Entities.GuildPermissions; // TODO: permissions | |||
namespace Discord | |||
{ | |||
/// <summary> | |||
/// Represents a generic role object to be given to a guild user. | |||
/// </summary> | |||
public interface IRole : ISnowflakeEntity, IDeletable, IMentionable, IComparable<IRole> | |||
{ | |||
/// <summary> | |||
/// Gets the guild that owns this role. | |||
/// </summary> | |||
/// <returns> | |||
/// A guild representing the parent guild of this role. | |||
/// </returns> | |||
IGuild Guild { get; } | |||
/// <summary> | |||
/// Gets the color given to users of this role. | |||
/// </summary> | |||
/// <returns> | |||
/// A <see cref="Color"/> struct representing the color of this role. | |||
/// </returns> | |||
Color Color { get; } | |||
/// <summary> | |||
/// Gets a value that indicates whether the role can be separated in the user list. | |||
/// </summary> | |||
/// <returns> | |||
/// <c>true</c> if users of this role are separated in the user list; otherwise <c>false</c>. | |||
/// </returns> | |||
bool IsHoisted { get; } | |||
/// <summary> | |||
/// Gets a value that indicates whether the role is managed by Discord. | |||
/// </summary> | |||
/// <returns> | |||
/// <c>true</c> if this role is automatically managed by Discord; otherwise <c>false</c>. | |||
/// </returns> | |||
bool IsManaged { get; } | |||
/// <summary> | |||
/// Gets a value that indicates whether the role is mentionable. | |||
/// </summary> | |||
/// <returns> | |||
/// <c>true</c> if this role may be mentioned in messages; otherwise <c>false</c>. | |||
/// </returns> | |||
bool IsMentionable { get; } | |||
/// <summary> | |||
/// Gets the name of this role. | |||
/// </summary> | |||
/// <returns> | |||
/// A string containing the name of this role. | |||
/// </returns> | |||
string Name { get; } | |||
/// <summary> | |||
/// Gets the permissions granted to members of this role. | |||
/// </summary> | |||
/// <returns> | |||
/// A <see cref="GuildPermissions"/> struct that this role possesses. | |||
/// </returns> | |||
GuildPermissions Permissions { get; } | |||
/// <summary> | |||
/// Gets this role's position relative to other roles in the same guild. | |||
/// </summary> | |||
/// <returns> | |||
/// An <see cref="int"/> representing the position of the role in the role list of the guild. | |||
/// </returns> | |||
int Position { get; } | |||
/// <summary> | |||
/// Modifies this role. | |||
/// </summary> | |||
/// <remarks> | |||
/// This method modifies this role with the specified properties. To see an example of this | |||
/// method and what properties are available, please refer to <see cref="RoleProperties"/>. | |||
/// </remarks> | |||
/// <param name="func">A delegate containing the properties to modify the role with.</param> | |||
/// <param name="options">The options to be used when sending the request.</param> | |||
/// <returns> | |||
/// A task that represents the asynchronous modification operation. | |||
/// </returns> | |||
Task ModifyAsync(); // TODO: stub out request properties | |||
} | |||
} |
@@ -6,12 +6,12 @@ namespace Discord | |||
{ | |||
public interface IDiscordClient | |||
{ | |||
event Action Ready; | |||
WumpusGatewayClient Gateway { get; } | |||
WumpusRestClient Rest { get; } | |||
Task StartAsync(); | |||
Task StopAsync(); | |||
event Action Ready; | |||
} | |||
} |
@@ -9,7 +9,7 @@ namespace Discord | |||
{ | |||
internal class Guild : SnowflakeEntity, IGuild | |||
{ | |||
public Guild(Model model, IDiscordClient client) : base(client) | |||
public Guild(Model model, IDiscordClient discord) : base(discord) | |||
{ | |||
Name = model.Name.ToString(); | |||
AFKTimeout = model.AfkTimeout; | |||
@@ -35,6 +35,23 @@ namespace Discord | |||
OwnerId = model.OwnerId; | |||
ApplicationId = model.ApplicationId; | |||
VoiceRegionId = null; // TODO? | |||
Role[] roles = new Role[model.Roles.Length]; | |||
Role role; | |||
for (int i = 0; i < model.Roles.Length; i++) | |||
{ | |||
role = new Role(model.Roles[i], this, Discord); | |||
if (role.Id == Id) // EveryoneRole has the same ID as the guild | |||
EveryoneRole = role; | |||
roles[i] = role; | |||
} | |||
Roles = roles; | |||
// TODO: emotes | |||
string[] features = new string[model.Features.Length]; | |||
for (int i = 0; i < model.Features.Length; i++) | |||
features[i] = model.Features[i].ToString(); | |||
Features = features; | |||
} | |||
public string Name { get; set; } | |||
@@ -61,6 +78,12 @@ namespace Discord | |||
public ulong? ApplicationId { get; set; } | |||
public string VoiceRegionId { get; set; } | |||
public Task DeleteAsync() => throw new NotImplementedException(); | |||
public IRole EveryoneRole { get; set; } | |||
public IReadOnlyCollection<IGuildEmote> Emotes { get; set; } | |||
public IReadOnlyCollection<string> Features { get; set; } | |||
public IReadOnlyCollection<IRole> Roles { get; set; } | |||
public Task DeleteAsync() | |||
=> Discord.Rest.DeleteGuildAsync(Id); | |||
} | |||
} |
@@ -0,0 +1,50 @@ | |||
using System; | |||
using System.Collections.Generic; | |||
using System.Text; | |||
using System.Threading.Tasks; | |||
using Wumpus.Entities; | |||
using Model = Wumpus.Entities.Role; | |||
namespace Discord | |||
{ | |||
internal class Role : SnowflakeEntity, IRole | |||
{ | |||
public Role(Model model, IGuild guild, IDiscordClient discord) : base(discord) | |||
{ | |||
Guild = guild; | |||
Color = model.Color; | |||
IsHoisted = model.IsHoisted; | |||
IsManaged = model.Managed; | |||
IsMentionable = model.IsMentionable; | |||
Name = model.Name.ToString(); | |||
Permissions = model.Permissions; | |||
Position = model.Position; | |||
} | |||
public IGuild Guild { get; set; } | |||
public Color Color { get; set; } | |||
public bool IsHoisted { get; set; } | |||
public bool IsManaged { get; set; } | |||
public bool IsMentionable { get; set; } | |||
public string Name { get; set; } | |||
public GuildPermissions Permissions { get; set; } | |||
public int Position { get; set; } | |||
public string Mention => throw new NotImplementedException(); // TODO: MentionUtils | |||
public Task DeleteAsync() | |||
=> Discord.Rest.DeleteGuildRoleAsync(Guild.Id, Id); | |||
public Task ModifyAsync() | |||
{ | |||
throw new NotImplementedException(); | |||
} | |||
// IComparable | |||
public int CompareTo(IRole other) | |||
{ | |||
return Id.CompareTo(other.Id); | |||
} | |||
} | |||
} |
@@ -4,6 +4,8 @@ | |||
<TargetFramework>netcoreapp2.1</TargetFramework> | |||
<IsPackable>false</IsPackable> | |||
<LangVersion>7.1</LangVersion> | |||
</PropertyGroup> | |||
<ItemGroup> | |||
@@ -4,6 +4,8 @@ | |||
<TargetFramework>netcoreapp2.1</TargetFramework> | |||
<IsPackable>false</IsPackable> | |||
<LangVersion>7.1</LangVersion> | |||
</PropertyGroup> | |||
<ItemGroup> | |||