mirror of
https://github.com/Hessenuk/DiscordTickets.git
synced 2025-09-05 09:41:27 +03:00
fix: user/create command when there is a single category
This commit is contained in:
@@ -32,7 +32,7 @@ module.exports = class CreateUserCommand extends UserCommand {
|
|||||||
/** @type {import("client")} */
|
/** @type {import("client")} */
|
||||||
const client = this.client;
|
const client = this.client;
|
||||||
|
|
||||||
await interaction.deferReply({ ephemeral: true });
|
await interaction.deferReply({ flags: 'Ephemeral' });
|
||||||
|
|
||||||
const settings = await client.prisma.guild.findUnique({
|
const settings = await client.prisma.guild.findUnique({
|
||||||
include: { categories:true },
|
include: { categories:true },
|
||||||
@@ -81,12 +81,11 @@ module.exports = class CreateUserCommand extends UserCommand {
|
|||||||
.setTitle(getMessage('commands.user.create.prompt.title'))
|
.setTitle(getMessage('commands.user.create.prompt.title'))
|
||||||
.setDescription(getMessage('commands.user.create.prompt.description')),
|
.setDescription(getMessage('commands.user.create.prompt.description')),
|
||||||
],
|
],
|
||||||
ephemeral: false,
|
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
if (settings.categories.length === 0) {
|
if (settings.categories.length === 0) {
|
||||||
interaction.reply({
|
interaction.editReply({
|
||||||
components: [],
|
components: [],
|
||||||
embeds: [
|
embeds: [
|
||||||
new ExtendedEmbedBuilder()
|
new ExtendedEmbedBuilder()
|
||||||
@@ -94,10 +93,27 @@ module.exports = class CreateUserCommand extends UserCommand {
|
|||||||
.setTitle(getMessage('misc.no_categories.title'))
|
.setTitle(getMessage('misc.no_categories.title'))
|
||||||
.setDescription(getMessage('misc.no_categories.description')),
|
.setDescription(getMessage('misc.no_categories.description')),
|
||||||
],
|
],
|
||||||
ephemeral: true,
|
|
||||||
});
|
});
|
||||||
} else if (settings.categories.length === 1) {
|
} else if (settings.categories.length === 1) {
|
||||||
await prompt(settings.categories[0].id);
|
const category = settings.categories[0];
|
||||||
|
// ! must be awaited,
|
||||||
|
// ! followUp will act as editReply (on the original ephemeral message) if it arrives first
|
||||||
|
await interaction.editReply({
|
||||||
|
components: [],
|
||||||
|
embeds: [
|
||||||
|
new ExtendedEmbedBuilder({
|
||||||
|
iconURL: interaction.guild.iconURL(),
|
||||||
|
text: settings.footer,
|
||||||
|
})
|
||||||
|
.setColor(settings.successColour)
|
||||||
|
.setTitle(getMessage('commands.user.create.sent.title'))
|
||||||
|
.setDescription(getMessage('commands.user.create.sent.description', {
|
||||||
|
category: category.name,
|
||||||
|
user: interaction.targetUser.toString(),
|
||||||
|
})),
|
||||||
|
],
|
||||||
|
});
|
||||||
|
await prompt(category.id);
|
||||||
} else {
|
} else {
|
||||||
const collectorTime = ms('15s');
|
const collectorTime = ms('15s');
|
||||||
const confirmationM = await interaction.editReply({
|
const confirmationM = await interaction.editReply({
|
||||||
@@ -130,6 +146,8 @@ module.exports = class CreateUserCommand extends UserCommand {
|
|||||||
})
|
})
|
||||||
.then(async i => {
|
.then(async i => {
|
||||||
const category = settings.categories.find(c => c.id === Number(i.values[0]));
|
const category = settings.categories.find(c => c.id === Number(i.values[0]));
|
||||||
|
// ! must be awaited,
|
||||||
|
// ! followUp will act as editReply (on the original ephemeral message) if it arrives first
|
||||||
await i.update({
|
await i.update({
|
||||||
components: [],
|
components: [],
|
||||||
embeds: [
|
embeds: [
|
||||||
@@ -144,7 +162,6 @@ module.exports = class CreateUserCommand extends UserCommand {
|
|||||||
user: interaction.targetUser.toString(),
|
user: interaction.targetUser.toString(),
|
||||||
})),
|
})),
|
||||||
],
|
],
|
||||||
ephemeral: true,
|
|
||||||
});
|
});
|
||||||
await prompt(category.id);
|
await prompt(category.id);
|
||||||
})
|
})
|
||||||
|
Reference in New Issue
Block a user