feature: Bump API version to 9 (#1847)

* First changes to the config

* Lots of changes to fit the new version

* Remove PermissionTargetConverter
This commit is contained in:
Paulo
2021-05-24 11:39:20 -03:00
committed by GitHub
parent 690bc3ff9d
commit 06a64b7877
43 changed files with 82 additions and 436 deletions

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 />
@@ -1234,8 +1207,6 @@ namespace Discord.WebSocket
/// <inheritdoc />
ulong IGuild.DefaultChannelId => DefaultChannel?.Id ?? 0;
/// <inheritdoc />
ulong? IGuild.EmbedChannelId => EmbedChannelId;
/// <inheritdoc />
ulong? IGuild.WidgetChannelId => WidgetChannelId;
/// <inheritdoc />
ulong? IGuild.SystemChannelId => SystemChannelId;
@@ -1290,10 +1261,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 />

View File

@@ -189,9 +189,6 @@ namespace Discord.WebSocket
/// <inheritdoc />
public Task UnpinAsync(RequestOptions options = null)
=> MessageHelper.UnpinAsync(this, Discord, options);
/// <inheritdoc />
public Task ModifySuppressionAsync(bool suppressEmbeds, RequestOptions options = null)
=> MessageHelper.SuppressEmbedsAsync(this, Discord, suppressEmbeds, options);
public string Resolve(int startIndex, TagHandling userHandling = TagHandling.Name, TagHandling channelHandling = TagHandling.Name,
TagHandling roleHandling = TagHandling.Name, TagHandling everyoneHandling = TagHandling.Ignore, TagHandling emojiHandling = TagHandling.Name)

View File

@@ -2,6 +2,7 @@ using System;
using System.Collections.Generic;
using System.Collections.Immutable;
using System.Diagnostics;
using System.Linq;
using Model = Discord.API.Presence;
namespace Discord.WebSocket
@@ -15,15 +16,12 @@ namespace Discord.WebSocket
/// <inheritdoc />
public UserStatus Status { get; }
/// <inheritdoc />
public IActivity Activity { get; }
/// <inheritdoc />
public IImmutableSet<ClientType> ActiveClients { get; }
/// <inheritdoc />
public IImmutableList<IActivity> Activities { get; }
internal SocketPresence(UserStatus status, IActivity activity, IImmutableSet<ClientType> activeClients, IImmutableList<IActivity> activities)
internal SocketPresence(UserStatus status, IImmutableSet<ClientType> activeClients, IImmutableList<IActivity> activities)
{
Status = status;
Activity = activity;
ActiveClients = activeClients ?? ImmutableHashSet<ClientType>.Empty;
Activities = activities ?? ImmutableList<IActivity>.Empty;
}
@@ -31,7 +29,7 @@ namespace Discord.WebSocket
{
var clients = ConvertClientTypesDict(model.ClientStatus.GetValueOrDefault());
var activities = ConvertActivitiesList(model.Activities);
return new SocketPresence(model.Status, model.Game?.ToEntity(), clients, activities);
return new SocketPresence(model.Status, clients, activities);
}
/// <summary>
/// Creates a new <see cref="IReadOnlyCollection{T}"/> containing all of the client types
@@ -84,7 +82,7 @@ namespace Discord.WebSocket
/// A string that resolves to <see cref="Discord.WebSocket.SocketPresence.Status" />.
/// </returns>
public override string ToString() => Status.ToString();
private string DebuggerDisplay => $"{Status}{(Activity != null ? $", {Activity.Name}": "")}";
private string DebuggerDisplay => $"{Status}{(Activities?.FirstOrDefault()?.Name ?? "")}";
internal SocketPresence Clone() => this;
}

View File

@@ -25,7 +25,7 @@ namespace Discord.WebSocket
/// <inheritdoc />
public override bool IsWebhook => false;
/// <inheritdoc />
internal override SocketPresence Presence { get { return new SocketPresence(UserStatus.Offline, null, null, null); } set { } }
internal override SocketPresence Presence { get { return new SocketPresence(UserStatus.Offline, null, null); } set { } }
/// <inheritdoc />
/// <exception cref="NotSupportedException">This field is not supported for an unknown user.</exception>
internal override SocketGlobalUser GlobalUser =>

View File

@@ -38,8 +38,6 @@ namespace Discord.WebSocket
/// <inheritdoc />
public string Mention => MentionUtils.MentionUser(Id);
/// <inheritdoc />
public IActivity Activity => Presence.Activity;
/// <inheritdoc />
public UserStatus Status => Presence.Status;
/// <inheritdoc />
public IImmutableSet<ClientType> ActiveClients => Presence.ActiveClients ?? ImmutableHashSet<ClientType>.Empty;

View File

@@ -30,7 +30,7 @@ namespace Discord.WebSocket
/// <inheritdoc />
public override bool IsWebhook => true;
/// <inheritdoc />
internal override SocketPresence Presence { get { return new SocketPresence(UserStatus.Offline, null, null, null); } set { } }
internal override SocketPresence Presence { get { return new SocketPresence(UserStatus.Offline, null, null); } set { } }
internal override SocketGlobalUser GlobalUser =>
throw new NotSupportedException();