[Feature] Get current bot application information (#2619)

* initial commit

* Add support for modifying current bot's app
This commit is contained in:
Misha133
2023-03-31 14:36:26 +03:00
committed by GitHub
parent 898ee56557
commit 9ef5a768e0
16 changed files with 281 additions and 84 deletions

View File

@@ -17,6 +17,34 @@ namespace Discord.Rest
return RestApplication.Create(client, model);
}
public static async Task<RestApplication> GetCurrentBotApplicationAsync(BaseDiscordClient client, RequestOptions options)
{
var model = await client.ApiClient.GetCurrentBotApplicationAsync(options).ConfigureAwait(false);
return RestApplication.Create(client, model);
}
public static async Task<API.Application> ModifyCurrentBotApplicationAsync(BaseDiscordClient client, Action<ModifyApplicationProperties> func, RequestOptions options)
{
var args = new ModifyApplicationProperties();
func(args);
if(args.Tags.IsSpecified)
foreach (var tag in args.Tags.Value)
Preconditions.AtMost(tag.Length, DiscordConfig.MaxApplicationTagLength, nameof(args.Tags), $"An application tag must have length less or equal to {DiscordConfig.MaxApplicationTagLength}");
if(args.Description.IsSpecified)
Preconditions.AtMost(args.Description.Value.Length, DiscordConfig.MaxApplicationDescriptionLength, nameof(args.Description), $"An application description tag mus have length less or equal to {DiscordConfig.MaxApplicationDescriptionLength}");
return await client.ApiClient.ModifyCurrentBotApplicationAsync(new()
{
Description = args.Description,
Tags = args.Tags,
Icon = args.Icon.IsSpecified ? args.Icon.Value?.ToModel() : Optional<API.Image?>.Unspecified,
InteractionsEndpointUrl = args.InteractionsEndpointUrl,
RoleConnectionsEndpointUrl = args.RoleConnectionsEndpointUrl,
}, options);
}
public static async Task<RestChannel> GetChannelAsync(BaseDiscordClient client,
ulong id, RequestOptions options)
{