Generalize labels and options
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
const { SlashCommandBuilder, AttachmentBuilder, EmbedBuilder, ActionRowBuilder, ButtonBuilder, ButtonStyle, ComponentType } = require("discord.js");
|
||||
const { Card, User, Band, Character } = require("../models");
|
||||
const { Card, User, Group, Character } = require("../models");
|
||||
const { QUALITY_VALUES, QUALITY_NAMES, CURRENCY_SYMBOLS } = require("../config/constants");
|
||||
const { UserUtils } = require("../util");
|
||||
const fs = require("fs");
|
||||
@@ -26,7 +26,7 @@ module.exports = {
|
||||
identifier: interaction.options.getString("id")
|
||||
},
|
||||
include: [
|
||||
{ model: Character, include: [{ model: Band }] },
|
||||
{ model: Character, include: [{ model: Group }] },
|
||||
{ model: User}
|
||||
]
|
||||
});
|
||||
@@ -47,7 +47,7 @@ module.exports = {
|
||||
.setTitle(`${interaction.member.displayName} burned ${card.identifier}`)
|
||||
.setDescription(`+${QUALITY_VALUES[card.quality].value} ${CURRENCY_SYMBOLS[QUALITY_VALUES[card.quality].type]}`)
|
||||
.addFields(
|
||||
{ name: `${card.Character.name}`, value: `${card.Character.Band.name}` },
|
||||
{ name: `${card.Character.name}`, value: `${card.Character.Group.name}` },
|
||||
{ name: 'Print Number', value: `${card.printNr}`, inline: true },
|
||||
{ name: 'Quality', value: `${QUALITY_NAMES[card.quality]}`, inline: true }
|
||||
)
|
||||
|
||||
@@ -19,8 +19,8 @@ module.exports = {
|
||||
)
|
||||
.addStringOption((option) =>
|
||||
option
|
||||
.setName("band")
|
||||
.setDescription("Band to filter by")
|
||||
.setName("group")
|
||||
.setDescription("Group to filter by")
|
||||
.setRequired(false)
|
||||
.setAutocomplete(true)
|
||||
)
|
||||
@@ -57,7 +57,7 @@ module.exports = {
|
||||
|
||||
const filter = {
|
||||
character: interaction.options.getString("character"),
|
||||
band: interaction.options.getString("band"),
|
||||
group: interaction.options.getString("group"),
|
||||
quality: interaction.options.getString("quality")
|
||||
}
|
||||
|
||||
@@ -145,8 +145,8 @@ module.exports = {
|
||||
filter["where"]["characterId"] = filterParam["character"];
|
||||
}
|
||||
|
||||
if (filterParam["band"]) {
|
||||
filter["where"]['$Character.bandId$'] = filterParam["band"];
|
||||
if (filterParam["group"]) {
|
||||
filter["where"]['$Character.groupId$'] = filterParam["group"];
|
||||
}
|
||||
|
||||
if (filterParam["quality"]) {
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
const { SlashCommandBuilder, ComponentType, ActionRowBuilder, ButtonBuilder, ButtonStyle, ModalBuilder, TextInputStyle, TextInputBuilder } = require("discord.js");
|
||||
const { Character, Band, RecordHistory } = require("../models");
|
||||
const { Character, Group, RecordHistory } = require("../models");
|
||||
const { UserUtils, GeneralUtils } = require("../util");
|
||||
const axios = require("axios");
|
||||
const fs = require("fs");
|
||||
@@ -15,7 +15,7 @@ module.exports = {
|
||||
.setRequired(true)
|
||||
.addChoices(
|
||||
{ name: 'character', value: 'character' },
|
||||
{ name: 'band', value: 'band' }
|
||||
{ name: 'group', value: 'group' }
|
||||
)
|
||||
)
|
||||
.addStringOption((option) =>
|
||||
@@ -39,14 +39,14 @@ module.exports = {
|
||||
let record;
|
||||
switch (interaction.options?.getString("type") ?? type) {
|
||||
case "character":
|
||||
record = await Character.findByPk(interaction.options?.getString("id") ?? id, { include: Band });
|
||||
record = await Character.findByPk(interaction.options?.getString("id") ?? id, { include: Group });
|
||||
if (!record) {
|
||||
interaction.editReply({ content: "Character not found" });
|
||||
return;
|
||||
}
|
||||
options = [ "name", "description", "imageIdentifier" ];
|
||||
break;
|
||||
case "band":
|
||||
case "group":
|
||||
options = [ "name", "description" ];
|
||||
break;
|
||||
default:
|
||||
@@ -102,7 +102,7 @@ module.exports = {
|
||||
await m.reply({ content: "An invalid image has been attached", ephemeral: true });
|
||||
return;
|
||||
}
|
||||
let identifier = `${record.Band.name.replace(" ", "_")}/${image.name}`;
|
||||
let identifier = `${record.Group.name.replace(" ", "_")}/${image.name}`;
|
||||
let path = `/app/assets/cards/${identifier}`;
|
||||
await this.downloadImage(image.attachment, path);
|
||||
await this.updateRecord(user, record, option, identifier);
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
const { SlashCommandBuilder, AttachmentBuilder } = require("discord.js");
|
||||
const { Card, Character, Band } = require("../models");
|
||||
const { Card, Character, Group } = require("../models");
|
||||
|
||||
//fetch all cards owned by the user and list them
|
||||
module.exports = {
|
||||
@@ -11,7 +11,7 @@ module.exports = {
|
||||
.setDescription('Entity type')
|
||||
.setRequired(true)
|
||||
.addChoices(
|
||||
{ name: 'Band', value: 'band' },
|
||||
{ name: 'Group', value: 'group' },
|
||||
{ name: 'Character', value: 'character' },
|
||||
{ name: 'DEBUG', value: 'debug' },
|
||||
)
|
||||
@@ -36,38 +36,38 @@ module.exports = {
|
||||
await interaction.deferReply();
|
||||
const type = interaction.options.getString('type');
|
||||
|
||||
if (type === 'band') {
|
||||
let band = await Band.findOne({
|
||||
if (type === 'group') {
|
||||
let group = await Group.findOne({
|
||||
where: {
|
||||
id: interaction.options.getInteger('id')
|
||||
}
|
||||
});
|
||||
if (!band) {
|
||||
if (!group) {
|
||||
interaction.editReply({
|
||||
content: "Band not found",
|
||||
content: "Group not found",
|
||||
ephemeral: true
|
||||
});
|
||||
return;
|
||||
}
|
||||
await band.update({
|
||||
await group.update({
|
||||
enabled: interaction.options.getBoolean('enabled')
|
||||
});
|
||||
|
||||
if (interaction.options.getBoolean('include_children')) {
|
||||
let characters = await Character.findAll({
|
||||
where: {
|
||||
bandId: band.id
|
||||
groupId: group.id
|
||||
}
|
||||
});
|
||||
Character.update({
|
||||
enabled: (interaction.options.getBoolean('enabled') ? 1 : 0)}, {
|
||||
where: { bandId: band.id }
|
||||
where: { groupId: group.id }
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
await interaction.editReply({
|
||||
content: `${band.name} is now `
|
||||
content: `${group.name} is now `
|
||||
+ `${(interaction.options.getBoolean('enabled') ? 'active' : 'inactive')} `
|
||||
+ `(Including children: ${(interaction.options.getBoolean('include_children') ? 'yes' : 'no')})`
|
||||
});
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
const { SlashCommandBuilder, AttachmentBuilder, EmbedBuilder, ActionRowBuilder, ButtonBuilder, ButtonStyle, ComponentType } = require("discord.js");
|
||||
const { Card, User, Band, Character } = require("../models");
|
||||
const { Card, User, Group, Character } = require("../models");
|
||||
const { Rendering, UserUtils } = require("../util");
|
||||
const { QUALITY_NAMES } = require("../config/constants");
|
||||
const fs = require("fs");
|
||||
@@ -18,7 +18,7 @@ module.exports = {
|
||||
.addChoices(
|
||||
{ name: 'card', value: 'card' },
|
||||
{ name: 'character', value: 'character' },
|
||||
{ name: 'band', value: 'band' }
|
||||
{ name: 'group', value: 'group' }
|
||||
)
|
||||
)
|
||||
.addStringOption((option) =>
|
||||
@@ -39,8 +39,8 @@ module.exports = {
|
||||
case "character":
|
||||
this.viewCharacter(interaction, interaction.options.getString("id"));
|
||||
break;
|
||||
case "band":
|
||||
interaction.editReply({ content: "Band view is not yet implemented" });
|
||||
case "group":
|
||||
interaction.editReply({ content: "Group view is not yet implemented" });
|
||||
break;
|
||||
|
||||
}
|
||||
@@ -52,7 +52,7 @@ module.exports = {
|
||||
identifier: cardIdentifier
|
||||
},
|
||||
include: [
|
||||
{ model: Character, include: [{ model: Band }] },
|
||||
{ model: Character, include: [{ model: Group }] },
|
||||
{ model: User}
|
||||
]
|
||||
});
|
||||
@@ -83,10 +83,10 @@ module.exports = {
|
||||
.setTitle(`${card.Character.name}`)
|
||||
.setDescription(description)
|
||||
.setImage(`attachment://${filename}`)
|
||||
.setThumbnail(card.Character.Band.imageURL)
|
||||
.setThumbnail(card.Character.Group.imageURL)
|
||||
.addFields(
|
||||
{ name: "Owned by", value: `<@${card.User.discordId}>` },
|
||||
{ name: "Band", value: `${card.Character.Band.name}` },
|
||||
{ name: "Group", value: `${card.Character.Group.name}` },
|
||||
{ name: "Character ID", value: `${card.Character.id}` },
|
||||
{ name: 'Print Number', value: `${card.printNr}`, inline: true },
|
||||
{ name: 'Quality', value: `${QUALITY_NAMES[card.quality]} ${(card.quality === 6 ? '<a:sparklu:1019505245572837428>':'')}`, inline: true }
|
||||
@@ -105,7 +105,7 @@ module.exports = {
|
||||
let isAdmin = await UserUtils.getPermissionLevel(interaction.member) == 2;
|
||||
let character = await Character.findOne({
|
||||
where: { id: characterId },
|
||||
include: [Band]
|
||||
include: [Group]
|
||||
});
|
||||
if (!character) {
|
||||
interaction.editReply({ content: "Character not found" });
|
||||
@@ -139,9 +139,9 @@ module.exports = {
|
||||
.setTitle(`${character.name}`)
|
||||
.setDescription(description)
|
||||
.setImage(`attachment://${filename}`)
|
||||
.setThumbnail(character.Band.imageURL)
|
||||
.setThumbnail(character.Group.imageURL)
|
||||
.addFields(
|
||||
{ name: "Band", value: `${character.Band.name}` },
|
||||
{ name: "Group", value: `${character.Group.name}` },
|
||||
{ name: "Character ID", value: `${character.id}` },
|
||||
)
|
||||
.setColor(0x00ff00)
|
||||
|
||||
Reference in New Issue
Block a user