Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add support for channel categories (as its own channel type)
- Loading branch information
Showing
18 changed files
with
243 additions
and
33 deletions.
There are no files selected for viewing
12 changes: 12 additions & 0 deletions
12
src/Discord.Net.Core/Entities/Channels/GuildChannelCategoryProperties.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
using System.Text; | ||
using System.Threading.Tasks; | ||
|
||
namespace Discord | ||
{ | ||
//public class GuildChannelCategoryProperties : GuildChannelProperties | ||
//{ | ||
//} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
14 changes: 14 additions & 0 deletions
14
src/Discord.Net.Core/Entities/Channels/IGuildChannelCategory.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
using System.Text; | ||
using System.Threading.Tasks; | ||
|
||
namespace Discord | ||
{ | ||
public interface IGuildChannelCategory : IGuildChannel | ||
{ | ||
///// <summary> Modifies this text channel. </summary> | ||
//Task ModifyAsync(Action<GuildChannelCategoryProperties> func, RequestOptions options = null); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
14 changes: 14 additions & 0 deletions
14
src/Discord.Net.Rest/API/Rest/ModifyGuildChannelCategoryParams.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
#pragma warning disable CS1591 | ||
using Newtonsoft.Json; | ||
|
||
namespace Discord.API.Rest | ||
{ | ||
[JsonObject(MemberSerialization = MemberSerialization.OptIn)] | ||
internal class ModifyGuildChannelCategoryParams | ||
{ | ||
[JsonProperty("name")] | ||
public Optional<string> Name { get; set; } | ||
[JsonProperty("position")] | ||
public Optional<int> Position { get; set; } | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -5,6 +5,7 @@ public enum ChannelType | |
Text = 0, | ||
DM = 1, | ||
Voice = 2, | ||
Group = 3 | ||
Group = 3, | ||
Category = 4 | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
38 changes: 38 additions & 0 deletions
38
src/Discord.Net.Rest/Entities/Channels/RestGuildChannelCategory.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Diagnostics; | ||
using System.IO; | ||
using System.Linq; | ||
using System.Threading.Tasks; | ||
using Model = Discord.API.Channel; | ||
|
||
namespace Discord.Rest | ||
{ | ||
[DebuggerDisplay(@"{DebuggerDisplay,nq}")] | ||
public class RestGuildChannelCategory : RestGuildChannel, IGuildChannelCategory | ||
{ | ||
public string Mention => MentionUtils.MentionChannel(Id); | ||
|
||
internal RestGuildChannelCategory(BaseDiscordClient discord, IGuild guild, ulong id) | ||
: base(discord, guild, id) | ||
{ | ||
} | ||
internal new static RestGuildChannelCategory Create(BaseDiscordClient discord, IGuild guild, Model model) | ||
{ | ||
var entity = new RestGuildChannelCategory(discord, guild, model.Id); | ||
entity.Update(model); | ||
return entity; | ||
} | ||
internal override void Update(Model model) | ||
{ | ||
base.Update(model); | ||
} | ||
|
||
public Task<RestGuildUser> GetUserAsync(ulong id, RequestOptions options = null) | ||
=> ChannelHelper.GetUserAsync(this, Guild, Discord, id, options); | ||
public IAsyncEnumerable<IReadOnlyCollection<RestGuildUser>> GetUsersAsync(RequestOptions options = null) | ||
=> ChannelHelper.GetUsersAsync(this, Guild, Discord, null, null, options); | ||
|
||
private string DebuggerDisplay => $"{Name} ({Id}, Text)"; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.