SetEnabled: Add SetEnabled command for Bands
which optionally includes child Characters
This commit is contained in:
@@ -4,7 +4,7 @@ const { Card, Character, Band } = require("../models");
|
|||||||
//fetch all cards owned by the user and list them
|
//fetch all cards owned by the user and list them
|
||||||
module.exports = {
|
module.exports = {
|
||||||
data: new SlashCommandBuilder()
|
data: new SlashCommandBuilder()
|
||||||
.setName("set_active")
|
.setName("setenabled")
|
||||||
.setDescription("Enable or disable entities")
|
.setDescription("Enable or disable entities")
|
||||||
.addStringOption(option =>
|
.addStringOption(option =>
|
||||||
option.setName('type')
|
option.setName('type')
|
||||||
@@ -22,8 +22,8 @@ module.exports = {
|
|||||||
.setRequired(true)
|
.setRequired(true)
|
||||||
)
|
)
|
||||||
.addBooleanOption(option =>
|
.addBooleanOption(option =>
|
||||||
option.setName('active')
|
option.setName('enabled')
|
||||||
.setDescription('Active (true) or inactive (false)')
|
.setDescription('Enabled (true) or Disabled (false)')
|
||||||
.setRequired(true)
|
.setRequired(true)
|
||||||
)
|
)
|
||||||
.addBooleanOption(option =>
|
.addBooleanOption(option =>
|
||||||
@@ -37,20 +37,20 @@ module.exports = {
|
|||||||
const type = interaction.options.getString('type');
|
const type = interaction.options.getString('type');
|
||||||
|
|
||||||
if (type === 'band') {
|
if (type === 'band') {
|
||||||
let band = Band.findOne({
|
let band = await Band.findOne({
|
||||||
where: {
|
where: {
|
||||||
id: interaction.options.getInteger('id')
|
id: interaction.options.getInteger('id')
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
if (!band) {
|
if (!band) {
|
||||||
interaction.reply({
|
interaction.editReply({
|
||||||
content: "Band not found",
|
content: "Band not found",
|
||||||
ephemeral: true
|
ephemeral: true
|
||||||
});
|
});
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
band.update({
|
await band.update({
|
||||||
active: interaction.options.getBoolean('active')
|
enabled: interaction.options.getBoolean('enabled')
|
||||||
});
|
});
|
||||||
|
|
||||||
if (interaction.options.getBoolean('include_children')) {
|
if (interaction.options.getBoolean('include_children')) {
|
||||||
@@ -59,20 +59,22 @@ module.exports = {
|
|||||||
bandId: band.id
|
bandId: band.id
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
for (let character of characters) {
|
Character.update({
|
||||||
character.update({
|
enabled: (interaction.options.getBoolean('enabled') ? 1 : 0)}, {
|
||||||
active: interaction.options.getBoolean('active')
|
where: { bandId: band.id }
|
||||||
});
|
});
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
await interaction.reply({
|
await interaction.editReply({
|
||||||
content: `${band.name} is now ${(interaction.options.getBoolean('active') ? 'active' : 'inactive')} (Including children: ${interaction.options.getBoolean('include_children')})`,
|
content: `${band.name} is now `
|
||||||
|
+ `${(interaction.options.getBoolean('enabled') ? 'active' : 'inactive')} `
|
||||||
|
+ `(Including children: ${(interaction.options.getBoolean('include_children') ? 'yes' : 'no')})`
|
||||||
});
|
});
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (type === 'debug') {
|
if (type === 'debug') {
|
||||||
interaction.reply({
|
interaction.editReply({
|
||||||
content: 'Debug DEBUG',
|
content: 'Debug DEBUG',
|
||||||
ephemeral: true
|
ephemeral: true
|
||||||
});
|
});
|
||||||
Reference in New Issue
Block a user