【问题标题】:discord.js - Stupid errors in one commanddiscord.js - 一个命令中的愚蠢错误
【发布时间】:2018-03-25 21:55:38
【问题描述】:

最近我通过 NodeJS 安装了 discord.js-music。发出命令并执行机器人后,我收到此错误:

});
 ^

SyntaxError: Unexpected token )

所以,从逻辑上讲,我删除了“)”,即使我知道它是必需的,我得到这个错误:

});
 ^

SyntaxError: Unexpected token )

我的代码是:

const Client = require('discord.js').Client;
const music = require('discord.js-music');

class Music extends patron.Command {
    constructor() {
        super({
            names: ['play'],
            groupName: 'general',
            description: 'joins your voice channel and plays the requested music.',
            args: [
                new patron.Argument({
                    name: 'message',
                    key: 'message',
                    type: 'message',
                    example: 'https://www.youtube.com/watch?v=DArzZ3RvejU',
                    defaultValue: patron.ArgumentDefault.message,
                    remainder: true
                })
            ]
        });
    };

    async run(msg, args) {
        if (String.isNullOrWhiteSpace(args.command)) {
            await msg.reply('you didn\'t specify the URL or search for music to play.')
            music(client);

        }
    }

【问题讨论】:

  • 我看到两件事 - 你有一个带引号的右括号(代码的倒数第二行),而右括号太少。所以你需要取消引用,并在最后添加另一个。
  • @theGleep 你是怎么读到这篇文章的? ;)
  • 你知道错误指向的行吗?请注意,您可以在编辑问题时使用 {} 按钮格式化代码块,现在的格式有点奇怪。我假设这两个
    标签不是错误消息的一部分?
  • 将代码复制到剪贴板,在“你的答案”框中,我点击了“代码”按钮 - 在“图片”按钮之后。粘贴到“javascript”部分并点击“tidy”。
  • @Confuzing 是的,BR 标签是错误的:/

标签: javascript node.js syntax discord discord.js


【解决方案1】:

检查您的代码,在异步运行函数部分的第二部分中缺少右花括号 }。

【讨论】:

  • 代码中缺少字符是关闭问题为“简单印刷错误”的原因
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2020-09-03
  • 2015-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多