at wrapSafe (internal/modules/cjs/loader.js:1043:16)
at Module._compile (internal/modules/cjs/loader.js:1091:27)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:1160:10)
at Module.load (internal/modules/cjs/loader.js:976:32)
at Function.Module._load (internal/modules/cjs/loader.js:884:14)
at Module.require (internal/modules/cjs/loader.js:1016:19)
at require (internal/modules/cjs/helpers.js:69:18)
at C:\Users\salih\Desktop\JoxArea\bot.js:21:17
at Array.forEach (<anonymous>)
at C:\Users\salih\Desktop\JoxArea\bot.js:20:9
I'm coding a discord bot but the code here gives an error. How can I fix it?
files.forEach(f => {
let props = require(`./komutlar/${f}`);
log(`Yüklenen komut: ${props.help.name}.`);
client.commands.set(props.help.name, props);
props.conf.aliases.forEach(alias => {
client.aliases.set(alias, props.help.name);
});
});
});
Looks like you have an extra });. You only show two opening brackets but show closing three of them.
Related
my code is as following
const Discord = require("discord.js");
const config = require("./Data/config.json");
const intents = new Discord.Intents(32767);
const client = new Discord.Client({ intents });
client.on("ready", () => console.log("Bot is online!"));
client.login(config.token);
and it is returning me this error, may I know what is wrong? Thanks
PS C:\Users\shiyu\Desktop\Programming\Tutorial Bot> node .
C:\Users\shiyu\Desktop\Programming\Tutorial Bot\node_modules\discord.js\src\rest\APIRequest.js:33
agent ??= new https.Agent({ ...this.client.options.http.agent, keepAlive: true });
^^^
SyntaxError: Unexpected token '??='
?[90m at wrapSafe (internal/modules/cjs/loader.js:988:16)?[39m
?[90m at Module._compile (internal/modules/cjs/loader.js:1036:27)?[39m
?[90m at Object.Module._extensions..js (internal/modules/cjs/loader.js:1101:10)?[39m
?[90m at Module.load (internal/modules/cjs/loader.js:937:32)?[39m
?[90m at Function.Module._load (internal/modules/cjs/loader.js:778:12)?[39m
?[90m at Module.require (internal/modules/cjs/loader.js:961:19)?[39m
?[90m at require (internal/modules/cjs/helpers.js:92:18)?[39m
at Object.<anonymous> (C:\Users\shiyu\Desktop\Programming\Tutorial Bot\node_modules\?[4mdiscord.js?[24m\src\rest\RESTManager.js:4:20)
?[90m at Module._compile (internal/modules/cjs/loader.js:1072:14)?[39m
?[90m at Object.Module._extensions..js (internal/modules/cjs/loader.js:1101:10)?[39m
Not sure why this code is not working as I am following a guide. I have checked everything many times and yeah regardless of what I do it returns me an error. The require did find the discord.js module this is for sure.
Upgrade your Node.js. The version you're using does not support the ?? operator.
Discord.js requires (as per their documentation) Node.js 16.6 or newer.
I´m trying to make a help command with Embed but dont works
/home/container/commands/other/help.js:15
const helpEmbed = new MessageEmbed()
^^^^^^^^^
SyntaxError: Unexpected identifier
at wrapSafe (internal/modules/cjs/loader.js:931:16)
at Module._compile (internal/modules/cjs/loader.js:979:27)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:1035:10)
at Module.load (internal/modules/cjs/loader.js:879:32)
at Function.Module._load (internal/modules/cjs/loader.js:724:14)
at Module.require (internal/modules/cjs/loader.js:903:19)
at require (internal/modules/cjs/helpers.js:74:18)
at /home/container/node_modules/require-all/index.js:56:46
at Array.forEach (<anonymous>)
at requireAll (/home/container/node_modules/require-all/index.js:34:9)
This is the code
Basically you are using the Embed inside nothing. Your module.exports should look similiar to this:
module.exports = class extends Command {
constructor(...args) {
super(...args, {
description: 'Testing.',
category: "Information",
});
}
async run(message, args) {
const helpEmbed...
}
}
The code example above is from my command handler so yours could be a little different, but you need a start point like run or execute.
i need help with this
SyntaxError: Identifier 'embed' has already been declared
When i try to make
if (owner && msg.author.id !== 725959811434414091) return;
than i create a embed with using let embed = new Discord.RichEmbed()
it say
^
SyntaxError: Identifier 'embed' has already been declared
at wrapSafe (internal/modules/cjs/loader.js:1047:16)
at Module._compile (internal/modules/cjs/loader.js:1097:27)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:1153:10)
at Module.load (internal/modules/cjs/loader.js:977:32)
at Function.Module._load (internal/modules/cjs/loader.js:877:14)
at Module.require (internal/modules/cjs/loader.js:1019:19)
at require (internal/modules/cjs/helpers.js:77:18)
at C:\Users\serveradmin\Desktop\backup\node_modules\require-all\index.js:52:46
at Array.forEach (<anonymous>)
at requireAll (C:\Users\serveradmin\Desktop\backup\node_modules\require-all\index.js:34:9
You should try to rename your variable embed to something else, as this name seems to already be used higher in your file.
If you can't, or don't want to, simply press Ctrl and F at the same time on your code editor, and search for all occurrences of embed, to find out where the other declaration was made.
I have searched all over but have not figured out what I am doing wrong. I am trying to set up mocha for testing node.js javascript application files. I have node installed and have successfully ran basic things on it to confirm it is working.
I installed mocha in my project file, and also have a Makefile and a file called "test" within my project file as well.
Here is the error my terminal(osx 10) is spitting out when I run the command "make test".
humbleMousesMBP:chapter02 humbleMouse$ make test
/Users/humbleMouse/chapter02/test/exchange.test.js:22

^
SyntaxError: Unexpected token ILLEGAL
at Module._compile (module.js:439:25)
at Object.Module._extensions..js (module.js:474:10)
at Module.load (module.js:356:32)
at Function.Module._load (module.js:312:12)
at Module.require (module.js:364:17)
at require (module.js:380:17)
at /Users/humbleMouse/chapter02/node_modules/mocha/bin/_mocha:313:27
at Array.forEach (native)
at load (/Users/humbleMouse/chapter02/node_modules/mocha/bin/_mocha:310:9)
at Object.<anonymous> (/Users/humbleMouse/chapter02/node_modules/mocha /bin/_mocha:301:1)
at Module._compile (module.js:456:26)
at Object.Module._extensions..js (module.js:474:10)
at Module.load (module.js:356:32)
at Function.Module._load (module.js:312:12)
at Function.Module.runMain (module.js:497:10)
at startup (node.js:119:16)
at node.js:906:3
make: *** [test] Error 8
This is the test I am trying to run:
'use strict';
var assert = require('assert')
, should = require('should');
var exchangeData = {};
suite('exchange', function() {
test('buy should add a BUY nockmarket order', function(done) {
exchangeData = exchange.buy(40, 100, exchangeData);
exchangeData.buys.volumes[40].should.eql(100);
done();
});
test('sell should add a SELL nockmarket order', function(done) {
exchangeData = exchange.sell(41, 200, exchangeData);
exchangeData.sells.volumes['41'].should.eql(200); //this is line 22
done();
});

test('sell should produce trades', function(done) {
exchangeData = exchange.sell(40, 75, exchangeData);
exchangeData.trades[0].price.should.eql(40);
exchangeData.trades[0].volume.should.eql(75);
exchangeData.buys.volumes[40].should.eql(25);
exchangeData.sells.volumes[41].should.eql(200);
done();
});
});
There are some invalid characters in your code, if you used proper text editor, you'd see them. The line numbering is a bit off, but this is clearly the cause.
Here's a screenshot from Sublime Text:
It's \uFFFC, more info here.
Just delete them (they can't be seen, so delete all from the semicolon to the next test().
I have an issue with exporting a module in Node.js.
Here is a part of my code:
var zmq = require('zmq');
var module = require('module');
var DeviceRequester = function(port, name)
{
...
};
var SMValueGetter = function(socket)
{
...
};
module.exports.DeviceRequester = DeviceRequester;
module.exports.SMValueGetter = SMValueGetter;
When I use it I get the following error:
module.exports.DeviceRequester = DeviceRequester;
^
TypeError: Cannot set property 'DeviceRequester' of undefined
at Object.<anonymous> (<PROJECT_PATH>/node_modules/lse/lib/lse.js:168:32)
at Module._compile (module.js:456:26)
at Object.Module._extensions..js (module.js:474:10)
at Module.load (module.js:356:32)
at Function.Module._load (module.js:312:12)
at Module.require (module.js:364:17)
at require (module.js:380:17)
at Object.<anonymous> (<PROJECT_PATH>/server.js:6:13)
at Module._compile (module.js:456:26)
at Object.Module._extensions..js (module.js:474:10)
I have no idea why it occurs. I've red the Node.js documentation and some tutorials about exporting modules and all of them do it that way. Am I overlooking something?
Give more attentions at errors
TypeError: Cannot set property 'DeviceRequester' of undefined
at line var module=require("module"); you are overwriting the default module variable.
simple try to change at something that makes more sense, such as
var MyModule=require(..path..)