Add ability to view another's inventory #155
2 changed files with 17 additions and 3 deletions
|
@ -4,11 +4,20 @@ import InventoryHelper from "../helpers/InventoryHelper";
|
||||||
|
|
||||||
export default class Inventory extends ButtonEvent {
|
export default class Inventory extends ButtonEvent {
|
||||||
public override async execute(interaction: ButtonInteraction) {
|
public override async execute(interaction: ButtonInteraction) {
|
||||||
|
if (!interaction.guild) return;
|
||||||
|
|
||||||
const userid = interaction.customId.split(" ")[1];
|
const userid = interaction.customId.split(" ")[1];
|
||||||
const page = interaction.customId.split(" ")[2];
|
const page = interaction.customId.split(" ")[2];
|
||||||
|
|
||||||
|
const member = interaction.guild.members.cache.find(x => x.id == userid) || interaction.member;
|
||||||
|
|
||||||
|
if (!member) {
|
||||||
|
await interaction.reply("Unable to find user.");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
const embed = await InventoryHelper.GenerateInventoryPage(interaction.user.username, userid, Number(page));
|
const embed = await InventoryHelper.GenerateInventoryPage(member.user.username, member.user.id, Number(page));
|
||||||
|
|
||||||
await interaction.update({
|
await interaction.update({
|
||||||
embeds: [ embed.embed ],
|
embeds: [ embed.embed ],
|
||||||
Vylpes marked this conversation as resolved
Outdated
|
|||||||
|
|
|
@ -12,11 +12,16 @@ export default class Inventory extends Command {
|
||||||
.addNumberOption(x =>
|
.addNumberOption(x =>
|
||||||
x
|
x
|
||||||
.setName("page")
|
.setName("page")
|
||||||
.setDescription("The page to start with"));
|
.setDescription("The page to start with"))
|
||||||
|
.addUserOption(x =>
|
||||||
|
x
|
||||||
|
.setName("user")
|
||||||
|
.setDescription("The user to view (Defaults to yourself)"));
|
||||||
}
|
}
|
||||||
|
|
||||||
public override async execute(interaction: CommandInteraction) {
|
public override async execute(interaction: CommandInteraction) {
|
||||||
const page = interaction.options.get("page");
|
const page = interaction.options.get("page");
|
||||||
|
const user = interaction.options.getUser("user") || interaction.user;
|
||||||
|
|
||||||
try {
|
try {
|
||||||
let pageNumber = 0;
|
let pageNumber = 0;
|
||||||
|
@ -25,7 +30,7 @@ export default class Inventory extends Command {
|
||||||
pageNumber = Number(page.value) - 1;
|
pageNumber = Number(page.value) - 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
const embed = await InventoryHelper.GenerateInventoryPage(interaction.user.username, interaction.user.id, pageNumber);
|
const embed = await InventoryHelper.GenerateInventoryPage(user.username, user.id, pageNumber);
|
||||||
|
|
||||||
await interaction.reply({
|
await interaction.reply({
|
||||||
embeds: [ embed.embed ],
|
embeds: [ embed.embed ],
|
||||||
|
|
Loading…
Reference in a new issue
This should be removed