command handler part 2

 KALIAN TINGGAL MASUKKAN COMMAND INI


ping.js:

module.exports = {
    name: 'ping',
    description: 'ini adalah command ping',
    execute(message) {
        message.reply('Pong!');
    }
}

info.js:

const {
    MessageEmbed
} = require('discord.js');
const botInfo = require('./botInfo.json');

module.exports = {
    name: 'info',
    description: 'ini adalah command info',
    execute(messageargs) {
        if (!args[1]) {
            const infoEmbed = new MessageEmbed()
            .setTitle('BOT Information commands')
            .setDescription('masukan salah satu perintah setelah mengetikan kata info')
            .addField('author','BOT author Information')
            .addField('version','BOT version')
            .addField('bot','All information about BOT')
            .setFooter('windows bot' + botInfo.version);
        message.channel.send(infoEmbed);
        break;
        } else {
            if (args[1] === 'author') {
                message.channel.send(botInfo.author);
            } else if (args[1] === 'version') {
                message.channel.send('Version : ' + botInfo.version);
            } else if (args[1] === 'bot') {
                const botInfoEmbed = new MessageEmbed()
                .setTitle('BOT information')
                .setDescription('Windows bot adalah bot command dan bot windows ini di bikin pakai node.js dan discord.js')
                .addField('Author',botInfo.authortrue)
                .addField('Version'botInfo.versiontrue)
                .setColor('9fd8df')
                .setFooter('windows bot' + botInfo.version)
            message.channel.send(botInfoEmbed);
        } else {
            message.channel.send('🚫 command yang anda ketik salah atau tidak benar');
            }
        }
    }
}

botinfo.json:

{
    "version""1.16.4",
    "prefix""w/",
    "bot_name""windows",
    "author""Nuril Ardhi"
}

help.js:

const {
    MessageEmbed
} = require('discord.js');
const botInfo = require('./botInfo.json');

module.exports = {
    name: 'help',
    description: 'ini adalah command help',
    execute(message) {
        const helpEmbed = new MessageEmbed()
                .setTitle('BOT commands')
                .addField('PREFIX'PREFIX)
                .addField('help''BOT commands')
                .addField('ping''Ping BOT')
                .addField('info''BOT information')
                .setColor('9fd8df')
                .setFooter('windows bot' + botInfo.version)
            message.channel.send(helpEmbed);
    }
}

Itu semua kalian bisa copy dan kalian juga bisa perbaiki sesuka kalian


dan kalian ganti dulu ini

const {
    Client,
    MessageEmbed,
    Collection
} = require('discord.js');
const bot = new Client;

const token = 'ODIyNzQ5NjQxMDg2MjA1OTgz.YFWzUA.Ey9ogE-_CjUZ2WPJkkd0XFn10ms';
var PREFIX = 'w/';
var version = '1.16.4';

const fs = require('fs');
const commands = new Collection();
const files = fs.readdirSync('./commands').filter(file => file.endsWith('.js'));
for(const file of files) {
    const command = require(`./commands/${file}`);
    commands.set(command.namecommand)
}

bot.on('ready', () => {
    console.log('Bot sudah online')
});

bot.on('message'message => {
    let args = message.content.substring(PREFIX.length).split(' ');

    switch (args[0]) {
        case 'ping':
            commands.get('ping').execute(message);
            break;   
        case 'info' :
            commands.get('info').execute(messageargs);
            break;
        

        case 'help':
            commands.get('help').execute(message);
            break;
    }
})

bot.login(token);

itu kalian ganti dulu

dan jika ada salah akan kami perbaiki di


bot command part 2


jika kalian salah komen di bawah nanti kami akan perbaiki


link youtube: https://www.youtube.com/watch?v=pAqt39T3HaA

Komentar

Posting Komentar