Polish processising of interactions

This commit is contained in:
Sebastian Fischlmayr 2022-10-07 14:36:12 +02:00
parent 4c853ae503
commit 8fee5df53e
Signed by: Maverick
GPG key ID: 6379E413924A4E77
4 changed files with 25 additions and 10 deletions

View file

@ -8,16 +8,26 @@ const commands = [
new SlashCommandBuilder() new SlashCommandBuilder()
.setName('generate') .setName('generate')
.setDescription('Generate something.') .setDescription('Generate something.')
.addStringOption(option => .addSubcommand(subcommand =>
option.setName('type') subcommand
.setDescription('The type of thing to generate.') .setName('host')
.setRequired(true) .setDescription('Generate a host.')
.addChoices( .addNumberOption(option =>
{ name: 'Host', value: 'host' }, option
{ name: 'Gang', value: 'gang' }, .setName('rating')
{ name: 'Corporation', value: 'corporation' }, .setDescription('The rating of the host.')
.setRequired(true)
) )
) .addStringOption(option =>
option
.setName('type')
.setDescription('The type of the host.')
.addChoices(
{ name: 'Foundation', value: 'foundation' },
{ name: 'Framework', value: 'framework' },
)
)
)
] ]
.map(command => command.toJSON()); .map(command => command.toJSON());

Binary file not shown.

After

Width:  |  Height:  |  Size: 69 KiB

View file

@ -13,11 +13,16 @@ client.once('ready', () => {
client.on('interactionCreate', async interaction => { client.on('interactionCreate', async interaction => {
if (!interaction.isCommand()) return; if (!interaction.isCommand()) return;
console.log(interaction.commandName);
let commandName = interaction.commandName; let commandName = interaction.commandName;
if (commandName === "generate") { if (commandName === "generate") {
await interaction.reply(`Generating ${interaction.options.getString('type')}`); if (interaction.options.getSubcommand() === "host") {
let rating = interaction.options.getNumber("rating");
let type = interaction.options.getString("type") ?? "foundation";
await interaction.reply({files: ["./france-in-pictures-beautiful-places-to-photograph-eiffel-tower.jpg"]});
}
} }
}) })

0
templates/hosts.pug Normal file
View file