Browse Source

Remove rest of GuildEmbed

pull/1849/head
Paulo 4 years ago
parent
commit
b661629e8d
11 changed files with 0 additions and 239 deletions
  1. +0
    -21
      src/Discord.Net.Core/Entities/Guilds/GuildEmbedProperties.cs
  2. +0
    -36
      src/Discord.Net.Core/Entities/Guilds/IGuild.cs
  3. +0
    -4
      src/Discord.Net.Rest/API/Common/Guild.cs
  4. +0
    -13
      src/Discord.Net.Rest/API/Common/GuildEmbed.cs
  5. +0
    -8
      src/Discord.Net.Rest/ClientHelper.cs
  6. +0
    -26
      src/Discord.Net.Rest/DiscordRestApiClient.cs
  7. +0
    -3
      src/Discord.Net.Rest/DiscordRestClient.cs
  8. +0
    -21
      src/Discord.Net.Rest/Entities/Guilds/GuildHelper.cs
  9. +0
    -49
      src/Discord.Net.Rest/Entities/Guilds/RestGuild.cs
  10. +0
    -25
      src/Discord.Net.Rest/Entities/Guilds/RestGuildEmbed.cs
  11. +0
    -33
      src/Discord.Net.WebSocket/Entities/Guilds/SocketGuild.cs

+ 0
- 21
src/Discord.Net.Core/Entities/Guilds/GuildEmbedProperties.cs View File

@@ -1,21 +0,0 @@
namespace Discord
{
/// <summary>
/// Provides properties that are used to modify the widget of an <see cref="IGuild" /> with the specified changes.
/// </summary>
public class GuildEmbedProperties
{
/// <summary>
/// Sets whether the widget should be enabled.
/// </summary>
public Optional<bool> Enabled { get; set; }
/// <summary>
/// Sets the channel that the invite should place its users in, if not <c>null</c>.
/// </summary>
public Optional<IChannel> Channel { get; set; }
/// <summary>
/// Sets the channel the invite should place its users in, if not <c>null</c>.
/// </summary>
public Optional<ulong?> ChannelId { get; set; }
}
}

+ 0
- 36
src/Discord.Net.Core/Entities/Guilds/IGuild.cs View File

@@ -28,13 +28,6 @@ namespace Discord
/// </returns>
int AFKTimeout { get; }
/// <summary>
/// Gets a value that indicates whether this guild is embeddable (i.e. can use widget).
/// </summary>
/// <returns>
/// <see langword="true" /> if this guild has a widget enabled; otherwise <see langword="false" />.
/// </returns>
bool IsEmbeddable { get; }
/// <summary>
/// Gets a value that indicates whether this guild has the widget enabled.
/// </summary>
/// <returns>
@@ -132,14 +125,6 @@ namespace Discord
/// </returns>
ulong? AFKChannelId { get; }
/// <summary>
/// Gets the ID of the widget embed channel of this guild.
/// </summary>
/// <returns>
/// A <see langword="ulong"/> representing the snowflake identifier of the embedded channel found within the
/// widget settings of this guild; <see langword="null" /> if none is set.
/// </returns>
ulong? EmbedChannelId { get; }
/// <summary>
/// Gets the ID of the channel assigned to the widget of this guild.
/// </summary>
/// <returns>
@@ -349,16 +334,6 @@ namespace Discord
/// </returns>
Task ModifyAsync(Action<GuildProperties> func, RequestOptions options = null);
/// <summary>
/// Modifies this guild's embed channel.
/// </summary>
/// <param name="func">The delegate containing the properties to modify the guild widget with.</param>
/// <param name="options">The options to be used when sending the request.</param>
/// <returns>
/// A task that represents the asynchronous modification operation.
/// </returns>
[Obsolete("This endpoint is deprecated, use ModifyWidgetAsync instead.")]
Task ModifyEmbedAsync(Action<GuildEmbedProperties> func, RequestOptions options = null);
/// <summary>
/// Modifies this guild's widget.
/// </summary>
/// <param name="func">The delegate containing the properties to modify the guild widget with.</param>
@@ -577,17 +552,6 @@ namespace Discord
/// </returns>
Task<ITextChannel> GetDefaultChannelAsync(CacheMode mode = CacheMode.AllowDownload, RequestOptions options = null);
/// <summary>
/// Gets the embed channel (i.e. the channel set in the guild's widget settings) in this guild.
/// </summary>
/// <param name="mode">The <see cref="CacheMode" /> that determines whether the object should be fetched from cache.</param>
/// <param name="options">The options to be used when sending the request.</param>
/// <returns>
/// A task that represents the asynchronous get operation. The task result contains the embed channel set
/// within the server's widget settings; <see langword="null" /> if none is set.
/// </returns>
[Obsolete("This endpoint is deprecated, use GetWidgetChannelAsync instead.")]
Task<IGuildChannel> GetEmbedChannelAsync(CacheMode mode = CacheMode.AllowDownload, RequestOptions options = null);
/// <summary>
/// Gets the widget channel (i.e. the channel set in the guild's widget settings) in this guild.
/// </summary>
/// <param name="mode">The <see cref="CacheMode" /> that determines whether the object should be fetched from cache.</param>


