Browse Source

Add missing properties to ChannelInfo

Remove UserLimit property
pull/1373/head
NeKz 6 years ago
parent
commit
c34eb4ff57
No known key found for this signature in database GPG Key ID: C4257EE7BB20CA1E
2 changed files with 26 additions and 15 deletions
  1. +18
    -10
      src/Discord.Net.Rest/Entities/AuditLogs/DataTypes/ChannelInfo.cs
  2. +8
    -5
      src/Discord.Net.Rest/Entities/AuditLogs/DataTypes/ChannelUpdateAuditLogData.cs

+ 18
- 10
src/Discord.Net.Rest/Entities/AuditLogs/DataTypes/ChannelInfo.cs View File

@@ -5,12 +5,13 @@ namespace Discord.Rest
/// </summary> /// </summary>
public struct ChannelInfo public struct ChannelInfo
{ {
internal ChannelInfo(string name, string topic, int? bitrate, int? limit)
internal ChannelInfo(string name, string topic, int? rateLimit, bool? nsfw, int? bitrate)
{ {
Name = name; Name = name;
Topic = topic; Topic = topic;
SlowModeInterval = rateLimit;
IsNsfw = nsfw;
Bitrate = bitrate; Bitrate = bitrate;
UserLimit = limit;
} }


/// <summary> /// <summary>
@@ -28,20 +29,27 @@ namespace Discord.Rest
/// </returns> /// </returns>
public string Topic { get; } public string Topic { get; }
/// <summary> /// <summary>
/// Gets the bit-rate of this channel if applicable.
/// Gets the current slow-mode delay of this channel.
/// </summary> /// </summary>
/// <returns> /// <returns>
/// An <see cref="System.Int32"/> representing the bit-rate set for the voice channel; <c>null</c> if not
/// applicable.
/// An <see cref="Int32"/> representing the time in seconds required before the user can send another
/// message; <c>0</c> if disabled.
/// </returns> /// </returns>
public int? Bitrate { get; }
public int? SlowModeInterval { get; }
/// <summary>
/// Gets the value that indicates whether this channel is NSFW.
/// </summary>
/// <returns>
/// <c>true</c> if this channel has the NSFW flag enabled; otherwise <c>false</c>.
/// </returns>
public bool? IsNsfw { get; }
/// <summary> /// <summary>
/// Gets the number of users allowed to be in this channel if applicable.
/// Gets the bit-rate of this channel if applicable.
/// </summary> /// </summary>
/// <returns> /// <returns>
/// An <see cref="System.Int32" /> representing the number of users allowed to be in this voice channel;
/// <c>null</c> if not applicable.
/// An <see cref="System.Int32"/> representing the bit-rate set for the voice channel; <c>null</c> if not
/// applicable.
/// </returns> /// </returns>
public int? UserLimit { get; }
public int? Bitrate { get; }
} }
} }

+ 8
- 5
src/Discord.Net.Rest/Entities/AuditLogs/DataTypes/ChannelUpdateAuditLogData.cs View File

@@ -23,20 +23,23 @@ namespace Discord.Rest


var nameModel = changes.FirstOrDefault(x => x.ChangedProperty == "name"); var nameModel = changes.FirstOrDefault(x => x.ChangedProperty == "name");
var topicModel = changes.FirstOrDefault(x => x.ChangedProperty == "topic"); var topicModel = changes.FirstOrDefault(x => x.ChangedProperty == "topic");
var rateLimitPerUserModel = changes.FirstOrDefault(x => x.ChangedProperty == "rate_limit_per_user");
var nsfwModel = changes.FirstOrDefault(x => x.ChangedProperty == "nsfw");
var bitrateModel = changes.FirstOrDefault(x => x.ChangedProperty == "bitrate"); var bitrateModel = changes.FirstOrDefault(x => x.ChangedProperty == "bitrate");
var userLimitModel = changes.FirstOrDefault(x => x.ChangedProperty == "user_limit");


string oldName = nameModel?.OldValue?.ToObject<string>(discord.ApiClient.Serializer), string oldName = nameModel?.OldValue?.ToObject<string>(discord.ApiClient.Serializer),
newName = nameModel?.NewValue?.ToObject<string>(discord.ApiClient.Serializer); newName = nameModel?.NewValue?.ToObject<string>(discord.ApiClient.Serializer);
string oldTopic = topicModel?.OldValue?.ToObject<string>(discord.ApiClient.Serializer), string oldTopic = topicModel?.OldValue?.ToObject<string>(discord.ApiClient.Serializer),
newTopic = topicModel?.NewValue?.ToObject<string>(discord.ApiClient.Serializer); newTopic = topicModel?.NewValue?.ToObject<string>(discord.ApiClient.Serializer);
int? oldRateLimitPerUser = rateLimitPerUserModel?.OldValue?.ToObject<int>(discord.ApiClient.Serializer),
newRateLimitPerUser = rateLimitPerUserModel?.NewValue?.ToObject<int>(discord.ApiClient.Serializer);
bool? oldNsfw = nsfwModel?.OldValue?.ToObject<bool>(discord.ApiClient.Serializer),
newNsfw = nsfwModel?.NewValue?.ToObject<bool>(discord.ApiClient.Serializer);
int? oldBitrate = bitrateModel?.OldValue?.ToObject<int>(discord.ApiClient.Serializer), int? oldBitrate = bitrateModel?.OldValue?.ToObject<int>(discord.ApiClient.Serializer),
newBitrate = bitrateModel?.NewValue?.ToObject<int>(discord.ApiClient.Serializer); newBitrate = bitrateModel?.NewValue?.ToObject<int>(discord.ApiClient.Serializer);
int? oldLimit = userLimitModel?.OldValue?.ToObject<int>(discord.ApiClient.Serializer),
newLimit = userLimitModel?.NewValue?.ToObject<int>(discord.ApiClient.Serializer);


var before = new ChannelInfo(oldName, oldTopic, oldBitrate, oldLimit);
var after = new ChannelInfo(newName, newTopic, newBitrate, newLimit);
var before = new ChannelInfo(oldName, oldTopic, oldRateLimitPerUser, oldNsfw, oldBitrate);
var after = new ChannelInfo(newName, newTopic, newRateLimitPerUser, newNsfw, newBitrate);


return new ChannelUpdateAuditLogData(entry.TargetId.Value, before, after); return new ChannelUpdateAuditLogData(entry.TargetId.Value, before, after);
} }


Loading…
Cancel
Save