fix: interaction response

This commit is contained in:
Elysia 2023-06-14 13:53:09 +07:00
parent e8f3b590c1
commit bd66c99ef2
4 changed files with 5 additions and 5 deletions

View File

@ -891,7 +891,7 @@ class ApplicationCommand extends Base {
return new Promise((resolve, reject) => { return new Promise((resolve, reject) => {
const handler = data => { const handler = data => {
timeout.refresh(); timeout.refresh();
if (data.metadata.nonce !== nonce) return; if (data.metadata?.nonce !== nonce) return;
clearTimeout(timeout); clearTimeout(timeout);
this.client.removeListener('interactionResponse', handler); this.client.removeListener('interactionResponse', handler);
this.client.decrementMaxListeners(); this.client.decrementMaxListeners();
@ -987,7 +987,7 @@ class ApplicationCommand extends Base {
return new Promise((resolve, reject) => { return new Promise((resolve, reject) => {
const handler = data => { const handler = data => {
timeout.refresh(); timeout.refresh();
if (data.metadata.nonce !== nonce) return; if (data.metadata?.nonce !== nonce) return;
clearTimeout(timeout); clearTimeout(timeout);
this.client.removeListener('interactionResponse', handler); this.client.removeListener('interactionResponse', handler);
this.client.decrementMaxListeners(); this.client.decrementMaxListeners();

View File

@ -199,7 +199,7 @@ class MessageButton extends BaseMessageComponent {
return new Promise((resolve, reject) => { return new Promise((resolve, reject) => {
const handler = data => { const handler = data => {
timeout.refresh(); timeout.refresh();
if (data.metadata.nonce !== nonce) return; if (data.metadata?.nonce !== nonce) return;
clearTimeout(timeout); clearTimeout(timeout);
message.client.removeListener('interactionResponse', handler); message.client.removeListener('interactionResponse', handler);
message.client.decrementMaxListeners(); message.client.decrementMaxListeners();

View File

@ -359,7 +359,7 @@ class MessageSelectMenu extends BaseMessageComponent {
return new Promise((resolve, reject) => { return new Promise((resolve, reject) => {
const handler = data => { const handler = data => {
timeout.refresh(); timeout.refresh();
if (data.metadata.nonce !== nonce) return; if (data.metadata?.nonce !== nonce) return;
clearTimeout(timeout); clearTimeout(timeout);
message.client.removeListener('interactionResponse', handler); message.client.removeListener('interactionResponse', handler);
message.client.decrementMaxListeners(); message.client.decrementMaxListeners();

View File

@ -247,7 +247,7 @@ class Modal {
return new Promise((resolve, reject) => { return new Promise((resolve, reject) => {
const handler = data => { const handler = data => {
timeout.refresh(); timeout.refresh();
if (data.metadata.nonce !== nonce) return; if (data.metadata?.nonce !== nonce) return;
clearTimeout(timeout); clearTimeout(timeout);
this.client.removeListener('interactionResponse', handler); this.client.removeListener('interactionResponse', handler);
this.client.decrementMaxListeners(); this.client.decrementMaxListeners();