Skip to content

Commit

Permalink
Fix ChannelPermissions Modify parameter to be correct default value (#…
Browse files Browse the repository at this point in the history
…1003)

* fix channel permissions modify parameter to use nullable boolean, correct default value

* Add general tests for the ChannelPermissions.Modify method to test default values

* remove unused cast in tests

* add guildpermission modify no param tests

* Add no-param modify tests for OverwritePermissions

* fix inconsistent parameters in GuildPermissions cstr

* Adjust formatting of methods and cstrs with many parameters

* remove temp file that was included. no idea what that is

* Fix System dependency

I should really stop fixing merge conflicts in the github website.
  • Loading branch information
Chris-Johnston authored and foxbot committed May 26, 2018
1 parent f9cbff5 commit a06e212
Show file tree
Hide file tree
Showing 6 changed files with 356 additions and 65 deletions.
99 changes: 81 additions & 18 deletions src/Discord.Net.Core/Entities/Permissions/ChannelPermissions.cs
Expand Up @@ -87,12 +87,27 @@ public static ChannelPermissions All(IChannel channel)
/// <summary> Creates a new 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 @@ -121,27 +136,75 @@ public static ChannelPermissions All(IChannel channel)
}

/// <summary> Creates a new 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 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
Expand Up @@ -84,14 +84,35 @@ public struct GuildPermissions
/// <summary> Creates a new 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 @@ public struct GuildPermissions
}

/// <summary> Creates a new 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 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

0 comments on commit a06e212

Please sign in to comment.