+ 0
- 4
src/Discord.Net.Rest/API/Common/Guild.cs View File

@@ -23,10 +23,6 @@ namespace Discord.API
public ulong? AFKChannelId { get; set; }
[JsonProperty("afk_timeout")]
public int AFKTimeout { get; set; }
[JsonProperty("embed_enabled")]
public Optional<bool> EmbedEnabled { get; set; }
[JsonProperty("embed_channel_id")]
public Optional<ulong?> EmbedChannelId { get; set; }
[JsonProperty("verification_level")]
public VerificationLevel VerificationLevel { get; set; }
[JsonProperty("default_message_notifications")]


+ 0
- 13
src/Discord.Net.Rest/API/Common/GuildEmbed.cs View File

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

namespace Discord.API
{
internal class GuildEmbed
{
[JsonProperty("enabled")]
public bool Enabled { get; set; }
[JsonProperty("channel_id")]
public ulong? ChannelId { get; set; }
}
}

+ 0
- 8
src/Discord.Net.Rest/ClientHelper.cs View File

@@ -69,14 +69,6 @@ namespace Discord.Rest
return RestGuild.Create(client, model);
return null;
}
public static async Task<RestGuildEmbed?> GetGuildEmbedAsync(BaseDiscordClient client,
ulong id, RequestOptions options)
{
var model = await client.ApiClient.GetGuildEmbedAsync(id, options).ConfigureAwait(false);
if (model != null)
return RestGuildEmbed.Create(model);
return null;
}
public static async Task<RestGuildWidget?> GetGuildWidgetAsync(BaseDiscordClient client,
ulong id, RequestOptions options)
{


+ 0
- 26
src/Discord.Net.Rest/DiscordRestApiClient.cs View File

@@ -949,32 +949,6 @@ namespace Discord.API
await SendAsync("DELETE", () => $"guilds/{guildId}/bans/{userId}", ids, options: options).ConfigureAwait(false);
}

//Guild Embeds
/// <exception cref="ArgumentException"><paramref name="guildId"/> must not be equal to zero.</exception>
public async Task<GuildEmbed> GetGuildEmbedAsync(ulong guildId, RequestOptions options = null)
{
Preconditions.NotEqual(guildId, 0, nameof(guildId));
options = RequestOptions.CreateOrClone(options);

try
{
var ids = new BucketIds(guildId: guildId);
return await SendAsync<GuildEmbed>("GET", () => $"guilds/{guildId}/embed", ids, options: options).ConfigureAwait(false);
}
catch (HttpException ex) when (ex.HttpCode == HttpStatusCode.NotFound) { return null; }
}
/// <exception cref="ArgumentException"><paramref name="guildId"/> must not be equal to zero.</exception>
/// <exception cref="ArgumentNullException"><paramref name="args"/> must not be <see langword="null"/>.</exception>
public async Task<GuildEmbed> ModifyGuildEmbedAsync(ulong guildId, Rest.ModifyGuildEmbedParams args, RequestOptions options = null)
{
Preconditions.NotNull(args, nameof(args));
Preconditions.NotEqual(guildId, 0, nameof(guildId));
options = RequestOptions.CreateOrClone(options);

var ids = new BucketIds(guildId: guildId);
return await SendJsonAsync<GuildEmbed>("PATCH", () => $"guilds/{guildId}/embed", args, ids, options: options).ConfigureAwait(false);
}

//Guild Widget
/// <exception cref="ArgumentException"><paramref name="guildId"/> must not be equal to zero.</exception>
public async Task<GuildWidget> GetGuildWidgetAsync(ulong guildId, RequestOptions options = null)


