Skip to content

Commit

Permalink
Mark ChannelHelper.IsNsfw Obsolete
Browse files Browse the repository at this point in the history
Discord no longer treats channels prefixed with 'nsfw' as NSFW,
so we no longer need to have this check.
  • Loading branch information
FiniteReality committed May 28, 2018
1 parent 237ad0f commit 683b3f2
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 5 deletions.
2 changes: 2 additions & 0 deletions src/Discord.Net.Rest/Entities/Channels/ChannelHelper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -338,8 +338,10 @@ private static IUser GetAuthor(BaseDiscordClient client, IGuild guild, UserModel
return author;
}

[Obsolete("Use channel.IsNsfw instead")]
public static bool IsNsfw(IChannel channel)
=> IsNsfw(channel.Name);
[Obsolete("Use Channel.IsNsfw instead")]
public static bool IsNsfw(string channelName) =>
channelName == "nsfw" || channelName.StartsWith("nsfw-");
}
Expand Down
8 changes: 4 additions & 4 deletions src/Discord.Net.Rest/Entities/Channels/RestTextChannel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ public class RestTextChannel : RestGuildChannel, IRestMessageChannel, ITextChann
public string Mention => MentionUtils.MentionChannel(Id);

private bool _nsfw;
public bool IsNsfw => _nsfw || ChannelHelper.IsNsfw(this);
public bool IsNsfw => _nsfw;

internal RestTextChannel(BaseDiscordClient discord, IGuild guild, ulong id)
: base(discord, guild, id)
Expand Down Expand Up @@ -47,7 +47,7 @@ public Task<RestGuildUser> GetUserAsync(ulong id, RequestOptions options = null)
=> ChannelHelper.GetUserAsync(this, Guild, Discord, id, options);
public IAsyncEnumerable<IReadOnlyCollection<RestGuildUser>> GetUsersAsync(RequestOptions options = null)
=> ChannelHelper.GetUsersAsync(this, Guild, Discord, null, null, options);

public Task<RestMessage> GetMessageAsync(ulong id, RequestOptions options = null)
=> ChannelHelper.GetMessageAsync(this, Discord, id, options);
public IAsyncEnumerable<IReadOnlyCollection<RestMessage>> GetMessagesAsync(int limit = DiscordConfig.MaxMessagesPerBatch, RequestOptions options = null)
Expand Down Expand Up @@ -89,7 +89,7 @@ public Task<RestWebhook> GetWebhookAsync(ulong id, RequestOptions options = null
=> ChannelHelper.GetWebhookAsync(this, Discord, id, options);
public Task<IReadOnlyCollection<RestWebhook>> GetWebhooksAsync(RequestOptions options = null)
=> ChannelHelper.GetWebhooksAsync(this, Discord, options);

public Task<ICategoryChannel> GetCategoryAsync(RequestOptions options = null)
=> ChannelHelper.GetCategoryAsync(this, Discord, options);

Expand Down Expand Up @@ -118,7 +118,7 @@ IAsyncEnumerable<IReadOnlyCollection<IMessage>> IMessageChannel.GetMessagesAsync
else
return AsyncEnumerable.Empty<IReadOnlyCollection<IMessage>>();
}

IAsyncEnumerable<IReadOnlyCollection<IMessage>> IMessageChannel.GetMessagesAsync(ulong fromMessageId, Direction dir, int limit, CacheMode mode, RequestOptions options)
{
if (mode == CacheMode.AllowDownload)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ public ICategoryChannel Category
=> CategoryId.HasValue ? Guild.GetChannel(CategoryId.Value) as ICategoryChannel : null;

private bool _nsfw;
public bool IsNsfw => _nsfw || ChannelHelper.IsNsfw(this);
public bool IsNsfw => _nsfw;

public string Mention => MentionUtils.MentionChannel(Id);
public IReadOnlyCollection<SocketMessage> CachedMessages => _messages?.Messages ?? ImmutableArray.Create<SocketMessage>();
Expand Down

0 comments on commit 683b3f2

Please sign in to comment.