A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://github.com/discordjs/discord.js/commit/c0eae344c2ed43fa67be9fda8e3d3e479693d2d1 below:

backport entrypoint command (#10908) · discordjs/discord.js@c0eae34 · GitHub

File tree Expand file treeCollapse file tree 13 files changed

+220

-21

lines changed

Filter options

Expand file treeCollapse file tree 13 files changed

+220

-21

lines changed Original file line number Diff line number Diff line change

@@ -9,6 +9,7 @@ const ChatInputCommandInteraction = require('../../structures/ChatInputCommandIn

9 9

const MentionableSelectMenuInteraction = require('../../structures/MentionableSelectMenuInteraction');

10 10

const MessageContextMenuCommandInteraction = require('../../structures/MessageContextMenuCommandInteraction');

11 11

const ModalSubmitInteraction = require('../../structures/ModalSubmitInteraction');

12 +

const PrimaryEntryPointCommandInteraction = require('../../structures/PrimaryEntryPointCommandInteraction');

12 13

const RoleSelectMenuInteraction = require('../../structures/RoleSelectMenuInteraction');

13 14

const StringSelectMenuInteraction = require('../../structures/StringSelectMenuInteraction');

14 15

const UserContextMenuCommandInteraction = require('../../structures/UserContextMenuCommandInteraction');

@@ -38,6 +39,9 @@ class InteractionCreateAction extends Action {

38 39

if (channel && !channel.isTextBased()) return;

39 40

InteractionClass = MessageContextMenuCommandInteraction;

40 41

break;

42 +

case ApplicationCommandType.PrimaryEntryPoint:

43 +

InteractionClass = PrimaryEntryPointCommandInteraction;

44 +

break;

41 45

default:

42 46

client.emit(

43 47

Events.Debug,

Original file line number Diff line number Diff line change

@@ -180,6 +180,7 @@ exports.PartialGroupDMChannel = require('./structures/PartialGroupDMChannel');

180 180

exports.PermissionOverwrites = require('./structures/PermissionOverwrites');

181 181

exports.Poll = require('./structures/Poll').Poll;

182 182

exports.PollAnswer = require('./structures/PollAnswer').PollAnswer;

183 +

exports.PrimaryEntryPointCommandInteraction = require('./structures/PrimaryEntryPointCommandInteraction');

183 184

exports.Presence = require('./structures/Presence').Presence;

184 185

exports.ReactionCollector = require('./structures/ReactionCollector');

185 186

exports.ReactionEmoji = require('./structures/ReactionEmoji');

Original file line number Diff line number Diff line change

@@ -261,6 +261,7 @@ class ApplicationCommandManager extends CachedManager {

261 261

dm_permission: command.dmPermission ?? command.dm_permission,

262 262

integration_types: command.integrationTypes ?? command.integration_types,

263 263

contexts: command.contexts,

264 +

handler: command.handler,

264 265

};

265 266

}

266 267

}

Original file line number Diff line number Diff line change

@@ -174,6 +174,18 @@ class ApplicationCommand extends Base {

174 174

this.contexts ??= null;

175 175

}

176 176 177 +

if ('handler' in data) {

178 +

/**

179 +

* Determines whether the interaction is handled by the app's interactions handler or by Discord.

180 +

* <info>Only available for {@link ApplicationCommandType.PrimaryEntryPoint} commands on

181 +

* applications with the {@link ApplicationFlags.Embedded} flag (i.e, those that have an Activity)</info>

182 +

* @type {?EntryPointCommandHandlerType}

183 +

*/

184 +

this.handler = data.handler;

185 +

} else {

186 +

this.handler ??= null;

187 +

}

188 + 177 189

if ('version' in data) {

178 190

/**

179 191

* Autoincrementing version identifier updated during substantial record changes

@@ -216,15 +228,20 @@ class ApplicationCommand extends Base {

216 228

* @property {string} name The name of the command, must be in all lowercase if type is

217 229

* {@link ApplicationCommandType.ChatInput}

218 230

* @property {Object<Locale, string>} [nameLocalizations] The localizations for the command name

219 -

* @property {string} description The description of the command, if type is {@link ApplicationCommandType.ChatInput}

231 +

* @property {string} description The description of the command,

232 +

* if type is {@link ApplicationCommandType.ChatInput} or {@link ApplicationCommandType.PrimaryEntryPoint}

220 233

* @property {boolean} [nsfw] Whether the command is age-restricted

221 234

* @property {Object<Locale, string>} [descriptionLocalizations] The localizations for the command description,

222 -

* if type is {@link ApplicationCommandType.ChatInput}

235 +

* if type is {@link ApplicationCommandType.ChatInput} or {@link ApplicationCommandType.PrimaryEntryPoint}

223 236

* @property {ApplicationCommandType} [type=ApplicationCommandType.ChatInput] The type of the command

224 237

* @property {ApplicationCommandOptionData[]} [options] Options for the command

225 238

* @property {?PermissionResolvable} [defaultMemberPermissions] The bitfield used to determine the default permissions

226 239

* a member needs in order to run the command

227 240

* @property {boolean} [dmPermission] Whether the command is enabled in DMs

241 +

* @property {ApplicationIntegrationType[]} [integrationTypes] Installation contexts where the command is available

242 +

* @property {InteractionContextType[]} [contexts] Interaction contexts where the command can be used

243 +

* @property {EntryPointCommandHandlerType} [handler] Whether the interaction is handled by the app's

244 +

* interactions handler or by Discord.

228 245

*/

229 246 230 247

/**

@@ -419,7 +436,8 @@ class ApplicationCommand extends Base {

419 436

this.descriptionLocalizations ?? {},

420 437

) ||

421 438

!isEqual(command.integrationTypes ?? command.integration_types ?? [], this.integrationTypes ?? []) ||

422 -

!isEqual(command.contexts ?? [], this.contexts ?? [])

439 +

!isEqual(command.contexts ?? [], this.contexts ?? []) ||

440 +

('handler' in command && command.handler !== this.handler)

423 441

) {

424 442

return false;

425 443

}

Original file line number Diff line number Diff line change

@@ -225,6 +225,16 @@ class BaseInteraction extends Base {

225 225

);

226 226

}

227 227 228 +

/**

229 +

* Indicates whether this interaction is a {@link PrimaryEntryPointCommandInteraction}

230 +

* @returns {boolean}

231 +

*/

232 +

isPrimaryEntryPointCommand() {

233 +

return (

234 +

this.type === InteractionType.ApplicationCommand && this.commandType === ApplicationCommandType.PrimaryEntryPoint

235 +

);

236 +

}

237 + 228 238

/**

229 239

* Indicates whether this interaction is a {@link MessageComponentInteraction}

230 240

* @returns {boolean}

Original file line number Diff line number Diff line change

@@ -152,6 +152,7 @@ class CommandInteraction extends BaseInteraction {

152 152

editReply() {}

153 153

deleteReply() {}

154 154

followUp() {}

155 +

launchActivity() {}

155 156

showModal() {}

156 157

sendPremiumRequired() {}

157 158

awaitModalSubmit() {}

Original file line number Diff line number Diff line change

@@ -97,6 +97,7 @@ class MessageComponentInteraction extends BaseInteraction {

97 97

followUp() {}

98 98

deferUpdate() {}

99 99

update() {}

100 +

launchActivity() {}

100 101

showModal() {}

101 102

sendPremiumRequired() {}

102 103

awaitModalSubmit() {}

Original file line number Diff line number Diff line change

@@ -119,6 +119,7 @@ class ModalSubmitInteraction extends BaseInteraction {

119 119

deferUpdate() {}

120 120

update() {}

121 121

sendPremiumRequired() {}

122 +

launchActivity() {}

122 123

}

123 124 124 125

InteractionResponses.applyToClass(ModalSubmitInteraction, 'showModal');

Original file line number Diff line number Diff line change

@@ -0,0 +1,11 @@

1 +

'use strict';

2 + 3 +

const CommandInteraction = require('./CommandInteraction.js');

4 + 5 +

/**

6 +

* Represents a primary entry point command interaction.

7 +

* @extends {CommandInteraction}

8 +

*/

9 +

class PrimaryEntryPointCommandInteraction extends CommandInteraction {}

10 + 11 +

module.exports = PrimaryEntryPointCommandInteraction;

Original file line number Diff line number Diff line change

@@ -69,6 +69,12 @@ class InteractionResponses {

69 69

* <warn>This option is deprecated. Use `withResponse` or fetch the response instead.</warn>

70 70

*/

71 71 72 +

/**

73 +

* Options for launching activity in response to a {@link BaseInteraction}

74 +

* @typedef {Object} LaunchActivityOptions

75 +

* @property {boolean} [withResponse] Whether to return an {@link InteractionCallbackResponse} as the response

76 +

*/

77 + 72 78

/**

73 79

* Options for showing a modal in response to a {@link BaseInteraction}

74 80

* @typedef {Object} ShowModalOptions

@@ -370,6 +376,25 @@ class InteractionResponses {

370 376

: new InteractionResponse(this, this.message.interactionMetadata?.id);

371 377

}

372 378 379 +

/**

380 +

* Launches this application's activity, if enabled

381 +

* @param {LaunchActivityOptions} [options={}] Options for launching the activity

382 +

* @returns {Promise<InteractionCallbackResponse|undefined>}

383 +

*/

384 +

async launchActivity({ withResponse } = {}) {

385 +

if (this.deferred || this.replied) throw new DiscordjsError(ErrorCodes.InteractionAlreadyReplied);

386 +

const response = await this.client.rest.post(Routes.interactionCallback(this.id, this.token), {

387 +

query: makeURLSearchParams({ with_response: withResponse ?? false }),

388 +

body: {

389 +

type: InteractionResponseType.LaunchActivity,

390 +

},

391 +

auth: false,

392 +

});

393 +

this.replied = true;

394 + 395 +

return withResponse ? new InteractionCallbackResponse(this.client, response) : undefined;

396 +

}

397 + 373 398

/**

374 399

* Shows a modal component

375 400

* @param {ModalBuilder|ModalComponentData|APIModalInteractionResponseCallbackData} modal The modal to show

@@ -450,6 +475,7 @@ class InteractionResponses {

450 475

'followUp',

451 476

'deferUpdate',

452 477

'update',

478 +

'launchActivity',

453 479

'showModal',

454 480

'sendPremiumRequired',

455 481

'awaitModalSubmit',

You can’t perform that action at this time.


RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4