我正在尝试制作一个不和谐的机器人,但它不起作用

时间:2021-01-06 14:04:26

标签: discord.js

所以我首先想说我对编码真的很陌生,这是我的第一个大项目。 无论如何,我对我的机器人进行了编码,它可以很好地联机,但甚至不会执行我编写的命令。我将发送我已完成的代码以确保我已正确完成。这里是 main.js

main.js


const client = new Discord.Client();

const prefix = '.';

const fs = require('fs');

client.commands = new Discord.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.name, command);
}


client.once('ready', () => {
   console.log('USA is online!');
});

client.on('message', message =>{
    if(!message.content.startsWith(prefix) || message.author.bot) return;
    
    const args = message.content.slice(prefix.length).split(/ +/);
    const command = args.shift().toLowerCase();


    if(command === 'ping'){
       client.command.get('ping').execute(message, args, Discord);
        message.channel.send('pong!')
    }
});

```client.login('My discord token is in here so i wont be sharing this part');




Here is the ping.js command I have in a command folder:


ping.js:


```module.exports = {
    name: 'ping',
    description: "if you ping we shall pong.",
    execute(message, args){
        message.channel.send('pong!');
    }
```}



Here is my problem here:

command.js:


```module.exports = {
    name: 'command',
    description: "Embeds!",
    execute(message, args, Discord) {
        const newEmbed = new Discord.MessageEmbed()
        .setColor('#3B5998')
        .setTitle('Rules')
        .setDescription('Basic Server Rules')
        .addFields(
            {name: 'Rule 1', value: 'No blank Nicknames.'},
            {name: 'Rule 2', value: 'No persons under 13 are allowed in here.'},
            {name: 'Rule 3', value: 'No racist,homophobic,transphobic or disturbing content.'},
            {name: 'Rule 4', value: 'No sexually explicit nicknames.'},
            {name: 'Rule 5', value: 'No blank profile pictures.'},
            {name: 'Rule 6', value: 'No Nicknames with unreadable unicode.'},
            {name: 'Rule 7', value: 'No offensive profile pictures.'},
            {name: 'Rule 8', value: 'Moderators reserve the right to kick or ban if they believe you broke a rule..'},
            {name: 'Notice', value: 'Stay safe'}
        )   
        .setImage('https://www.teahub.io/photos/full/21-216454_usa-flag-america-wallpaper-photos.jpg')
        .setFooter('Stay Safe Online');
    
        message.channel.send(newEmbed);
    
    }

```}

I'd really like some help as it would be really neat to see my first project come to life and just make me feel more competent in my abilities,
I have been learning this off of a youtuber called "Code Lyon".

0 个答案:

没有答案
相关问题