Reworked IChannel.IsNsfw to support the new API flag (#771)
IChannel.IsNsfw will now return false when being used on any channel that is not an ITextChannel. When being used on an ITextChannel, this will now account for the API flag, and fall back to the channel name. (this is gross design, thanks discord)
This commit is contained in:
@@ -41,7 +41,7 @@ namespace Discord.WebSocket
|
||||
|
||||
//IChannel
|
||||
string IChannel.Name => null;
|
||||
bool IChannel.IsNsfw => ChannelHelper.IsNsfw(this);
|
||||
bool IChannel.IsNsfw => false;
|
||||
|
||||
Task<IUser> IChannel.GetUserAsync(ulong id, CacheMode mode, RequestOptions options)
|
||||
=> Task.FromResult<IUser>(null); //Overridden
|
||||
|
||||
@@ -16,6 +16,7 @@ namespace Discord.WebSocket
|
||||
private readonly MessageCache _messages;
|
||||
|
||||
public string Topic { get; private set; }
|
||||
internal bool Nsfw { get; private set; }
|
||||
|
||||
public string Mention => MentionUtils.MentionChannel(Id);
|
||||
public IReadOnlyCollection<SocketMessage> CachedMessages => _messages?.Messages ?? ImmutableArray.Create<SocketMessage>();
|
||||
@@ -41,6 +42,7 @@ namespace Discord.WebSocket
|
||||
base.Update(state, model);
|
||||
|
||||
Topic = model.Topic.Value;
|
||||
Nsfw = model.Nsfw.GetValueOrDefault();
|
||||
}
|
||||
|
||||
public Task ModifyAsync(Action<TextChannelProperties> func, RequestOptions options = null)
|
||||
@@ -144,5 +146,8 @@ namespace Discord.WebSocket
|
||||
=> await SendMessageAsync(text, isTTS, embed, options).ConfigureAwait(false);
|
||||
IDisposable IMessageChannel.EnterTypingState(RequestOptions options)
|
||||
=> EnterTypingState(options);
|
||||
|
||||
// IChannel
|
||||
bool IChannel.IsNsfw => Nsfw || ChannelHelper.IsNsfw(this);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user