All files / src commands.ts

0% Statements 0/47
0% Branches 0/1
0% Functions 0/1
0% Lines 0/47

Press n or j to go to the next uncovered block, b, p or k for the previous block.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48                                                                                               
import { SlashCommandBuilder, Routes } from 'discord.js';
import { REST } from '@discordjs/rest';

// Load configuration
import { clientId, guildId, token } from '../config.json';

const commands = [
    new SlashCommandBuilder().setName('txt2img')
        .setDescription('Generate images from a text prompt.')
        .addStringOption(
            (option) => option.setName('prompt')
                .setDescription('Text prompt for the generator.')
                .setRequired(true)
        )
        .addStringOption(
            (option) => option.setName('negative_prompt')
                .setDescription('Negative prompt for the generator.')
        )
        .addStringOption(
            (option) => option.setName('workflow')
                .setDescription('Workflow to use. Default: Stable Cascade')
                .addChoices(
                    { name: 'Dreamshaper XL', value: 'dsxl' },
                    { name: 'Dreamshaper XL 4K', value: 'dsxl4k' },
                    { name: 'LazyMix+', value: 'lazy' },
                    { name: 'LazyMix+ 2K', value: 'lazy2k' },
                    { name: 'Stable Cascade', value: 'sc' },
                    { name: 'Stable Cascade 2K', value: 'sc2k' },
                    { name: 'Stable Diffusion XL', value: 'sdxl' },
                    { name: 'Stable Diffusion XL 4K', value: 'sdxl4k' },
                    { name: 'Stable Video Diffusion', value: 'svd' },
                    { name: 'Stable Video Diffusion XT', value: 'svdxt' }
                )
        )
        .addIntegerOption(
            (option) => option.setName('batch_size')
                .setDescription('Images in each batch. Default: 1')
                .setMinValue(1)
                .setMaxValue(10)
        )
].map((command) => command.toJSON());

const rest = new REST({ version: '10' }).setToken(token);

rest.put(Routes.applicationGuildCommands(clientId, guildId), { body: commands })
    .then(() => console.log('Successfully registered application commands.'))
.catch(console.error);