Yardım v14.3.0

claxorj
Katılım
18 Şub 2023
Mesajlar
10
Tepkime puanı
0
Şehir
İstanbul
Bana v14.3.0 slashlı yardım menüsü lazım boş

/yardım yazınca yardım menüsünü atacak.

Not: src klasörünün içinde commands klasörü var ona göre kodlarsanız sevinirim
Yani commands içine yardım.js olarak atacam

Not koda yardım edecek arkadaşlar için yazdım
 
Son düzenleme:
janwilliemkoch
Katılım
15 Tem 2023
Mesajlar
5
Tepkime puanı
1
Şehir
İzmir
commands klasorünün içindeki yardim.js

JavaScript:
const { Client, CommandInteraction, MessageActionRow, MessageSelectMenuBuilder } = require('discord.js');

module.exports = {
    data: {
        name: 'yardım',
        description: 'Tüm komutları görüntüler.',
    },
    async execute(interaction) {
        const commands = interaction.client.commands;

        const commandOptions = [];
        for (const command of commands) {
            commandOptions.push({
                label: command[1].data.name,
                description: command[1].data.description,
                value: command[1].data.name,
            });
        }

        const selectMenu = new MessageSelectMenuBuilder()
            .setCustomId('yardim_select')
            .setPlaceholder('Bir komut seçin...')
            .addOptions(commandOptions);

        const row = new MessageActionRow().addComponents(selectMenu);

        await interaction.reply({
            content: 'Aşağıdan bir komut seçin:',
            components: [row],
        });
    },
};


Buda ana index dosyanın içinde olması gereken.


JavaScript:
const { Client, Collection, Intents } = require('discord.js');
const fs = require('fs');

const client = new Client({ intents: [Intents.FLAGS.GUILDS, Intents.FLAGS.GUILD_MESSAGES] });

client.commands = new Collection();

const commandFiles = fs.readdirSync('./commands').filter(file => file.endsWith('.js'));

for (const file of commandFiles) {
    const command = require(`./commands/${file}`);
    client.commands.set(command.data.name, command);
}

client.on('ready', () => {
    console.log(`Logged in as ${client.user.tag}`);
});

client.on('interactionCreate', async interaction => {
    if (!interaction.isCommand()) return;

    const { commandName } = interaction;

    if (!client.commands.has(commandName)) return;

    try {
        await client.commands.get(commandName).execute(interaction);
    } catch (error) {
        console.error(error);
        await interaction.reply({ content: 'Komutu çalıştırırken bir hata oluştu.', ephemeral: true });
    }
});

client.login('YOUR_BOT_TOKEN');
 
  • Beğen
Tepkiler: Ironensar123

Konuyu 1 kişi okuyor. (0 kayıtlı üye ve 1 ziyaretçi)

  • Bilgi