Skip to content

Commit

Permalink
feat: allow updating the current OAuth application (#118)
Browse files Browse the repository at this point in the history
* feat: allow updating the current OAuth application

* types: fix linting errors

* Resolve the status quo for OAuthApplicationInfo
  • Loading branch information
TTtie committed Dec 11, 2023
1 parent ea03f84 commit e0f6b2e
Show file tree
Hide file tree
Showing 2 changed files with 39 additions and 0 deletions.
30 changes: 30 additions & 0 deletions index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1167,6 +1167,17 @@ declare namespace Dysnomia {
code: string | null;
uses: number;
}
interface PartialGuild {
approximate_member_count?: number;
approximate_presence_count?: number;
description?: string | null;
discovery_splash?: string | null;
features?: GuildFeatures[];
icon?: string | null;
id: string;
name?: string;
splash?: string | null;
}
interface IntegrationApplication {
bot?: User;
description: string;
Expand Down Expand Up @@ -1831,20 +1842,25 @@ declare namespace Dysnomia {
[key: string]: unknown;
}
interface OAuthApplicationInfo {
approximate_guild_count?: number;
bot?: PartialUser;
bot_public: boolean;
bot_require_code_grant: boolean;
cover_image?: string;
custom_install_url?: string;
description: string;
flags?: number;
guild_id?: string;
guild?: PartialGuild;
icon: string | null;
id: string;
install_params?: OAuthInstallParams;
interactions_endpoint_url?: string;
name: string;
owner?: PartialUser;
primary_sku_id?: string;
privacy_policy_url?: string;
redirect_uris?: string[];
role_connections_verification_url?: string;
rpc_origins?: string[];
slug?: string;
Expand All @@ -1855,6 +1871,19 @@ declare namespace Dysnomia {
terms_of_service_url?: string;
verify_key: string;
}

type EditApplicationOptions = Partial<Pick<OAuthApplicationInfo, |
"cover_image" |
"custom_install_url" |
"description" |
"flags" |
"icon" |
"install_params" |
"interactions_endpoint_url" |
"role_connections_verification_url" |
"tags"
>>;

interface OAuthTeamInfo {
icon: string | null;
id: string;
Expand Down Expand Up @@ -2756,6 +2785,7 @@ declare namespace Dysnomia {
deleteWebhookMessage(webhookID: string, token: string, messageID: string): Promise<void>;
disconnect(options: { reconnect?: boolean | "auto" }): void;
editAFK(afk: boolean): void;
editApplication(options: EditApplicationOptions): Promise<OAuthApplicationInfo>;
editAutoModerationRule(guildID: string, ruleID: string, options: EditAutoModerationRuleOptions): Promise<AutoModerationRule>;
editChannel(
channelID: string,
Expand Down
9 changes: 9 additions & 0 deletions lib/Client.js
Original file line number Diff line number Diff line change
Expand Up @@ -1218,6 +1218,15 @@ class Client extends EventEmitter {
});
}

/**
* Edits the application associated with this bot user
* @param {Object} options The new application options. See [Discord's documentation](https://discord.com/developers/docs/resources/application#edit-current-application-json-params) for a list of them
* @returns {Promise<Object>}
*/
editApplication(options) {
return this.requestHandler.request("PATCH", Endpoints.APPLICATION, options);
}

/**
* Edit an existing auto moderation rule
* @arg {String} guildID the ID of the guild to edit the rule in
Expand Down

0 comments on commit e0f6b2e

Please sign in to comment.