Skip to content
TheChatArchiveThe Chat Archive
gpt-4o-2024-08-06· OpenAIAi2 WildChat-4.8M (AI2)

const { SlashCommandBuilder } = require('@discordjs/builders'); const { EmbedBuilder,…

  1. User

    const { SlashCommandBuilder } = require('@discordjs/builders'); const { EmbedBuilder, StringSelectMenuBuilder, StringSelectMenuOptionBuilder } = require('discord.js');

    module.exports = { data: new SlashCommandBuilder() .setName('settings') .setDescription('Настройка бота'), async execute(interaction) { const embed = new EmbedBuilder() .setDescription(${interaction.user}, **выберите что-нибудь для настройки чего нибудь.**) .setColor(0x212121);

    const select = new StringSelectMenuBuilder()
      .setCustomId('settings')
      .setPlaceholder('Выберите настройку')
      .addOptions(
        new StringSelectMenuOptionBuilder()
          .setLabel('Уровни')
          .setValue('levels')
          .setDescription('Настройка уровней, карточки пользователя, рейтинг и т.д')
          .setEmoji('🏆'),
        new StringSelectMenuOptionBuilder()
          .setLabel('Модерация')
          .setValue('moderation')
          .setDescription('Настройки модерации сервера')
          .setEmoji('🛡️'),
        new StringSelectMenuOptionBuilder()
          .setLabel('Приватные комнаты')
          .setValue('private_rooms')
          .setDescription('Настройки приватных комнат')
          .setEmoji('🔒'),
        new StringSelectMenuOptionBuilder()
          .setLabel('Тикеты')
          .setValue('tickets')
          .setDescription('Настройка тикетов')
          .setEmoji('🎫'),
        new StringSelectMenuOptionBuilder()
          .setLabel('Аудит')
          .setValue('audit')
          .setDescription('Просмотр и управление аудитом')
          .setEmoji('📋'),
        new StringSelectMenuOptionBuilder()
          .setLabel('Анти-рейд')
          .setValue('anti_raid')
          .setDescription('Настройки защиты от рейдов и т.д')
          .setEmoji('🛡️')
      );
    
    await interaction.reply({ embeds: [embed], components: [select] });
    

    }, };

    переделай чтобы было селект меню место вибора в команде

  2. Assistant

    Если я правильно понимаю, вы хотите сделать команду /settings, которая отображает интерфейс выбора настроек с помощью кнопок, вместо использования одного всплывающего меню. Давайте изменим ваш код, чтобы в результате появился набор кнопок для каждой настройки:

    const { SlashCommandBuilder } = require('@discordjs/builders');
    const { EmbedBuilder, ActionRowBuilder, ButtonBuilder, ButtonStyle } = require('discord.js');
    
    module.exports = {
      data: new SlashCommandBuilder()
        .setName('settings')
        .setDescription('Настройка бота'),
      async execute(interaction) {
        const embed = new EmbedBuilder()
          .setDescription(`${interaction.user}, **выберите что-нибудь для настройки чего нибудь.**`)
          .setColor(0x212121);
    
        const row = new ActionRowBuilder()
          .addComponents(
            new ButtonBuilder()
              .setCustomId('levels')
              .setLabel('Уровни')
              .setStyle(ButtonStyle.Primary)
              .setEmoji('🏆'),
            new ButtonBuilder()
              .setCustomId('moderation')
              .setLabel('Модерация')
              .setStyle(ButtonStyle.Primary)
              .setEmoji('🛡️'),
            new ButtonBuilder()
              .setCustomId('private_rooms')
              .setLabel('Приватные комнаты')
              .setStyle(ButtonStyle.Primary)
              .setEmoji('🔒'),
            new ButtonBuilder()
              .setCustomId('tickets')
              .setLabel('Тикеты')
              .setStyle(ButtonStyle.Primary)
              .setEmoji('🎫'),
            new ButtonBuilder()
              .setCustomId('audit')
              .setLabel('Аудит')
              .setStyle(ButtonStyle.Primary)
              .setEmoji('📋'),
            new ButtonBuilder()
              .setCustomId('anti_raid')
              .setLabel('Анти-рейд')
              .setStyle(ButtonStyle.Primary)
              .setEmoji('🛡️')
          );
    
        await interaction.reply({ embeds: [embed], components: [row] });
      },
    };
    

    В этой версии кода мы использовали ButtonBuilder для создания кнопок вместо StringSelectMenuBuilder. Каждая кнопка содержит CustomId, который вы впоследствии можете использовать, чтобы настроить какой-то функционал, исходя из того, какую кнопку нажал пользователь. Обратите внимание, что для того чтобы обработать нажатие кнопок, вам понадобится слушатель обработки событий кнопок, который должен быть реализован у вашего бота.

Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.