Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix ChannelPermissions Modify parameter to be correct default value #1003

Merged
merged 11 commits into from
May 26, 2018
Merged
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 @@ -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 @@ private ChannelPermissions(ulong initialValue, bool? createInstantInvite = null,
}

/// <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
Original file line number Diff line number Diff line change
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 @@ private GuildPermissions(ulong initialValue, bool? createInstantInvite = null, b
}

/// <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
Loading