Allow viewing other users inventories
This commit is contained in:
parent
36ec25113e
commit
ab2b5d70af
2 changed files with 17 additions and 3 deletions
|
@ -4,11 +4,20 @@ import InventoryHelper from "../helpers/InventoryHelper";
|
|||
|
||||
export default class Inventory extends ButtonEvent {
|
||||
public override async execute(interaction: ButtonInteraction) {
|
||||
if (!interaction.guild) return;
|
||||
|
||||
const userid = interaction.customId.split(" ")[1];
|
||||
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 {
|
||||
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({
|
||||
embeds: [ embed.embed ],
|
||||
|
|
|
@ -12,11 +12,16 @@ export default class Inventory extends Command {
|
|||
.addNumberOption(x =>
|
||||
x
|
||||
.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) {
|
||||
const page = interaction.options.get("page");
|
||||
const user = interaction.options.getUser("user") || interaction.user;
|
||||
|
||||
try {
|
||||
let pageNumber = 0;
|
||||
|
@ -25,7 +30,7 @@ export default class Inventory extends Command {
|
|||
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({
|
||||
embeds: [ embed.embed ],
|
||||
|
|
Loading…
Reference in a new issue