Skip to content

Commit

Permalink
feature: Bump API version to 9 (#1847)
Browse files Browse the repository at this point in the history
* First changes to the config

* Lots of changes to fit the new version

* Remove PermissionTargetConverter
  • Loading branch information
SubZero0 committed May 24, 2021
1 parent 690bc3f commit 06a64b7
Show file tree
Hide file tree
Showing 43 changed files with 82 additions and 436 deletions.
16 changes: 2 additions & 14 deletions src/Discord.Net.Core/DiscordConfig.cs
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ public class DiscordConfig
/// <see href="https://discord.com/developers/docs/reference#api-versioning">Discord API documentation</see>
/// .</para>
/// </returns>
public const int APIVersion = 6;
public const int APIVersion = 9;
/// <summary>
/// Returns the Voice API version Discord.Net uses.
/// </summary>
Expand All @@ -43,7 +43,7 @@ public class DiscordConfig
/// <returns>
/// The user agent used in each Discord.Net request.
/// </returns>
public static string UserAgent { get; } = $"DiscordBot (https://github.com/RogueException/Discord.Net, v{Version})";
public static string UserAgent { get; } = $"DiscordBot (https://github.com/discord-net/Discord.Net, v{Version})";
/// <summary>
/// Returns the base Discord API URL.
/// </summary>
Expand Down Expand Up @@ -141,18 +141,6 @@ public class DiscordConfig
/// </remarks>
internal bool DisplayInitialLog { get; set; } = true;

/// <summary>
/// Gets or sets the level of precision of the rate limit reset response.
/// </summary>
/// <remarks>
/// If set to <see cref="RateLimitPrecision.Second"/>, this value will be rounded up to the
/// nearest second.
/// </remarks>
/// <returns>
/// The currently set <see cref="RateLimitPrecision"/>.
/// </returns>
public RateLimitPrecision RateLimitPrecision { get; set; } = RateLimitPrecision.Millisecond;

/// <summary>
/// Gets or sets whether or not rate-limits should use the system clock.
/// </summary>
Expand Down
36 changes: 0 additions & 36 deletions src/Discord.Net.Core/Entities/Guilds/IGuild.cs
Original file line number Diff line number Diff line change
Expand Up @@ -28,13 +28,6 @@ public interface IGuild : IDeletable, ISnowflakeEntity
/// </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>
Expand Down Expand Up @@ -147,14 +140,6 @@ public interface IGuild : IDeletable, ISnowflakeEntity
/// </returns>
ulong DefaultChannelId { 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>
Expand Down Expand Up @@ -364,16 +349,6 @@ public interface IGuild : IDeletable, ISnowflakeEntity
/// </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>
Expand Down Expand Up @@ -592,17 +567,6 @@ public interface IGuild : IDeletable, ISnowflakeEntity
/// </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>
Expand Down
4 changes: 2 additions & 2 deletions src/Discord.Net.Core/Entities/Guilds/PermissionTarget.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,10 @@ public enum PermissionTarget
/// <summary>
/// The target of the permission is a role.
/// </summary>
Role,
Role = 0,
/// <summary>
/// The target of the permission is a user.
/// </summary>
User
User = 1,
}
}
12 changes: 0 additions & 12 deletions src/Discord.Net.Core/Entities/Messages/IUserMessage.cs
Original file line number Diff line number Diff line change
Expand Up @@ -36,18 +36,6 @@ public interface IUserMessage : IMessage
/// </returns>
Task ModifyAsync(Action<MessageProperties> func, RequestOptions options = null);
/// <summary>
/// Modifies the suppression of this message.
/// </summary>
/// <remarks>
/// This method modifies whether or not embeds in this message are suppressed (hidden).
/// </remarks>
/// <param name="suppressEmbeds">Whether or not embeds in this message should be suppressed.</param>
/// <param name="options">The options to be used when sending the request.</param>
/// <returns>
/// A task that represents the asynchronous modification operation.
/// </returns>
Task ModifySuppressionAsync(bool suppressEmbeds, RequestOptions options = null);
/// <summary>
/// Adds this message to its channel's pinned messages.
/// </summary>
/// <param name="options">The options to be used when sending the request.</param>
Expand Down
3 changes: 0 additions & 3 deletions src/Discord.Net.Core/Entities/Messages/MessageType.cs
Original file line number Diff line number Diff line change
Expand Up @@ -60,9 +60,6 @@ public enum MessageType
/// <summary>
/// The message is an inline reply.
/// </summary>
/// <remarks>
/// Only available in API v8.
/// </remarks>
Reply = 19,
}
}
3 changes: 3 additions & 0 deletions src/Discord.Net.Core/Entities/Permissions/GuildPermissions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,9 @@ public struct GuildPermissions
/// <summary> Creates a new <see cref="GuildPermissions"/> with the provided packed value. </summary>
public GuildPermissions(ulong rawValue) { RawValue = rawValue; }

/// <summary> Creates a new <see cref="GuildPermissions"/> with the provided packed value after converting to ulong. </summary>
public GuildPermissions(string rawValue) { RawValue = ulong.Parse(rawValue); }

private GuildPermissions(ulong initialValue,
bool? createInstantInvite = null,
bool? kickMembers = null,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,13 @@ public OverwritePermissions(ulong allowValue, ulong denyValue)
DenyValue = denyValue;
}

/// <summary> Creates a new OverwritePermissions with the provided allow and deny packed values after converting to ulong. </summary>
public OverwritePermissions(string allowValue, string denyValue)
{
AllowValue = ulong.Parse(allowValue);
DenyValue = ulong.Parse(denyValue);
}

private OverwritePermissions(ulong allowValue, ulong denyValue,
PermValue? createInstantInvite = null,
PermValue? manageChannel = null,
Expand Down
4 changes: 0 additions & 4 deletions src/Discord.Net.Core/Entities/Users/IPresence.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,6 @@ namespace Discord
/// </summary>
public interface IPresence
{
/// <summary>
/// Gets the activity this user is currently doing.
/// </summary>
IActivity Activity { get; }
/// <summary>
/// Gets the current status of this user.
/// </summary>
Expand Down
11 changes: 11 additions & 0 deletions src/Discord.Net.Core/GatewayIntents.cs
Original file line number Diff line number Diff line change
Expand Up @@ -39,5 +39,16 @@ public enum GatewayIntents
DirectMessageReactions = 1 << 13,
/// <summary> This intent includes TYPING_START </summary>
DirectMessageTyping = 1 << 14,
/// <summary>
/// This intent includes all but <see cref="GuildMembers"/> and <see cref="GuildMembers"/>
/// that are privileged must be enabled for the application.
/// </summary>
AllUnprivileged = Guilds | GuildBans | GuildEmojis | GuildIntegrations | GuildWebhooks | GuildInvites |
GuildVoiceStates | GuildMessages | GuildMessageReactions | GuildMessageTyping | DirectMessages |
DirectMessageReactions | DirectMessageTyping,
/// <summary>
/// This intent includes all of them, including privileged ones.
/// </summary>
All = AllUnprivileged | GuildMembers | GuildPresences
}
}
18 changes: 0 additions & 18 deletions src/Discord.Net.Core/RateLimitPrecision.cs

This file was deleted.

4 changes: 0 additions & 4 deletions src/Discord.Net.Rest/API/Common/Guild.cs
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,6 @@ internal class Guild
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")]
Expand Down
13 changes: 0 additions & 13 deletions src/Discord.Net.Rest/API/Common/GuildEmbed.cs

This file was deleted.

4 changes: 2 additions & 2 deletions src/Discord.Net.Rest/API/Common/Overwrite.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@ internal class Overwrite
[JsonProperty("type")]
public PermissionTarget TargetType { get; set; }
[JsonProperty("deny"), Int53]
public ulong Deny { get; set; }
public string Deny { get; set; }
[JsonProperty("allow"), Int53]
public ulong Allow { get; set; }
public string Allow { get; set; }
}
}
2 changes: 0 additions & 2 deletions src/Discord.Net.Rest/API/Common/Presence.cs
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,6 @@ internal class Presence
public Optional<ulong> GuildId { get; set; }
[JsonProperty("status")]
public UserStatus Status { get; set; }
[JsonProperty("game")]
public Game Game { get; set; }

[JsonProperty("roles")]
public Optional<ulong[]> Roles { get; set; }
Expand Down
2 changes: 1 addition & 1 deletion src/Discord.Net.Rest/API/Common/Role.cs
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ internal class Role
[JsonProperty("position")]
public int Position { get; set; }
[JsonProperty("permissions"), Int53]
public ulong Permissions { get; set; }
public string Permissions { get; set; }
[JsonProperty("managed")]
public bool Managed { get; set; }
[JsonProperty("tags")]
Expand Down
4 changes: 2 additions & 2 deletions src/Discord.Net.Rest/API/Common/UserGuild.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#pragma warning disable CS1591
#pragma warning disable CS1591
using Newtonsoft.Json;

namespace Discord.API
Expand All @@ -14,6 +14,6 @@ internal class UserGuild
[JsonProperty("owner")]
public bool Owner { get; set; }
[JsonProperty("permissions"), Int53]
public ulong Permissions { get; set; }
public string Permissions { get; set; }
}
}
10 changes: 5 additions & 5 deletions src/Discord.Net.Rest/API/Rest/ModifyChannelPermissionsParams.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#pragma warning disable CS1591
#pragma warning disable CS1591
using Newtonsoft.Json;

namespace Discord.API.Rest
Expand All @@ -7,13 +7,13 @@ namespace Discord.API.Rest
internal class ModifyChannelPermissionsParams
{
[JsonProperty("type")]
public string Type { get; }
public int Type { get; }
[JsonProperty("allow")]
public ulong Allow { get; }
public string Allow { get; }
[JsonProperty("deny")]
public ulong Deny { get; }
public string Deny { get; }

public ModifyChannelPermissionsParams(string type, ulong allow, ulong deny)
public ModifyChannelPermissionsParams(int type, string allow, string deny)
{
Type = type;
Allow = allow;
Expand Down
4 changes: 2 additions & 2 deletions src/Discord.Net.Rest/API/Rest/ModifyGuildRoleParams.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#pragma warning disable CS1591
#pragma warning disable CS1591
using Newtonsoft.Json;

namespace Discord.API.Rest
Expand All @@ -9,7 +9,7 @@ internal class ModifyGuildRoleParams
[JsonProperty("name")]
public Optional<string> Name { get; set; }
[JsonProperty("permissions")]
public Optional<ulong> Permissions { get; set; }
public Optional<string> Permissions { get; set; }
[JsonProperty("color")]
public Optional<uint> Color { get; set; }
[JsonProperty("hoist")]
Expand Down
11 changes: 0 additions & 11 deletions src/Discord.Net.Rest/API/Rest/SuppressEmbedParams.cs

This file was deleted.

8 changes: 0 additions & 8 deletions src/Discord.Net.Rest/ClientHelper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -69,14 +69,6 @@ public static async Task<IReadOnlyCollection<RestConnection>> GetConnectionsAsyn
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)
{
Expand Down

0 comments on commit 06a64b7

Please sign in to comment.