Skip to content

Commit

Permalink
chore: restore generate
Browse files Browse the repository at this point in the history
  • Loading branch information
fearandesire committed Nov 21, 2024
1 parent e77a2bd commit 24f85ef
Showing 1 changed file with 54 additions and 1 deletion.
55 changes: 54 additions & 1 deletion src/commands/props/props.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
import { LogType } from '../../utils/logging/AppLog.interface.js';
import { Subcommand } from '@sapphire/plugin-subcommands';
import { PermissionFlagsBits, EmbedBuilder } from 'discord.js';
import {
PermissionFlagsBits,
EmbedBuilder,
type ChatInputCommandInteraction,
} from 'discord.js';
import PropsApiWrapper from '../../utils/api/Khronos/props/propsApiWrapper.js';
import type { Prop } from '../../openapi/khronos/models/Prop.js';
import type { UpdatePropResultDto } from '../../openapi/khronos/models/UpdatePropResultDto.js';
Expand All @@ -14,6 +18,9 @@ import { ApiErrorHandler } from '../../utils/api/Khronos/error-handling/ApiError
import { ApiModules } from '../../lib/interfaces/api/api.interface.js';
import { PaginatedMessageEmbedFields } from '@sapphire/discord.js-utilities';
import embedColors from '../../lib/colorsConfig.js';
import { entries } from 'lodash';
import { type } from 'node:os';
import { log } from 'node:console';

export class UserCommand extends Subcommand {
public constructor(
Expand All @@ -30,6 +37,14 @@ export class UserCommand extends Subcommand {
type: 'group',
entries: [{ name: 'active', chatInputRun: 'viewActive' }],
},
{
name: 'generate',
type: 'group',
entries: [
{ name: 'all', chatInputRun: 'generateAll' },
{ name: 'prop_embed', chatInputRun: 'generatePropEmbed' },
],
},
{
name: 'manage',
type: 'group',
Expand All @@ -56,6 +71,16 @@ export class UserCommand extends Subcommand {
.setDescription('View props with active predictions'),
),
)
.addSubcommandGroup((group) =>
group
.setName('generate')
.setDescription('Generate prop embeds')
.addSubcommand((subcommand) =>
subcommand
.setName('all')
.setDescription('Generate all prop embeds'),
),
)
.addSubcommandGroup((group) =>
group
.setName('manage')
Expand Down Expand Up @@ -95,6 +120,12 @@ export class UserCommand extends Subcommand {
return this.setResult(interaction);
}

public async generateAll(
interaction: Subcommand.ChatInputCommandInteraction,
) {
return this.generateProps(interaction);
}

private async setResult(interaction: Subcommand.ChatInputCommandInteraction) {
const propId = interaction.options.getString('prop_id', true);
const result = interaction.options.getString('result', true);
Expand Down Expand Up @@ -156,6 +187,28 @@ export class UserCommand extends Subcommand {
return embed;
}

private async generateProps(
interaction: Subcommand.ChatInputCommandInteraction,
) {
await interaction.deferReply();
await interaction.editReply({
content: 'Generating prop embeds, please wait...',
});
await new PropsApiWrapper().generateAllPropEmbeds({
guildId: interaction.guildId,
});

await interaction.editReply({
content: 'Prop Embeds populated successfully',
});

await AppLog.log({
guildId: interaction.guildId,
description: `${interaction.user.username} generated all prop embeds`,
type: LogType.Info,
});
}

private async viewActiveProps(
interaction: Subcommand.ChatInputCommandInteraction,
) {
Expand Down

0 comments on commit 24f85ef

Please sign in to comment.