Skip to content

Commit

Permalink
refactor: requested changes
Browse files Browse the repository at this point in the history
  • Loading branch information
almeidx committed Oct 23, 2023
1 parent eb6e1e7 commit 61e3f22
Show file tree
Hide file tree
Showing 7 changed files with 13 additions and 11 deletions.
2 changes: 1 addition & 1 deletion packages/discord.js/src/structures/CommandInteraction.js
Original file line number Diff line number Diff line change
Expand Up @@ -210,7 +210,7 @@ class CommandInteraction extends BaseInteraction {
deleteReply() {}
followUp() {}
showModal() {}
sendPremiumUpgradeButton() {}
sendPremiumRequired() {}
awaitModalSubmit() {}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ class MessageComponentInteraction extends BaseInteraction {
deferUpdate() {}
update() {}
showModal() {}
sendPremiumUpgradeButton() {}
sendPremiumRequired() {}
awaitModalSubmit() {}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ class ModalSubmitInteraction extends BaseInteraction {
followUp() {}
deferUpdate() {}
update() {}
sendPremiumUpgradeButton() {}
sendPremiumRequired() {}
}

InteractionResponses.applyToClass(ModalSubmitInteraction, 'showModal');
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -262,10 +262,10 @@ class InteractionResponses {

/**
* Responds to the interaction with an upgrade button.
* <warn>Only available for applications with monetization enabled.</warn>
* <info>Only available for applications with monetization enabled.</info>
* @returns {Promise<void>}
*/
async sendPremiumUpgradeButton() {
async sendPremiumRequired() {
if (this.deferred || this.replied) throw new DiscordjsError(ErrorCodes.InteractionAlreadyReplied);
await this.client.rest.post(Routes.interactionCallback(this.id, this.token), {
body: {
Expand Down Expand Up @@ -319,7 +319,7 @@ class InteractionResponses {
'deferUpdate',
'update',
'showModal',
'sendPremiumUpgradeButton',
'sendPremiumRequired',
'awaitModalSubmit',
];

Expand Down
4 changes: 3 additions & 1 deletion packages/discord.js/test/monetization.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,9 @@ client.on(Events.InteractionCreate, async interaction => {
console.log('interaction.entitlements', interaction.entitlements);

if (interaction.commandName === 'test') {
await interaction.sendPremiumUpgradeButton();
await interaction.deferReply();

await interaction.sendPremiumRequired();
}
});

Expand Down
6 changes: 3 additions & 3 deletions packages/discord.js/typings/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -585,7 +585,7 @@ export abstract class CommandInteraction<Cached extends CacheType = CacheType> e
| ModalComponentData
| APIModalInteractionResponseCallbackData,
): Promise<void>;
public sendPremiumUpgradeButton(): Promise<void>;
public sendPremiumRequired(): Promise<void>;
public awaitModalSubmit(
options: AwaitModalSubmitOptions<ModalSubmitInteraction>,
): Promise<ModalSubmitInteraction<Cached>>;
Expand Down Expand Up @@ -2202,7 +2202,7 @@ export class MessageComponentInteraction<Cached extends CacheType = CacheType> e
| ModalComponentData
| APIModalInteractionResponseCallbackData,
): Promise<void>;
public sendPremiumUpgradeButton(): Promise<void>;
public sendPremiumRequired(): Promise<void>;
public awaitModalSubmit(
options: AwaitModalSubmitOptions<ModalSubmitInteraction>,
): Promise<ModalSubmitInteraction<Cached>>;
Expand Down Expand Up @@ -2386,7 +2386,7 @@ export class ModalSubmitInteraction<Cached extends CacheType = CacheType> extend
options: InteractionDeferUpdateOptions & { fetchReply: true },
): Promise<Message<BooleanCache<Cached>>>;
public deferUpdate(options?: InteractionDeferUpdateOptions): Promise<InteractionResponse<BooleanCache<Cached>>>;
public sendPremiumUpgradeButton(): Promise<void>;
public sendPremiumRequired(): Promise<void>;
public inGuild(): this is ModalSubmitInteraction<'raw' | 'cached'>;
public inCachedGuild(): this is ModalSubmitInteraction<'cached'>;
public inRawGuild(): this is ModalSubmitInteraction<'raw'>;
Expand Down
2 changes: 1 addition & 1 deletion packages/discord.js/typings/index.test-d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2438,7 +2438,7 @@ declare const sku: SKU;
expectType<Collection<Snowflake, Entitlement>>(interaction.entitlements);

if (interaction.isRepliable()) {
await interaction.sendPremiumUpgradeButton();
await interaction.sendPremiumRequired();
}
});
}

0 comments on commit 61e3f22

Please sign in to comment.