首页 > 解决方案 > 需要帮助找到我哪里出错了 DiscordJS

问题描述

与机器人混在一起没有任何 javascript 经验,所以我无法发现我出错的地方,它说的是意外的令牌并指向)最后我猜这不是问题,而是其他问题

const Discord = require('discord.js');
const client = new Discord.Client();

const {
    prefix,
    token
} = require('./config.json');

client.once('ready', () => {
    console.log('Online');
});

client.on('message', message => {

            const args = message.content.slice(prefix.length).trim().split(' ');
            const command = args.shift().toLowerCase();
            if (!message.content.startsWith(prefix) || message.author.bot) return;

            else if (command === 'bargun') {
                message.channel.send('bargun number one siege player I get wet when I hear his name');
            } else if (command === 'siege') {
                message.channel.send('Siege is Shit Game');
            } else if (command === 'shaiiko') {
                message.channel.send('Shaiiko is the coolest guy ever i want to be him')
            } else if (command === 'kruzty') {
                message.channel.send('Kruzty is a bitch');

            } else if (command === 'cunt') {
                if (!args.length) {
                    return message.channel.send(`${message.author} is a cunt`);
                    message.channel.send(`${command}\n${args} is a cunt.`);
                };



            }); client.login(token);

标签: javascript

解决方案


const Discord = require('discord.js');
const client = new Discord.Client();

const {
    prefix,
    token
} = require('./config.json');

client.once('ready', () => {
    console.log('Online');
});

client.on('message', message => {

            const args = message.content.slice(prefix.length).trim().split(' ');
            const command = args.shift().toLowerCase();
            if (!message.content.startsWith(prefix) || message.author.bot) return;

            else if (command === 'bargun') {
                message.channel.send('bargun number one siege player I get wet when I hear his name');
            } else if (command === 'siege') {
                message.channel.send('Siege is Shit Game');
            } else if (command === 'shaiiko') {
                message.channel.send('Shaiiko is the coolest guy ever i want to be him')
            } else if (command === 'kruzty') {
                message.channel.send('Kruzty is a bitch');

            } else if (command === 'cunt') {
                if (!args.length) {
                    return message.channel.send(`${message.author} is a cunt`);
                    message.channel.send(`${command}\n${args} is a cunt.`);
                };
            }


            }); 
client.login(token);

你在最后一个“else if”语句之后缺少一个'}'。这应该工作


推荐阅读