+ 0
- 3
src/Discord.Net.Rest/DiscordRestClient.cs View File

@@ -80,9 +80,6 @@ namespace Discord.Rest
=> ClientHelper.GetGuildAsync(this, id, false, options);
public Task<RestGuild> GetGuildAsync(ulong id, bool withCounts, RequestOptions options = null)
=> ClientHelper.GetGuildAsync(this, id, withCounts, options);
[Obsolete("This endpoint is deprecated, use GetGuildWidgetAsync instead.")]
public Task<RestGuildEmbed?> GetGuildEmbedAsync(ulong id, RequestOptions options = null)
=> ClientHelper.GetGuildEmbedAsync(this, id, options);
public Task<RestGuildWidget?> GetGuildWidgetAsync(ulong id, RequestOptions options = null)
=> ClientHelper.GetGuildWidgetAsync(this, id, options);
public IAsyncEnumerable<IReadOnlyCollection<RestUserGuild>> GetGuildSummariesAsync(RequestOptions options = null)


+ 0
- 21
src/Discord.Net.Rest/Entities/Guilds/GuildHelper.cs View File

@@ -4,7 +4,6 @@ using System.Collections.Generic;
using System.Collections.Immutable;
using System.Linq;
using System.Threading.Tasks;
using EmbedModel = Discord.API.GuildEmbed;
using WidgetModel = Discord.API.GuildWidget;
using Model = Discord.API.Guild;
using RoleModel = Discord.API.Role;
@@ -81,26 +80,6 @@ namespace Discord.Rest
return await client.ApiClient.ModifyGuildAsync(guild.Id, apiArgs, options).ConfigureAwait(false);
}
/// <exception cref="ArgumentNullException"><paramref name="func"/> is <c>null</c>.</exception>
public static async Task<EmbedModel> ModifyEmbedAsync(IGuild guild, BaseDiscordClient client,
Action<GuildEmbedProperties> func, RequestOptions options)
{
if (func == null) throw new ArgumentNullException(nameof(func));

var args = new GuildEmbedProperties();
func(args);
var apiArgs = new API.Rest.ModifyGuildEmbedParams
{
Enabled = args.Enabled
};

if (args.Channel.IsSpecified)
apiArgs.ChannelId = args.Channel.Value?.Id;
else if (args.ChannelId.IsSpecified)
apiArgs.ChannelId = args.ChannelId.Value;

return await client.ApiClient.ModifyGuildEmbedAsync(guild.Id, apiArgs, options).ConfigureAwait(false);
}
/// <exception cref="ArgumentNullException"><paramref name="func"/> is <c>null</c>.</exception>
public static async Task<WidgetModel> ModifyWidgetAsync(IGuild guild, BaseDiscordClient client,
Action<GuildWidgetProperties> func, RequestOptions options)
{


+ 0
- 49
src/Discord.Net.Rest/Entities/Guilds/RestGuild.cs View File

@@ -6,7 +6,6 @@ using System.Diagnostics;
using System.Globalization;
using System.Linq;
using System.Threading.Tasks;
using EmbedModel = Discord.API.GuildEmbed;
using WidgetModel = Discord.API.GuildWidget;
using Model = Discord.API.Guild;

@@ -27,8 +26,6 @@ namespace Discord.Rest
/// <inheritdoc />
public int AFKTimeout { get; private set; }
/// <inheritdoc />
public bool IsEmbeddable { get; private set; }
/// <inheritdoc />
public bool IsWidgetEnabled { get; private set; }
/// <inheritdoc />
public VerificationLevel VerificationLevel { get; private set; }
@@ -42,8 +39,6 @@ namespace Discord.Rest
/// <inheritdoc />
public ulong? AFKChannelId { get; private set; }
/// <inheritdoc />
public ulong? EmbedChannelId { get; private set; }
/// <inheritdoc />
public ulong? WidgetChannelId { get; private set; }
/// <inheritdoc />
public ulong? SystemChannelId { get; private set; }
@@ -131,16 +126,12 @@ namespace Discord.Rest
internal void Update(Model model)
{
AFKChannelId = model.AFKChannelId;
if (model.EmbedChannelId.IsSpecified)
EmbedChannelId = model.EmbedChannelId.Value;
if (model.WidgetChannelId.IsSpecified)
WidgetChannelId = model.WidgetChannelId.Value;
SystemChannelId = model.SystemChannelId;
RulesChannelId = model.RulesChannelId;
PublicUpdatesChannelId = model.PublicUpdatesChannelId;
AFKTimeout = model.AFKTimeout;
if (model.EmbedEnabled.IsSpecified)
IsEmbeddable = model.EmbedEnabled.Value;
if (model.WidgetEnabled.IsSpecified)
IsWidgetEnabled = model.WidgetEnabled.Value;
IconId = model.Icon;
@@ -198,11 +189,6 @@ namespace Discord.Rest

Available = true;
}
internal void Update(EmbedModel model)
{
EmbedChannelId = model.ChannelId;
IsEmbeddable = model.Enabled;
}
internal void Update(WidgetModel model)
{
WidgetChannelId = model.ChannelId;
@@ -239,15 +225,6 @@ namespace Discord.Rest
Update(model);
}

/// <inheritdoc />
/// <exception cref="ArgumentNullException"><paramref name="func"/> is <see langword="null"/>.</exception>
[Obsolete("This endpoint is deprecated, use ModifyWidgetAsync instead.")]
public async Task ModifyEmbedAsync(Action<GuildEmbedProperties> func, RequestOptions options = null)
{
var model = await GuildHelper.ModifyEmbedAsync(this, Discord, func, options).ConfigureAwait(false);
Update(model);
}

/// <inheritdoc />
/// <exception cref="ArgumentNullException"><paramref name="func"/> is <see langword="null"/>.</exception>
public async Task ModifyWidgetAsync(Action<GuildWidgetProperties> func, RequestOptions options = null)
@@ -461,23 +438,6 @@ namespace Discord.Rest
.FirstOrDefault();
}

