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
interactions #5106
interactions #5106
Conversation
c942f86
to
5be3216
Compare
I feel like this is missing a couple of stuff. Such as editing commands, editing the message(s), and sending follow up messages. Side note: I was thinking, perhaps |
options may support repetition in the future, so a map would cause issues. note that this is only intended to accurately expose the capability of the api, for higher level interaction you should use something like commando. |
This will likely need a InteractionMessageOptions as Interactions don't take all the same options as normal messages (including the additional ephemeral flag) |
|
||
/** | ||
* Emitted when an interaction is created. | ||
* @event Client#interactionCreate |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
there should also be a docstring to indicate this event is emitted on InteractionClient
or perhaps just emit the event on the InteractionClient
only
✏ note: documentation has been finalized (at least for the beta period) at https://discord.com/developers/docs/interactions/slash-commands |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this.client.api.applications('@me') should be this.client.api.applications(this.client.id) Discord expects a snowflake.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sry by mistake, pls delete this.
This will need changes to APIRouter to account for all additional type of major id: webhooks |
637531b
to
1de89f0
Compare
So we would make two calls to .reply() then? One as . |
you just call reply normally. the library automatically handles whether it should be deferred or not, and the message utils handle the ephemeral option. |
typings/index.d.ts
Outdated
public readonly applicationID: Snowflake; | ||
public readonly channel: TextChannel | NewsChannel | DMChannel | null; | ||
public readonly channelID: Snowflake | null; | ||
public readonly guild: Guild | null; | ||
public readonly guildID: Snowflake | null; | ||
public readonly id: Snowflake; | ||
public readonly member: GuildMember | null; | ||
public readonly token: string; | ||
public readonly type: InteractionType; | ||
public readonly user: User | null; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
public readonly applicationID: Snowflake; | |
public readonly channel: TextChannel | NewsChannel | DMChannel | null; | |
public readonly channelID: Snowflake | null; | |
public readonly guild: Guild | null; | |
public readonly guildID: Snowflake | null; | |
public readonly id: Snowflake; | |
public readonly member: GuildMember | null; | |
public readonly token: string; | |
public readonly type: InteractionType; | |
public readonly user: User | null; | |
public applicationID: Snowflake; | |
public channel: TextChannel | NewsChannel | DMChannel | null; | |
public channelID: Snowflake | null; | |
public guild: Guild | null; | |
public guildID: Snowflake | null; | |
public id: Snowflake; | |
public member: GuildMember | null; | |
public token: string; | |
public type: InteractionType; | |
public user: User | null; |
typings/index.d.ts
Outdated
public readonly commandID: Snowflake; | ||
public readonly commandName: string; | ||
public readonly createdAt: Date; | ||
public readonly createdTimestamp: number; | ||
public readonly options: object; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
public readonly commandID: Snowflake; | |
public readonly commandName: string; | |
public readonly createdAt: Date; | |
public readonly createdTimestamp: number; | |
public readonly options: object; | |
public commandID: Snowflake; | |
public commandName: string; | |
public readonly createdAt: Date; | |
public readonly createdTimestamp: number; | |
public options: object; |
I see the automatic handling of deferred and how ephemeral is handled, I see no way to defer with ephemeral, as it must be set in the original callback. Side note: the deferred message will show the user the interaction has timed out with the current handling, even after a reply, if the timeout for deferred has been reached. |
Pulled the PR to mess about, may want to modify the readme to show the new parameter requirements for Client ( |
I think its because of #4879. |
#5323 Takes care of the README change. |
* @param {(StringResolvable | APIMessage)?} content The content for the message. | ||
* @param {(MessageOptions | MessageAdditions)?} options The options to provide. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
* @param {(StringResolvable | APIMessage)?} content The content for the message. | |
* @param {(MessageOptions | MessageAdditions)?} options The options to provide. | |
* @param {StringResolvable|APIMessage} content The content for the message. | |
* @param {MessageOptions|MessageAdditions} [options] The options to provide. |
src/structures/CommandInteraction.js
Outdated
* @type {Object} | ||
* @readonly | ||
*/ | ||
this.options = data.data.options.map(map); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this.options = data.data.options.map(map); | |
this.options = data.data.options?.map(map); |
options
can be undefined when a command doesn't have parameters (or none are given when executing the command)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this.options = data.data.options.map(map); | |
this.options = data.data.options?.map(map) ?? []; |
Wouldn't it be better if options
was an empty array, instead of just being undefined?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
client.interactionClient.createCommand()
is broken atm, this should fix it
@@ -12,6 +12,8 @@ module.exports = (client, { d: data }, shard) => { | |||
client.users.cache.set(clientUser.id, clientUser); | |||
} | |||
|
|||
client.applicationID = data.application.id; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
client.applicationID = data.application.id; | |
client.applicationID = data.application.id; | |
client.interactionClient.applicationID = data.application.id; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
client.applicationID = data.application.id; | |
client.applicationID = client.interactionClient.applicationID = data.application.id; |
src/client/InteractionClient.js
Outdated
* @returns {ApplicationCommand} The created command. | ||
*/ | ||
async createCommand(command, guildID) { | ||
let path = this.client.api.applications(this.clientID); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
let path = this.client.api.applications(this.clientID); | |
let path = this.client.api.applications(this.applicationID); |
src/structures/ApplicationCommand.js
Outdated
|
||
/** | ||
* Edit this command. | ||
* @param {ApplicationCommandOptions} data The data to update the command with |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I feel like this should be a separate type since all of the endpoint parameters are optional yet the type requires them + others that are thrown away
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
alternatively use Partial<ApplicationCommandOptions>
as was going to be documented by #5144 but document it here instead
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
devsnek#13 creates a new typedef for that
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
the typedef created there still does not respect edit data being optional, while options becomes optional, name and description still are not.
|
* @type {?GuildMember} | ||
* @readonly | ||
*/ | ||
this.member = data.member ? this.guild?.members.add(data.member, false) : null; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this.member = data.member ? this.guild?.members.add(data.member, false) : null; | |
this.member = (data.member && this.guild) ? this.guild.members.add(data.member, false) : null; |
*/ | ||
class InteractionClient extends BaseClient { | ||
/** | ||
* @param {Options} options Options for the client. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this Options
type doesn't exist, would probably be good to give it a better name too
This comment has been minimized.
This comment has been minimized.
superseded by #5448 |
#5448 is done! |
Please describe the changes this PR makes and why it should be merged:
Status
This will need #4879 before it lands.
Semantic versioning classification: