简体   繁体   English

我正在尝试将带有前缀的命令 output 执行到带有 discord.js 的控制台中

[英]I'm attempting to output the command that was executed with a prefix into console with discord.js

I'm using this code snippet from the Jinx Selfbot from Github which I slightly modified to this template from the Discord Auto Reply index.js我正在使用来自 Github 的Jinx Selfbot中的代码片段,我对来自Discord 自动回复index.js 的模板进行了轻微修改

bot.on('message', async(msg)=>{
    let cmd = msg.content.split(" ")[0]
    cmd = cmd.slice(settings.prefix.length);
    let args = msg.content.split(" ").slice(1);
     if(msg.content.startsWith(${PREFIX}) && msg.author.id === settings.ID){
        console.log(cyan(`[COMMAND RAN] :: ${message}`));

and it keeps outputting this into command prompt when run with node.js当使用 node.js 运行时,它会一直将其输出到命令提示符中

     if(msg.content.startsWith(${PREFIX}) && msg.author.id === settings.ID){
                               ^

SyntaxError: missing ) after argument list
[90m    at wrapSafe (internal/modules/cjs/loader.js:1152:16)[39m
[90m    at Module._compile (internal/modules/cjs/loader.js:1200:27)[39m
[90m    at Object.Module._extensions..js (internal/modules/cjs/loader.js:1257:10)[39m
[90m    at Module.load (internal/modules/cjs/loader.js:1085:32)[39m
[90m    at Function.Module._load (internal/modules/cjs/loader.js:950:14)[39m
[90m    at Function.executeUserEntryPoint [as runMain] (internal/modules/run_main.js:60:12)[39m
[90m    at internal/main/run_main_module.js:17:47[39m

Edit: I forgot to put in the original code snippet from the Jinx Selfbot编辑:我忘了输入 Jinx Selfbot 的原始代码片段

bot.on('message', async(msg)=>{
    if(msg.author.id !== settings.ID) {
        return;
    }
    let cmd = msg.content.split(" ")[0]
    cmd = cmd.slice(settings.prefix.length);
    let args = msg.content.split(" ").slice(1);
    if(msg.content.startsWith(settings.prefix) && msg.author.id === settings.ID){
        console.log(cyan(`[COMMAND RAN] :: ${msg.content}`));

As @Taplar said - ${} is reserved to template literals .正如@Taplar 所说 - ${}保留给模板文字 If you want to access a variable outside of them, use its' name without any additional symbols.如果你想访问它们之外的变量,使用它的名字而不需要任何额外的符号。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM