Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Feature] Get current bot application information #2619

Merged
merged 3 commits into from
Mar 31, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions src/Discord.Net.Core/DiscordConfig.cs
Original file line number Diff line number Diff line change
Expand Up @@ -222,5 +222,15 @@ public class DiscordConfig
/// The maximum number of thread members that can be gotten per-batch.
/// </returns>
public const int MaxThreadMembersPerBatch = 100;

/// <summary>
/// Returns the max length of an application tag.
/// </summary>
public const int MaxApplicationTagLength = 20;

/// <summary>
/// Returns the max length of an application description.
/// </summary>
public const int MaxApplicationDescriptionLength = 400;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -36,13 +36,13 @@ public interface IApplication : ISnowflakeEntity
/// </summary>
string IconUrl { get; }
/// <summary>
/// Gets if the bot is public.
/// Gets if the bot is public. <see langword="null" /> if not set.
/// </summary>
bool IsBotPublic { get; }
bool? IsBotPublic { get; }
/// <summary>
/// Gets if the bot requires code grant.
/// Gets if the bot requires code grant. <see langword="null" /> if not set.
/// </summary>
bool BotRequiresCodeGrant { get; }
bool? BotRequiresCodeGrant { get; }
/// <summary>
/// Gets the team associated with this application if there is one.
/// </summary>
Expand Down Expand Up @@ -75,5 +75,24 @@ public interface IApplication : ISnowflakeEntity
/// </summary>
public string VerifyKey { get; }

/// <summary>
/// Gets the partial guild object of the application's developer's support server. <see langword="null" /> if not set.
/// </summary>
public PartialGuild Guild { get; }

/// <summary>
/// Gets the redirect uris configured for the application.
/// </summary>
public IReadOnlyCollection<string> RedirectUris { get;}

/// <summary>
/// Gets application's interactions endpoint url. <see langword="null" /> if not set.
/// </summary>
public string InteractionsEndpointUrl { get; }

/// <summary>
/// Gets the approximate count of the guild the application was added to. <see langword="null" /> if not returned.
/// </summary>
public int? ApproximateGuildCount { get; }
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
namespace Discord;

/// <summary>
/// Represents properties used to modify current application's bot.
/// </summary>
public class ModifyApplicationProperties
{
/// <summary>
/// Gets or sets the http interactions endpoint configured for the application.
/// </summary>
public Optional<string> InteractionsEndpointUrl { get; set; }

/// <summary>
/// Gets or sets the role connections verification endpoint configured for the application.
/// </summary>
public Optional<string> RoleConnectionsEndpointUrl { get; set; }

/// <summary>
/// Gets or sets the description of the application.
/// </summary>
public Optional<string> Description { get; set; }

/// <summary>
/// Gets or sets application's tags
/// </summary>
public Optional<string[]> Tags { get; set; }

/// <summary>
/// Gets or sets the icon of the application.
/// </summary>
public Optional<Image?> Icon { get; set; }
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,37 +2,43 @@

namespace Discord;

public class InviteGuild : ISnowflakeEntity
/// <summary>
/// Represents a partial guild object.
/// </summary>
/// <remarks>
/// Most of the fields can have <see langword="null" /> value.
/// </remarks>
public class PartialGuild : ISnowflakeEntity
{
/// <inheritdoc />
public DateTimeOffset CreatedAt => SnowflakeUtils.FromSnowflake(Id);

/// <inheritdoc/>
public ulong Id { get; private set; }
public ulong Id { get; internal set; }

/// <summary>
/// Gets the name of this guild.
/// </summary>
/// <returns>
/// A string containing the name of this guild.
/// </returns>
public string Name { get; private set; }
public string Name { get; internal set; }

/// <summary>
/// Gets the description for the guild.
/// </summary>
/// <returns>
/// The description for the guild; <see langword="null" /> if none is set.
/// </returns>
public string Description { get; private set; }
public string Description { get; internal set; }

/// <summary>
/// Gets the ID of this guild's splash image.
/// </summary>
/// <returns>
/// An identifier for the splash image; <see langword="null" /> if none is set.
/// </returns>
public string SplashId { get; private set; }
public string SplashId { get; internal set; }

/// <summary>
/// Gets the URL of this guild's splash image.
Expand All @@ -48,7 +54,7 @@ public class InviteGuild : ISnowflakeEntity
/// <returns>
/// An identifier for the banner image; <see langword="null" /> if none is set.
/// </returns>
public string BannerId { get; private set; }
public string BannerId { get; internal set; }

/// <summary>
/// Gets the URL of this guild's banner image.
Expand All @@ -64,15 +70,15 @@ public class InviteGuild : ISnowflakeEntity
/// <returns>
/// A flags enum containing all the features for the guild.
/// </returns>
public GuildFeatures Features { get; private set; }
public GuildFeatures Features { get; internal set; }

/// <summary>
/// Gets the ID of this guild's icon.
/// </summary>
/// <returns>
/// An identifier for the splash image; <see langword="null" /> if none is set.
/// </returns>
public string IconId { get; private set; }
public string IconId { get; internal set; }

/// <summary>
/// Gets the URL of this guild's icon.
Expand All @@ -87,17 +93,17 @@ public class InviteGuild : ISnowflakeEntity
/// Gets the level of requirements a user must fulfill before being allowed to post messages in this guild.
/// </summary>
/// <returns>
/// The level of requirements.
/// The level of requirements. <see langword="null" /> if none is was returned.
/// </returns>
public VerificationLevel VerificationLevel { get; private set; }
public VerificationLevel? VerificationLevel { get; internal set; }

/// <summary>
/// Gets the code for this guild's vanity invite URL.
/// </summary>
/// <returns>
/// A string containing the vanity invite code for this guild; <see langword="null" /> if none is set.
/// </returns>
public string VanityURLCode { get; private set; }
public string VanityURLCode { get; internal set; }

/// <summary>
/// Gets the number of premium subscribers of this guild.
Expand All @@ -106,51 +112,36 @@ public class InviteGuild : ISnowflakeEntity
/// This is the number of users who have boosted this guild.
/// </remarks>
/// <returns>
/// The number of premium subscribers of this guild;
/// The number of premium subscribers of this guild; <see langword="null" /> if none was returned.
/// </returns>
public int PremiumSubscriptionCount { get; private set; }
public int? PremiumSubscriptionCount { get; internal set; }

/// <summary>
/// Gets the NSFW level of this guild.
/// </summary>
/// <returns>
/// The NSFW level of this guild.
/// The NSFW level of this guild. <see langword="null" /> if none was returned.
/// </returns>
public NsfwLevel NsfwLevel { get; private set; }
public NsfwLevel? NsfwLevel { get; internal set; }

/// <summary>
/// Gets the Welcome Screen of this guild
/// </summary>
/// <returns>
/// The welcome screen of this guild. <see langword="null" /> if none is set.
/// </returns>
public WelcomeScreen WelcomeScreen { get; private set; }

internal InviteGuild(
ulong id,
string name,
string description,
string splashId,
string bannerId,
GuildFeatures features,
string iconId,
VerificationLevel verificationLevel,
string vanityURLCode,
int premiumSubscriptionCount,
NsfwLevel nsfwLevel,
WelcomeScreen welcomeScreen)
{
Id = id;
Name = name;
Description = description;
SplashId = splashId;
BannerId = bannerId;
Features = features;
IconId = iconId;
VerificationLevel = verificationLevel;
VanityURLCode = vanityURLCode;
PremiumSubscriptionCount = premiumSubscriptionCount;
NsfwLevel = nsfwLevel;
WelcomeScreen = welcomeScreen;
}
public WelcomeScreen WelcomeScreen { get; internal set; }

/// <summary>
/// Gets the approximate member count in the guild. <see langword="null" /> if none was returned.
/// </summary>
public int? ApproximateMemberCount { get; internal set; }

/// <summary>
/// Gets the approximate presence count in the guild.<see langword="null" /> if none was returned.
/// </summary>
public int? ApproximatePresenceCount { get; internal set; }

internal PartialGuild() { }

}
26 changes: 22 additions & 4 deletions src/Discord.Net.Rest/API/Common/Application.cs
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,12 @@ internal class Application
public ulong Id { get; set; }
[JsonProperty("icon")]
public string Icon { get; set; }

[JsonProperty("bot_public")]
public bool IsBotPublic { get; set; }
public Optional<bool> IsBotPublic { get; set; }
[JsonProperty("bot_require_code_grant")]
public bool BotRequiresCodeGrant { get; set; }
public Optional<bool> BotRequiresCodeGrant { get; set; }

[JsonProperty("install_params")]
public Optional<InstallParams> InstallParams { get; set; }
[JsonProperty("team")]
Expand All @@ -28,8 +30,20 @@ internal class Application
public Optional<User> Owner { get; set; }
[JsonProperty("tags")]
public Optional<string[]> Tags { get; set; }

[JsonProperty("verify_key")]
public string VerifyKey { get; set; }

[JsonProperty("approximate_guild_count")]
public Optional<int> ApproximateGuildCount { get; set; }

[JsonProperty("guild")]
public Optional<PartialGuild> PartialGuild { get; set; }

/// Urls
[JsonProperty("terms_of_service_url")]
public string TermsOfService { get; set; }

[JsonProperty("privacy_policy_url")]
public string PrivacyPolicy { get; set; }

Expand All @@ -39,7 +53,11 @@ internal class Application
[JsonProperty("role_connections_verification_url")]
public Optional<string> RoleConnectionsUrl { get; set; }

[JsonProperty("verify_key")]
public string VerifyKey { get; set; }
[JsonProperty("interactions_endpoint_url")]
public Optional<string> InteractionsEndpointUrl { get; set; }

[JsonProperty("redirect_uris")]
public Optional<string[]> RedirectUris { get; set; }

}
}
2 changes: 1 addition & 1 deletion src/Discord.Net.Rest/API/Common/Invite.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ internal class Invite
public string Code { get; set; }

[JsonProperty("guild")]
public Optional<InviteGuild> Guild { get; set; }
public Optional<PartialGuild> Guild { get; set; }

[JsonProperty("channel")]
public InviteChannel Channel { get; set; }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

namespace Discord.API
{
internal class InviteGuild
internal class PartialGuild
{
[JsonProperty("id")]
public ulong Id { get; set; }
Expand All @@ -23,10 +23,10 @@ internal class InviteGuild
public Optional<string> IconHash { get; set; }

[JsonProperty("features")]
public GuildFeatures Features { get; set; }
public Optional<GuildFeatures> Features { get; set; }

[JsonProperty("verification_level")]
public VerificationLevel VerificationLevel { get; set; }
public Optional<VerificationLevel> VerificationLevel { get; set; }

[JsonProperty("vanity_url_code")]
public Optional<string> VanityUrlCode { get; set; }
Expand All @@ -38,9 +38,16 @@ internal class InviteGuild
public Optional<bool?> Nsfw { get; set; }

[JsonProperty("nsfw_level")]
public NsfwLevel NsfwLevel { get; set; }
public Optional<NsfwLevel> NsfwLevel { get; set; }

[JsonProperty("welcome_screen")]
public Optional<WelcomeScreen> WelcomeScreen { get; set; }

[JsonProperty("approximate_member_count")]
public Optional<int> ApproximateMemberCount { get; set; }

[JsonProperty("approximate_presence_count")]
public Optional<int> ApproximatePresenceCount { get; set; }

}
}
21 changes: 21 additions & 0 deletions src/Discord.Net.Rest/API/Rest/ModifyCurrentApplicationBotParams.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
using Newtonsoft.Json;

namespace Discord.API.Rest;

internal class ModifyCurrentApplicationBotParams
{
[JsonProperty("interactions_endpoint_url")]
public Optional<string> InteractionsEndpointUrl { get; set; }

[JsonProperty("role_connections_verification_url")]
public Optional<string> RoleConnectionsEndpointUrl { get; set; }

[JsonProperty("description")]
public Optional<string> Description { get; set; }

[JsonProperty("tags")]
public Optional<string[]> Tags { get; set; }

[JsonProperty("icon")]
public Optional<Image?> Icon { get; set; }
}
Loading