Gal*_*ksy 8 javascript node.js discord
当我进行嵌入并运行机器人时,这里出现问题,因为我使用了let EmbedHelp = Discord.RichEmbed此问题出现在终端中,请输入问题以及我需要修复的内容:
SyntaxError: Lexical declaration cannot appear in a single-statement context
at new Script (vm.js:79:7)
at createScript (vm.js:251:10)
at Object.runInThisContext (vm.js:303:10)
at Module._compile (internal/modules/cjs/loader.js:657:28)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:700:10)
at Module.load (internal/modules/cjs/loader.js:599:32)
at tryModuleLoad (internal/modules/cjs/loader.js:538:12)
at Function.Module._load (internal/modules/cjs/loader.js:530:3)
at Function.Module.runMain (internal/modules/cjs/loader.js:742:12)
at startup (internal/bootstrap/node.js:283:19)
Run Code Online (Sandbox Code Playgroud)
我用于嵌入的代码是:
client.on('message', message => {
if (message.startsWith('$Commands'))
let EmbedHelp = Discord.RichEmbed()
"title": "title ~~(did you know you can have markdown here too?)~~",
"description": "```",
"url": "https://discordapp.com",
"color": 192748,
"timestamp": "Timezone - GGT 3+",
"footer": {
"icon_url": "https://cdn.discordapp.com/avatars/563449221701959700/8386d5fe48d71898c40244e7a5a66d58.png",
"text": "footer text"
},
"thumbnail": {
"url": "https://cdn.discordapp.com/avatars/563449221701959700/8386d5fe48d71898c40244e7a5a66d58.png"
},
"image": {
"url": "https://cdn.discordapp.com/embed/avatars/0.png"
},
"author": {
"name": "Galak$y#3038",
"url": "https://discordapp.com",
"icon_url": "https://discordapp.com/channels/564059839320555540/569179399211974666"
},
}
});
channel.send({EmbedHelp})
Run Code Online (Sandbox Code Playgroud)
该错误指的是下面的行Discord.RichEmbed()。您有一个对象属性声明,但看不到任何对象。看起来你混淆了一些你试图从 Discord 文档中提取的内容。
RichEmbed旨在与其他辅助方法链接。如果您将代码放入一个对象中(将其用大括号括起来{})并将其传递给一个send方法,它应该会消除该错误。
client.on('message', (message) => {
if (message.startsWith('$Commands')) {
message.channel.send({
embed: {
title: 'title ~~(did you know you can have markdown here too?)~~',
description: '```',
url: 'https://discordapp.com',
color: 192748,
timestamp: 'Timezone - GGT 3+',
footer: {
icon_url:
'https://cdn.discordapp.com/avatars/563449221701959700/8386d5fe48d71898c40244e7a5a66d58.png',
text: 'footer text',
},
thumbnail: {
url: 'https://cdn.discordapp.com/avatars/563449221701959700/8386d5fe48d71898c40244e7a5a66d58.png',
},
image: {
url: 'https://cdn.discordapp.com/embed/avatars/0.png',
},
author: {
name: 'Galak$y#3038',
url: 'https://discordapp.com',
icon_url:
'https://discordapp.com/channels/564059839320555540/569179399211974666',
},
},
});
}
});
Run Code Online (Sandbox Code Playgroud)
我有以下代码:
let viewShareSelectBoxInitializedInterval = setInterval(function () {
if (IsViewShareSelectBoxInitialized() === true) {
clearInterval(viewShareSelectBoxInitializedInterval);
ReloadViewShareItems(endItemStateIdForSharing);
}
}, 250);
Run Code Online (Sandbox Code Playgroud)
我将其更改let为var然后它工作正常。
在我的本地开发机器上,它可以与 一起使用let,但是当 JavaScript 与 using 捆绑在一起时,let它就会失败。
| 归档时间: |
|
| 查看次数: |
61987 次 |
| 最近记录: |