Skip to content

Commit

Permalink
Merge branch 'dev' into docs/faq-n-patches-offline
Browse files Browse the repository at this point in the history
  • Loading branch information
Still Hsu committed May 27, 2018
2 parents cb57ada + a06e212 commit 1a146af
Show file tree
Hide file tree
Showing 28 changed files with 540 additions and 151 deletions.
11 changes: 0 additions & 11 deletions src/Discord.Net.Core/Entities/Channels/IGuildChannel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -20,17 +20,6 @@ public interface IGuildChannel : IChannel, IDeletable
/// </returns>
int Position { get; }

/// <summary>
/// Gets the parent ID (category) of this channel in the guild's channel list.
/// </summary>
/// <returns>
/// The parent category ID associated with this channel, or <c>null</c> if none is set.
/// </returns>
ulong? CategoryId { get; }
/// <summary>
/// Gets the parent channel (category) of this channel.
/// </summary>
Task<ICategoryChannel> GetCategoryAsync();
/// <summary>
/// Gets the guild associated with this channel.
/// </summary>
Expand Down
16 changes: 16 additions & 0 deletions src/Discord.Net.Core/Entities/Channels/INestedChannel.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
using System.Threading.Tasks;

namespace Discord
{
/// <summary>
/// A type of guild channel that can be nested within a category.
/// Contains a CategoryId that is set to the parent category, if it is set.
/// </summary>
public interface INestedChannel : IGuildChannel
{
/// <summary> Gets the parentid (category) of this channel in the guild's channel list. </summary>
ulong? CategoryId { get; }
/// <summary> Gets the parent channel (category) of this channel, if it is set. If unset, returns null.</summary>
Task<ICategoryChannel> GetCategoryAsync(CacheMode mode = CacheMode.AllowDownload, RequestOptions options = null);
}
}
2 changes: 1 addition & 1 deletion src/Discord.Net.Core/Entities/Channels/ITextChannel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ namespace Discord
/// <summary>
/// Represents a generic channel in a guild that can send and receive messages.
/// </summary>
public interface ITextChannel : IMessageChannel, IMentionable, IGuildChannel
public interface ITextChannel : IMessageChannel, IMentionable, INestedChannel
{
/// <summary>
/// Determines whether the channel is NSFW.
Expand Down
2 changes: 1 addition & 1 deletion src/Discord.Net.Core/Entities/Channels/IVoiceChannel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ namespace Discord
/// <summary>
/// Represents a generic voice channel in a guild.
/// </summary>
public interface IVoiceChannel : IGuildChannel, IAudioChannel
public interface IVoiceChannel : INestedChannel, IAudioChannel
{
/// <summary>
/// Gets the bitrate, in bits per second, clients in this voice channel are requested to use.
Expand Down
99 changes: 81 additions & 18 deletions src/Discord.Net.Core/Entities/Permissions/ChannelPermissions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -88,12 +88,27 @@ public static ChannelPermissions All(IChannel channel)
/// <summary> Creates a new <see cref="ChannelPermissions"/> with the provided packed value. </summary>
public ChannelPermissions(ulong rawValue) { RawValue = rawValue; }

private ChannelPermissions(ulong initialValue, bool? createInstantInvite = null, bool? manageChannel = null,
private ChannelPermissions(ulong initialValue,
bool? createInstantInvite = null,
bool? manageChannel = null,
bool? addReactions = null,
bool? viewChannel = null, bool? sendMessages = null, bool? sendTTSMessages = null, bool? manageMessages = null,
bool? embedLinks = null, bool? attachFiles = null, bool? readMessageHistory = null, bool? mentionEveryone = null,
bool? useExternalEmojis = null, bool? connect = null, bool? speak = null, bool? muteMembers = null, bool? deafenMembers = null,
bool? moveMembers = null, bool? useVoiceActivation = null, bool? manageRoles = null, bool? manageWebhooks = null)
bool? viewChannel = null,
bool? sendMessages = null,
bool? sendTTSMessages = null,
bool? manageMessages = null,
bool? embedLinks = null,
bool? attachFiles = null,
bool? readMessageHistory = null,
bool? mentionEveryone = null,
bool? useExternalEmojis = null,
bool? connect = null,
bool? speak = null,
bool? muteMembers = null,
bool? deafenMembers = null,
bool? moveMembers = null,
bool? useVoiceActivation = null,
bool? manageRoles = null,
bool? manageWebhooks = null)
{
ulong value = initialValue;

Expand Down Expand Up @@ -122,27 +137,75 @@ private ChannelPermissions(ulong initialValue, bool? createInstantInvite = null,
}

/// <summary> Creates a new <see cref="ChannelPermissions"/> with the provided permissions. </summary>
public ChannelPermissions(bool createInstantInvite = false, bool manageChannel = false,
public ChannelPermissions(
bool createInstantInvite = false,
bool manageChannel = false,
bool addReactions = false,
bool viewChannel = false, bool sendMessages = false, bool sendTTSMessages = false, bool manageMessages = false,
bool embedLinks = false, bool attachFiles = false, bool readMessageHistory = false, bool mentionEveryone = false,
bool useExternalEmojis = false, bool connect = false, bool speak = false, bool muteMembers = false, bool deafenMembers = false,
bool moveMembers = false, bool useVoiceActivation = false, bool manageRoles = false, bool manageWebhooks = false)
bool viewChannel = false,
bool sendMessages = false,
bool sendTTSMessages = false,
bool manageMessages = false,
bool embedLinks = false,
bool attachFiles = false,
bool readMessageHistory = false,
bool mentionEveryone = false,
bool useExternalEmojis = false,
bool connect = false,
bool speak = false,
bool muteMembers = false,
bool deafenMembers = false,
bool moveMembers = false,
bool useVoiceActivation = false,
bool manageRoles = false,
bool manageWebhooks = false)
: this(0, createInstantInvite, manageChannel, addReactions, viewChannel, sendMessages, sendTTSMessages, manageMessages,
embedLinks, attachFiles, readMessageHistory, mentionEveryone, useExternalEmojis, connect,
speak, muteMembers, deafenMembers, moveMembers, useVoiceActivation, manageRoles, manageWebhooks)
{ }

/// <summary> Creates a new <see cref="ChannelPermissions"/> from this one, changing the provided non-null permissions. </summary>
public ChannelPermissions Modify(bool? createInstantInvite = null, bool? manageChannel = null,
public ChannelPermissions Modify(
bool? createInstantInvite = null,
bool? manageChannel = null,
bool? addReactions = null,
bool? viewChannel = null, bool? sendMessages = null, bool? sendTTSMessages = null, bool? manageMessages = null,
bool? embedLinks = null, bool? attachFiles = null, bool? readMessageHistory = null, bool? mentionEveryone = null,
bool useExternalEmojis = false, bool? connect = null, bool? speak = null, bool? muteMembers = null, bool? deafenMembers = null,
bool? moveMembers = null, bool? useVoiceActivation = null, bool? manageRoles = null, bool? manageWebhooks = null)
=> new ChannelPermissions(RawValue, createInstantInvite, manageChannel, addReactions, viewChannel, sendMessages, sendTTSMessages, manageMessages,
embedLinks, attachFiles, readMessageHistory, mentionEveryone, useExternalEmojis, connect,
speak, muteMembers, deafenMembers, moveMembers, useVoiceActivation, manageRoles, manageWebhooks);
bool? viewChannel = null,
bool? sendMessages = null,
bool? sendTTSMessages = null,
bool? manageMessages = null,
bool? embedLinks = null,
bool? attachFiles = null,
bool? readMessageHistory = null,
bool? mentionEveryone = null,
bool? useExternalEmojis = null,
bool? connect = null,
bool? speak = null,
bool? muteMembers = null,
bool? deafenMembers = null,
bool? moveMembers = null,
bool? useVoiceActivation = null,
bool? manageRoles = null,
bool? manageWebhooks = null)
=> new ChannelPermissions(RawValue,
createInstantInvite,
manageChannel,
addReactions,
viewChannel,
sendMessages,
sendTTSMessages,
manageMessages,
embedLinks,
attachFiles,
readMessageHistory,
mentionEveryone,
useExternalEmojis,
connect,
speak,
muteMembers,
deafenMembers,
moveMembers,
useVoiceActivation,
manageRoles,
manageWebhooks);

public bool Has(ChannelPermission permission) => Permissions.GetValue(RawValue, permission);

Expand Down
147 changes: 116 additions & 31 deletions src/Discord.Net.Core/Entities/Permissions/GuildPermissions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -84,14 +84,35 @@ public struct GuildPermissions
/// <summary> Creates a new <see cref="GuildPermissions"/> with the provided packed value. </summary>
public GuildPermissions(ulong rawValue) { RawValue = rawValue; }

private GuildPermissions(ulong initialValue, bool? createInstantInvite = null, bool? kickMembers = null,
bool? banMembers = null, bool? administrator = null, bool? manageChannels = null, bool? manageGuild = null,
bool? addReactions = null, bool? viewAuditLog = null,
bool? viewChannel = null, bool? sendMessages = null, bool? sendTTSMessages = null, bool? manageMessages = null,
bool? embedLinks = null, bool? attachFiles = null, bool? readMessageHistory = null, bool? mentionEveryone = null,
bool? useExternalEmojis = null, bool? connect = null, bool? speak = null, bool? muteMembers = null, bool? deafenMembers = null,
bool? moveMembers = null, bool? useVoiceActivation = null, bool? changeNickname = null, bool? manageNicknames = null,
bool? manageRoles = null, bool? manageWebhooks = null, bool? manageEmojis = null)
private GuildPermissions(ulong initialValue,
bool? createInstantInvite = null,
bool? kickMembers = null,
bool? banMembers = null,
bool? administrator = null,
bool? manageChannels = null,
bool? manageGuild = null,
bool? addReactions = null,
bool? viewAuditLog = null,
bool? viewChannel = null,
bool? sendMessages = null,
bool? sendTTSMessages = null,
bool? manageMessages = null,
bool? embedLinks = null,
bool? attachFiles = null,
bool? readMessageHistory = null,
bool? mentionEveryone = null,
bool? useExternalEmojis = null,
bool? connect = null,
bool? speak = null,
bool? muteMembers = null,
bool? deafenMembers = null,
bool? moveMembers = null,
bool? useVoiceActivation = null,
bool? changeNickname = null,
bool? manageNicknames = null,
bool? manageRoles = null,
bool? manageWebhooks = null,
bool? manageEmojis = null)
{
ulong value = initialValue;

Expand Down Expand Up @@ -128,32 +149,96 @@ private GuildPermissions(ulong initialValue, bool? createInstantInvite = null, b
}

/// <summary> Creates a new <see cref="GuildPermissions"/> with the provided permissions. </summary>
public GuildPermissions(bool createInstantInvite = false, bool kickMembers = false,
bool banMembers = false, bool administrator = false, bool manageChannels = false, bool manageGuild = false,
bool addReactions = false, bool viewAuditLog = false,
bool viewChannel = false, bool sendMessages = false, bool sendTTSMessages = false, bool manageMessages = false,
bool embedLinks = false, bool attachFiles = false, bool readMessageHistory = false, bool mentionEveryone = false,
bool useExternalEmojis = false, bool connect = false, bool speak = false, bool muteMembers = false, bool deafenMembers = false,
bool moveMembers = false, bool useVoiceActivation = false, bool? changeNickname = false, bool? manageNicknames = false,
bool manageRoles = false, bool manageWebhooks = false, bool manageEmojis = false)
: this(0, createInstantInvite: createInstantInvite, manageRoles: manageRoles, kickMembers: kickMembers, banMembers: banMembers,
administrator: administrator, manageChannels: manageChannels, manageGuild: manageGuild, addReactions: addReactions,
viewAuditLog: viewAuditLog, viewChannel: viewChannel, sendMessages: sendMessages, sendTTSMessages: sendTTSMessages,
manageMessages: manageMessages, embedLinks: embedLinks, attachFiles: attachFiles, readMessageHistory: readMessageHistory,
mentionEveryone: mentionEveryone, useExternalEmojis: useExternalEmojis, connect: connect, speak: speak, muteMembers: muteMembers,
deafenMembers: deafenMembers, moveMembers: moveMembers, useVoiceActivation: useVoiceActivation, changeNickname: changeNickname,
manageNicknames: manageNicknames, manageWebhooks: manageWebhooks, manageEmojis: manageEmojis)
public GuildPermissions(
bool createInstantInvite = false,
bool kickMembers = false,
bool banMembers = false,
bool administrator = false,
bool manageChannels = false,
bool manageGuild = false,
bool addReactions = false,
bool viewAuditLog = false,
bool viewChannel = false,
bool sendMessages = false,
bool sendTTSMessages = false,
bool manageMessages = false,
bool embedLinks = false,
bool attachFiles = false,
bool readMessageHistory = false,
bool mentionEveryone = false,
bool useExternalEmojis = false,
bool connect = false,
bool speak = false,
bool muteMembers = false,
bool deafenMembers = false,
bool moveMembers = false,
bool useVoiceActivation = false,
bool changeNickname = false,
bool manageNicknames = false,
bool manageRoles = false,
bool manageWebhooks = false,
bool manageEmojis = false)
: this(0,
createInstantInvite: createInstantInvite,
manageRoles: manageRoles,
kickMembers: kickMembers,
banMembers: banMembers,
administrator: administrator,
manageChannels: manageChannels,
manageGuild: manageGuild,
addReactions: addReactions,
viewAuditLog: viewAuditLog,
viewChannel: viewChannel,
sendMessages: sendMessages,
sendTTSMessages: sendTTSMessages,
manageMessages: manageMessages,
embedLinks: embedLinks,
attachFiles: attachFiles,
readMessageHistory: readMessageHistory,
mentionEveryone: mentionEveryone,
useExternalEmojis: useExternalEmojis,
connect: connect,
speak: speak,
muteMembers: muteMembers,
deafenMembers: deafenMembers,
moveMembers: moveMembers,
useVoiceActivation: useVoiceActivation,
changeNickname: changeNickname,
manageNicknames: manageNicknames,
manageWebhooks: manageWebhooks,
manageEmojis: manageEmojis)
{ }

/// <summary> Creates a new <see cref="GuildPermissions"/> from this one, changing the provided non-null permissions. </summary>
public GuildPermissions Modify(bool? createInstantInvite = null, bool? kickMembers = null,
bool? banMembers = null, bool? administrator = null, bool? manageChannels = null, bool? manageGuild = null,
bool? addReactions = null, bool? viewAuditLog = null,
bool? viewChannel = null, bool? sendMessages = null, bool? sendTTSMessages = null, bool? manageMessages = null,
bool? embedLinks = null, bool? attachFiles = null, bool? readMessageHistory = null, bool? mentionEveryone = null,
bool? useExternalEmojis = null, bool? connect = null, bool? speak = null, bool? muteMembers = null, bool? deafenMembers = null,
bool? moveMembers = null, bool? useVoiceActivation = null, bool? changeNickname = null, bool? manageNicknames = null,
bool? manageRoles = null, bool? manageWebhooks = null, bool? manageEmojis = null)
public GuildPermissions Modify(
bool? createInstantInvite = null,
bool? kickMembers = null,
bool? banMembers = null,
bool? administrator = null,
bool? manageChannels = null,
bool? manageGuild = null,
bool? addReactions = null,
bool? viewAuditLog = null,
bool? viewChannel = null,
bool? sendMessages = null,
bool? sendTTSMessages = null,
bool? manageMessages = null,
bool? embedLinks = null,
bool? attachFiles = null,
bool? readMessageHistory = null,
bool? mentionEveryone = null,
bool? useExternalEmojis = null,
bool? connect = null,
bool? speak = null,
bool? muteMembers = null,
bool? deafenMembers = null,
bool? moveMembers = null,
bool? useVoiceActivation = null,
bool? changeNickname = null,
bool? manageNicknames = null,
bool? manageRoles = null,
bool? manageWebhooks = null,
bool? manageEmojis = null)
=> new GuildPermissions(RawValue, createInstantInvite, kickMembers, banMembers, administrator, manageChannels, manageGuild, addReactions,
viewAuditLog, viewChannel, sendMessages, sendTTSMessages, manageMessages, embedLinks, attachFiles,
readMessageHistory, mentionEveryone, useExternalEmojis, connect, speak, muteMembers, deafenMembers, moveMembers,
Expand Down
Loading

0 comments on commit 1a146af

Please sign in to comment.