@novelbrasil/discord.js-embed-menu
Advanced tools
Comparing version 1.2.1 to 1.2.2
@@ -172,8 +172,52 @@ "use strict"; | ||
const filter = (_interaction) => { | ||
var _a, _b; | ||
return _interaction.user.id === ((_b = (_a = this.menu) === null || _a === void 0 ? void 0 : _a.client.user) === null || _b === void 0 ? void 0 : _b.id); | ||
return _interaction.user.id === this.user.id; | ||
}; | ||
const component = yield this.menu.awaitMessageComponent({ filter, time: this.timeout, componentType: discord_js_1.ComponentType.Button }); | ||
console.log(component); | ||
if (!component) { | ||
try { | ||
const component = yield this.menu.awaitMessageComponent({ filter, time: this.timeout, componentType: discord_js_1.ComponentType.Button }); | ||
console.log(component); | ||
if (!component) | ||
return; | ||
const key = Object.prototype.hasOwnProperty.call(this.currentPage.buttons, component.customId) | ||
? component.customId | ||
: Object.prototype.hasOwnProperty.call(this.currentPage.buttons, component.id) ? component.id : null; | ||
console.log("collect"); | ||
if (key && this.menu && this.menu instanceof discord_js_1.InteractionResponse) { | ||
if (component.user.id !== this.user.id) | ||
return; | ||
if (!this.currentPage.buttons) | ||
return; | ||
if (typeof this.currentPage.buttons[key].action !== 'string') { | ||
this.currentPage.buttons[key].action(this); | ||
} | ||
switch (this.currentPage.buttons[key].action) { | ||
case "first": | ||
this.setPage(0); | ||
break; | ||
case "last": | ||
this.setPage(this.pages.length - 1); | ||
break; | ||
case 'previous': { | ||
if (this.pageIndex > 0) { | ||
this.setPage(this.pageIndex - 1); | ||
} | ||
break; | ||
} | ||
case 'next': { | ||
if (this.pageIndex < this.pages.length - 1) { | ||
this.setPage(this.pageIndex + 1); | ||
} | ||
break; | ||
} | ||
case 'delete': { | ||
this.delete(); | ||
break; | ||
} | ||
default: { | ||
this.setPage(this.pages.findIndex(p => this.currentPage.buttons && p.name === this.currentPage.buttons[key].action)); | ||
break; | ||
} | ||
} | ||
} | ||
} | ||
catch (error) { | ||
if (!this.isDM) { | ||
@@ -187,45 +231,3 @@ if (this.deleteOnTimeout) { | ||
} | ||
return; | ||
} | ||
const key = Object.prototype.hasOwnProperty.call(this.currentPage.buttons, component.customId) | ||
? component.customId | ||
: Object.prototype.hasOwnProperty.call(this.currentPage.buttons, component.id) ? component.id : null; | ||
console.log("collect"); | ||
if (key && this.menu && this.menu instanceof discord_js_1.InteractionResponse) { | ||
if (component.user.id !== this.user.id) | ||
return; | ||
if (!this.currentPage.buttons) | ||
return; | ||
if (typeof this.currentPage.buttons[key].action !== 'string') { | ||
this.currentPage.buttons[key].action(this); | ||
} | ||
switch (this.currentPage.buttons[key].action) { | ||
case "first": | ||
this.setPage(0); | ||
break; | ||
case "last": | ||
this.setPage(this.pages.length - 1); | ||
break; | ||
case 'previous': { | ||
if (this.pageIndex > 0) { | ||
this.setPage(this.pageIndex - 1); | ||
} | ||
break; | ||
} | ||
case 'next': { | ||
if (this.pageIndex < this.pages.length - 1) { | ||
this.setPage(this.pageIndex + 1); | ||
} | ||
break; | ||
} | ||
case 'delete': { | ||
this.delete(); | ||
break; | ||
} | ||
default: { | ||
this.setPage(this.pages.findIndex(p => this.currentPage.buttons && p.name === this.currentPage.buttons[key].action)); | ||
break; | ||
} | ||
} | ||
} | ||
} | ||
@@ -232,0 +234,0 @@ }); |
{ | ||
"name": "@novelbrasil/discord.js-embed-menu", | ||
"description": "Easily create Discord.js embed menus with reactions and unlimited customisable pages.", | ||
"version": "1.2.1", | ||
"version": "1.2.2", | ||
"author": "eilex", | ||
@@ -6,0 +6,0 @@ "license": "MIT", |
@@ -198,7 +198,51 @@ import { EventEmitter } from 'events'; | ||
const filter = (_interaction: any): boolean => { | ||
return _interaction.user.id === this.menu?.client.user?.id | ||
return _interaction.user.id === this.user.id | ||
} | ||
const component = await this.menu.awaitMessageComponent({ filter, time: this.timeout, componentType: ComponentType.Button }) | ||
console.log(component) | ||
if (!component) { | ||
try { | ||
const component = await this.menu.awaitMessageComponent({ filter, time: this.timeout, componentType: ComponentType.Button }) | ||
console.log(component) | ||
if (!component) return | ||
const key = Object.prototype.hasOwnProperty.call(this.currentPage.buttons, component.customId as string) | ||
? component.customId | ||
: Object.prototype.hasOwnProperty.call(this.currentPage.buttons, component.id as string) ? component.id : null; | ||
console.log("collect") | ||
if (key && this.menu && this.menu instanceof InteractionResponse) { | ||
if (component.user.id !== this.user.id) return | ||
if (!this.currentPage.buttons) return | ||
if (typeof this.currentPage.buttons[key].action !== 'string') { | ||
this.currentPage.buttons[key].action(this); | ||
} | ||
switch (this.currentPage.buttons[key].action) { | ||
case "first": | ||
this.setPage(0); | ||
break | ||
case "last": | ||
this.setPage(this.pages.length - 1); | ||
break | ||
case 'previous': { | ||
if (this.pageIndex > 0) { | ||
this.setPage(this.pageIndex - 1); | ||
} | ||
break; | ||
} | ||
case 'next': { | ||
if (this.pageIndex < this.pages.length - 1) { | ||
this.setPage(this.pageIndex + 1); | ||
} | ||
break; | ||
} | ||
case 'delete': { | ||
this.delete() | ||
break | ||
} | ||
default: { | ||
this.setPage( | ||
this.pages.findIndex(p => this.currentPage.buttons && p.name === this.currentPage.buttons[key].action) | ||
); | ||
break; | ||
} | ||
} | ||
} | ||
} catch (error) { | ||
if (!this.isDM) { | ||
@@ -211,46 +255,3 @@ if (this.deleteOnTimeout) { | ||
} | ||
return | ||
} | ||
const key = Object.prototype.hasOwnProperty.call(this.currentPage.buttons, component.customId as string) | ||
? component.customId | ||
: Object.prototype.hasOwnProperty.call(this.currentPage.buttons, component.id as string) ? component.id : null; | ||
console.log("collect") | ||
if (key && this.menu && this.menu instanceof InteractionResponse) { | ||
if (component.user.id !== this.user.id) return | ||
if (!this.currentPage.buttons) return | ||
if (typeof this.currentPage.buttons[key].action !== 'string') { | ||
this.currentPage.buttons[key].action(this); | ||
} | ||
switch (this.currentPage.buttons[key].action) { | ||
case "first": | ||
this.setPage(0); | ||
break | ||
case "last": | ||
this.setPage(this.pages.length - 1); | ||
break | ||
case 'previous': { | ||
if (this.pageIndex > 0) { | ||
this.setPage(this.pageIndex - 1); | ||
} | ||
break; | ||
} | ||
case 'next': { | ||
if (this.pageIndex < this.pages.length - 1) { | ||
this.setPage(this.pageIndex + 1); | ||
} | ||
break; | ||
} | ||
case 'delete': { | ||
this.delete() | ||
break | ||
} | ||
default: { | ||
this.setPage( | ||
this.pages.findIndex(p => this.currentPage.buttons && p.name === this.currentPage.buttons[key].action) | ||
); | ||
break; | ||
} | ||
} | ||
} | ||
} | ||
@@ -257,0 +258,0 @@ } |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
475141
3998