Compare commits
No commits in common. "680e627f7a690d6bfeffa3eeb654f4976551696b" and "a71b33d8792dcf64dda0fb16d57afb488b946705" have entirely different histories.
680e627f7a
...
a71b33d879
2 changed files with 3 additions and 40 deletions
|
@ -113,8 +113,6 @@ export default class InventoryHelper {
|
||||||
.setStyle(ButtonStyle.Primary)
|
.setStyle(ButtonStyle.Primary)
|
||||||
.setDisabled(page + 1 == pages.length));
|
.setDisabled(page + 1 == pages.length));
|
||||||
|
|
||||||
let pageNum = 0;
|
|
||||||
|
|
||||||
const row2 = new ActionRowBuilder<StringSelectMenuBuilder>()
|
const row2 = new ActionRowBuilder<StringSelectMenuBuilder>()
|
||||||
.addComponents(
|
.addComponents(
|
||||||
new StringSelectMenuBuilder()
|
new StringSelectMenuBuilder()
|
||||||
|
@ -123,9 +121,9 @@ export default class InventoryHelper {
|
||||||
.addOptions(...pages.map(x =>
|
.addOptions(...pages.map(x =>
|
||||||
new StringSelectMenuOptionBuilder()
|
new StringSelectMenuOptionBuilder()
|
||||||
.setLabel(`${x.name} (${x.seriesSubpage + 1})`.substring(0, 100))
|
.setLabel(`${x.name} (${x.seriesSubpage + 1})`.substring(0, 100))
|
||||||
.setDescription(`Page ${pageNum + 1}`)
|
.setDescription("Quick navigate to page...")
|
||||||
.setDefault(currentPage.id == x.id)
|
.setDefault(currentPage.id == x.id)
|
||||||
.setValue(`${userid} ${pageNum++}`))));
|
.setValue(x.id.toString()))));
|
||||||
|
|
||||||
const buffer = await ImageHelper.GenerateCardImageGrid(currentPage.cards.map(x => ({ id: x.id, path: x.path })));
|
const buffer = await ImageHelper.GenerateCardImageGrid(currentPage.cards.map(x => ({ id: x.id, path: x.path })));
|
||||||
const image = new AttachmentBuilder(buffer, { name: "page.png" });
|
const image = new AttachmentBuilder(buffer, { name: "page.png" });
|
||||||
|
|
|
@ -1,43 +1,8 @@
|
||||||
import {StringSelectMenuInteraction} from "discord.js";
|
import {StringSelectMenuInteraction} from "discord.js";
|
||||||
import {StringDropdownEvent} from "../type/stringDropdownEvent";
|
import {StringDropdownEvent} from "../type/stringDropdownEvent";
|
||||||
import AppLogger from "../client/appLogger";
|
|
||||||
import InventoryHelper from "../helpers/InventoryHelper";
|
|
||||||
|
|
||||||
export default class Inventory extends StringDropdownEvent {
|
export default class Inventory extends StringDropdownEvent {
|
||||||
public override async execute(interaction: StringSelectMenuInteraction) {
|
public override async execute(interaction: StringSelectMenuInteraction) {
|
||||||
if (!interaction.guild) return;
|
await interaction.reply(`Test: ${interaction.customId}, ${interaction.values.join(",")}`);
|
||||||
|
|
||||||
const userid = interaction.values[0].split(" ")[0];
|
|
||||||
const page = interaction.values[0].split(" ")[1];
|
|
||||||
|
|
||||||
AppLogger.LogDebug("StringDropdown/Inventory", `Parameters: userid=${userid}, page=${page}`);
|
|
||||||
|
|
||||||
await interaction.deferUpdate();
|
|
||||||
|
|
||||||
const member = interaction.guild.members.cache.find(x => x.id == userid) || await interaction.guild.members.fetch(userid);
|
|
||||||
|
|
||||||
if (!member) {
|
|
||||||
await interaction.reply("Unable to find user.");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
try {
|
|
||||||
const embed = await InventoryHelper.GenerateInventoryPage(member.user.username, member.user.id, Number(page));
|
|
||||||
|
|
||||||
if (!embed) {
|
|
||||||
await interaction.followUp("No page for user found.");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
await interaction.editReply({
|
|
||||||
files: [ embed.image ],
|
|
||||||
embeds: [ embed.embed ],
|
|
||||||
components: [ embed.row1, embed.row2 ],
|
|
||||||
});
|
|
||||||
} catch (e) {
|
|
||||||
AppLogger.LogError("StringDropdown/Inventory", `Error generating inventory page for ${member.user.username} with id ${member.user.id}: ${e}`);
|
|
||||||
|
|
||||||
await interaction.followUp("An error has occurred running this command.");
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue