Browse Source

Merge 0fb4e1c71e into 5f084adf94

pull/1016/merge
Still Hsu GitHub 7 years ago
parent
commit
0ccb62bbd5
No known key found for this signature in database GPG Key ID: 4AEE18F83AFDEB23
6 changed files with 29 additions and 4 deletions
  1. +5
    -1
      src/Discord.Net.Core/Entities/Channels/GuildChannelProperties.cs
  2. +9
    -1
      src/Discord.Net.Rest/API/Common/Overwrite.cs
  3. +2
    -0
      src/Discord.Net.Rest/API/Rest/ModifyGuildChannelParams.cs
  4. +11
    -0
      src/Discord.Net.Rest/Entities/Channels/ChannelHelper.cs
  5. +1
    -1
      src/Discord.Net.Rest/Entities/Channels/RestGuildChannel.cs
  6. +1
    -1
      src/Discord.Net.WebSocket/Entities/Channels/SocketGuildChannel.cs

+ 5
- 1
src/Discord.Net.Core/Entities/Channels/GuildChannelProperties.cs View File

@@ -1,4 +1,4 @@
namespace Discord
namespace Discord
{ {
/// <summary> /// <summary>
/// Modify an IGuildChannel with the specified changes. /// Modify an IGuildChannel with the specified changes.
@@ -30,5 +30,9 @@
/// Sets the category for this channel /// Sets the category for this channel
/// </summary> /// </summary>
public Optional<ulong?> CategoryId { get; set; } public Optional<ulong?> CategoryId { get; set; }
/// <summary>
/// Syncs the permission with the channel's parent (category).
/// </summary>
public Optional<bool> SyncWithCategory { get; set; }
} }
} }

+ 9
- 1
src/Discord.Net.Rest/API/Common/Overwrite.cs View File

@@ -1,4 +1,4 @@
#pragma warning disable CS1591
#pragma warning disable CS1591
using Newtonsoft.Json; using Newtonsoft.Json;


namespace Discord.API namespace Discord.API
@@ -13,5 +13,13 @@ namespace Discord.API
public ulong Deny { get; set; } public ulong Deny { get; set; }
[JsonProperty("allow"), Int53] [JsonProperty("allow"), Int53]
public ulong Allow { get; set; } public ulong Allow { get; set; }

public Overwrite(ulong targetId, PermissionTarget targetType, ulong allowValue, ulong denyValue)
{
TargetId = targetId;
TargetType = targetType;
Allow = allowValue;
Deny = denyValue;
}
} }
} }

+ 2
- 0
src/Discord.Net.Rest/API/Rest/ModifyGuildChannelParams.cs View File

@@ -12,5 +12,7 @@ namespace Discord.API.Rest
public Optional<int> Position { get; set; } public Optional<int> Position { get; set; }
[JsonProperty("parent_id")] [JsonProperty("parent_id")]
public Optional<ulong?> CategoryId { get; set; } public Optional<ulong?> CategoryId { get; set; }
[JsonProperty("permission_overwrites")]
public Optional<Overwrite[]> Overwrites { get; set; }
} }
} }

+ 11
- 0
src/Discord.Net.Rest/Entities/Channels/ChannelHelper.cs View File

@@ -19,6 +19,7 @@ namespace Discord.Rest
{ {
await client.ApiClient.DeleteChannelAsync(channel.Id, options).ConfigureAwait(false); await client.ApiClient.DeleteChannelAsync(channel.Id, options).ConfigureAwait(false);
} }

public static async Task<Model> ModifyAsync(IGuildChannel channel, BaseDiscordClient client, public static async Task<Model> ModifyAsync(IGuildChannel channel, BaseDiscordClient client,
Action<GuildChannelProperties> func, Action<GuildChannelProperties> func,
RequestOptions options) RequestOptions options)
@@ -31,6 +32,16 @@ namespace Discord.Rest
Position = args.Position, Position = args.Position,
CategoryId = args.CategoryId CategoryId = args.CategoryId
}; };
if (args.SyncWithCategory.IsSpecified && args.SyncWithCategory.Value)
{
var categoryChannel = await channel.GetCategoryAsync().ConfigureAwait(false);
if (categoryChannel != null)
apiArgs.Overwrites = categoryChannel.PermissionOverwrites
.Select(overwrite => new API.Overwrite(overwrite.TargetId, overwrite.TargetType,
overwrite.Permissions.AllowValue, overwrite.Permissions.DenyValue))
.ToArray();
}

return await client.ApiClient.ModifyGuildChannelAsync(channel.Id, apiArgs, options).ConfigureAwait(false); return await client.ApiClient.ModifyGuildChannelAsync(channel.Id, apiArgs, options).ConfigureAwait(false);
} }
public static async Task<Model> ModifyAsync(ITextChannel channel, BaseDiscordClient client, public static async Task<Model> ModifyAsync(ITextChannel channel, BaseDiscordClient client,


+ 1
- 1
src/Discord.Net.Rest/Entities/Channels/RestGuildChannel.cs View File

@@ -1,4 +1,4 @@
using System;
using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Collections.Immutable; using System.Collections.Immutable;
using System.Linq; using System.Linq;


+ 1
- 1
src/Discord.Net.WebSocket/Entities/Channels/SocketGuildChannel.cs View File

@@ -1,4 +1,4 @@
using Discord.Rest;
using Discord.Rest;
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Collections.Immutable; using System.Collections.Immutable;


Loading…
Cancel
Save