/// <summary>
/// Gets the embed channel (i.e. the channel set in the guild's widget settings) in this guild.
/// </summary>
/// <param name="options">The options to be used when sending the request.</param>
/// <returns>
/// A task that represents the asynchronous get operation. The task result contains the embed channel set
/// within the server's widget settings; <see langword="null"/> if none is set.
/// </returns>
[Obsolete("This endpoint is deprecated, use GetWidgetChannelAsync instead.")]
public async Task<RestGuildChannel> GetEmbedChannelAsync(RequestOptions options = null)
{
var embedId = EmbedChannelId;
if (embedId.HasValue)
return await GuildHelper.GetChannelAsync(this, Discord, embedId.Value, options).ConfigureAwait(false);
return null;
}

/// <summary>
/// Gets the widget channel (i.e. the channel set in the guild's widget settings) in this guild.
/// </summary>
@@ -935,15 +895,6 @@ namespace Discord.Rest
return null;
}
/// <inheritdoc />
[Obsolete("This endpoint is deprecated, use GetWidgetChannelAsync instead.")]
async Task<IGuildChannel> IGuild.GetEmbedChannelAsync(CacheMode mode, RequestOptions options)
{
if (mode == CacheMode.AllowDownload)
return await GetEmbedChannelAsync(options).ConfigureAwait(false);
else
return null;
}
/// <inheritdoc />
async Task<IGuildChannel> IGuild.GetWidgetChannelAsync(CacheMode mode, RequestOptions options)
{
if (mode == CacheMode.AllowDownload)


+ 0
- 25
src/Discord.Net.Rest/Entities/Guilds/RestGuildEmbed.cs View File

@@ -1,25 +0,0 @@
using System.Diagnostics;
using Model = Discord.API.GuildEmbed;

namespace Discord.Rest
{
[DebuggerDisplay(@"{DebuggerDisplay,nq}")]
public struct RestGuildEmbed
{
public bool IsEnabled { get; private set; }
public ulong? ChannelId { get; private set; }

internal RestGuildEmbed(bool isEnabled, ulong? channelId)
{
ChannelId = channelId;
IsEnabled = isEnabled;
}
internal static RestGuildEmbed Create(Model model)
{
return new RestGuildEmbed(model.Enabled, model.ChannelId);
}

public override string ToString() => ChannelId?.ToString() ?? "Unknown";
private string DebuggerDisplay => $"{ChannelId} ({(IsEnabled ? "Enabled" : "Disabled")})";
}
}

+ 0
- 33
src/Discord.Net.WebSocket/Entities/Guilds/SocketGuild.cs View File

@@ -46,8 +46,6 @@ namespace Discord.WebSocket
/// <inheritdoc />
public int AFKTimeout { get; private set; }
/// <inheritdoc />
public bool IsEmbeddable { get; private set; }
/// <inheritdoc />
public bool IsWidgetEnabled { get; private set; }
/// <inheritdoc />
public VerificationLevel VerificationLevel { get; private set; }
@@ -84,7 +82,6 @@ namespace Discord.WebSocket
public ulong? ApplicationId { get; internal set; }

internal ulong? AFKChannelId { get; private set; }
internal ulong? EmbedChannelId { get; private set; }
internal ulong? WidgetChannelId { get; private set; }
internal ulong? SystemChannelId { get; private set; }
internal ulong? RulesChannelId { get; private set; }
@@ -198,21 +195,6 @@ namespace Discord.WebSocket
}
}
/// <summary>
/// Gets the embed channel (i.e. the channel set in the guild's widget settings) in this guild.
/// </summary>
/// <returns>
/// A channel set within the server's widget settings; <see langword="null"/> if none is set.
/// </returns>
[Obsolete("This property is deprecated, use WidgetChannel instead.")]
public SocketGuildChannel EmbedChannel
{
get
{
var id = EmbedChannelId;
return id.HasValue ? GetChannel(id.Value) : null;
}
}
/// <summary>
/// Gets the widget channel (i.e. the channel set in the guild's widget settings) in this guild.
/// </summary>
/// <returns>
@@ -440,16 +422,12 @@ namespace Discord.WebSocket
internal void Update(ClientState state, Model model)
{
AFKChannelId = model.AFKChannelId;
if (model.EmbedChannelId.IsSpecified)
EmbedChannelId = model.EmbedChannelId.Value;
if (model.WidgetChannelId.IsSpecified)
WidgetChannelId = model.WidgetChannelId.Value;
SystemChannelId = model.SystemChannelId;
RulesChannelId = model.RulesChannelId;
PublicUpdatesChannelId = model.PublicUpdatesChannelId;
AFKTimeout = model.AFKTimeout;
if (model.EmbedEnabled.IsSpecified)
IsEmbeddable = model.EmbedEnabled.Value;
if (model.WidgetEnabled.IsSpecified)
IsWidgetEnabled = model.WidgetEnabled.Value;
IconId = model.Icon;
@@ -548,11 +526,6 @@ namespace Discord.WebSocket

/// <inheritdoc />
/// <exception cref="ArgumentNullException"><paramref name="func"/> is <see langword="null"/>.</exception>
[Obsolete("This endpoint is deprecated, use ModifyWidgetAsync instead.")]
public Task ModifyEmbedAsync(Action<GuildEmbedProperties> func, RequestOptions options = null)
=> GuildHelper.ModifyEmbedAsync(this, Discord, func, options);
/// <inheritdoc />
/// <exception cref="ArgumentNullException"><paramref name="func"/> is <see langword="null"/>.</exception>
public Task ModifyWidgetAsync(Action<GuildWidgetProperties> func, RequestOptions options = null)
=> GuildHelper.ModifyWidgetAsync(this, Discord, func, options);
/// <inheritdoc />
@@ -1232,8 +1205,6 @@ namespace Discord.WebSocket
/// <inheritdoc />
bool IGuild.Available => true;
/// <inheritdoc />
ulong? IGuild.EmbedChannelId => EmbedChannelId;
/// <inheritdoc />
ulong? IGuild.WidgetChannelId => WidgetChannelId;
/// <inheritdoc />
ulong? IGuild.SystemChannelId => SystemChannelId;
@@ -1288,10 +1259,6 @@ namespace Discord.WebSocket
Task<ITextChannel> IGuild.GetDefaultChannelAsync(CacheMode mode, RequestOptions options)
=> Task.FromResult<ITextChannel>(DefaultChannel);
/// <inheritdoc />
[Obsolete("This method is deprecated, use GetWidgetChannelAsync instead.")]
Task<IGuildChannel> IGuild.GetEmbedChannelAsync(CacheMode mode, RequestOptions options)
=> Task.FromResult<IGuildChannel>(EmbedChannel);
/// <inheritdoc />
Task<IGuildChannel> IGuild.GetWidgetChannelAsync(CacheMode mode, RequestOptions options)
=> Task.FromResult<IGuildChannel>(WidgetChannel);
/// <inheritdoc />


Loading…
Cancel
Save