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.
Related
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.
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.
Here is my stack trace when attempting to launch my api side of my react - web app.
I have ran into this error multiple times but never seem to be able to fix it when it comes up again!
/Users/joshua_paulsen/Desktop/Jump-In-Final/api/node_modules/pouchdb-core/lib/index.js:1285
throw new Error('Invalid Adapter: ' + opts.adapter);
^
Error: Invalid Adapter: undefined
at new PouchDB (/Users/joshua_paulsen/Desktop/Jump-In-Final/api/node_modules/pouchdb-core/lib/index.js:1285:11)
at Object.<anonymous> (/Users/joshua_paulsen/Desktop/Jump-In-Final/api/dal.js:18:12)
at Module._compile (internal/modules/cjs/loader.js:689:30)
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 Module.require (internal/modules/cjs/loader.js:637:17)
at require (internal/modules/cjs/helpers.js:20:18)
at Object.<anonymous> (/Users/joshua_paulsen/Desktop/Jump-In-Final/api/routes/workouts/index.js:8:5)
I had my db defined like this - const db = new PouchDB(
${process.env.COUCH_HOSTNAME}${process.env.COUCH_DBNAME}
)
the fix ended up being changing it to this.
var pouch = new PouchDB(${process.env.COUCH_DBNAME}, { adapter: "http" })
I'm just trying to test Hapi.js and, whatever I code, I got this error :
node_modules/hapi/lib/server.js:145
Items.serial(this.connections, (connectionItem, next) => {
^
SyntaxError: missing ) after argument list
at exports.runInThisContext (vm.js:53:16)
at Module._compile (module.js:413:25)
at Object.Module._extensions..js (module.js:448:10)
at Module.load (module.js:355:32)
at Function.Module._load (module.js:310:12)
at Module.require (module.js:365:17)
at require (module.js:384:17)
at Object.<anonymous> (/Users/gilles/exo1/node_modules/hapi/lib/index.js:5:16)
at Module._compile (module.js:430:26)
at Object.Module._extensions..js (module.js:448:10)
Where does come form this syntax ...() => {... to make a function ?
What I did bad to use Hapi ?
Thank you very much
The syntax is called Arrow function. You use hapi 10 or later which requires node 4+, but you have an older version of node which doesn't support arrow functions yet. The solution is to upgrade your node version to 4 or 5.
If I try to create a bitpay client in node after npm install bitpay and feeding it my on bitpay.com generated api key.
var client = BitPay.createClient('apikey');
I get:
assert.js:92 throw new assert.AssertionError({
AssertionError: Not enough entropy. Minimum is: 192 bits
at new HmacDRBG (/home/enigma/WebstormProjects/expensereports/node_modules/bitpay/node_modules/bitauth/node_modules/elliptic/lib/elliptic/hmac-drbg.js:24:3)
at EC.sign (/home/enigma/WebstormProjects/expensereports/node_modules/bitpay/node_modules/bitauth/node_modules/elliptic/lib/elliptic/ec/index.js:94:14)
at Object.BitAuth.sign (/home/enigma/WebstormProjects/expensereports/node_modules/bitpay/node_modules/bitauth/lib/bitauth.js:101:25)
at RESTClient._sendRequest (/home/enigma/WebstormProjects/expensereports/node_modules/bitpay/lib/rest-client.js:156:46)
at RESTClient.get (/home/enigma/WebstormProjects/expensereports/node_modules/bitpay/lib/rest-client.js:282:28)
at RESTClient._getAccessTokens (/home/enigma/WebstormProjects/expensereports/node_modules/bitpay/lib/rest-client.js:81:19)
at new RESTClient (/home/enigma/WebstormProjects/expensereports/node_modules/bitpay/lib/rest-client.js:51:17)
at Object.module.exports.createClient (/home/enigma/WebstormProjects/expensereports/node_modules/bitpay/index.js:10:12)
at Object.<anonymous> (/home/enigma/WebstormProjects/expensereports/server/api/btc/btc.controller.js:6:21)
at Module._compile (module.js:456:26)
if I try the website provided way:
$ npm install bitpay
var BitPay = require('bitpay');
var client = new BitPay('apikey');
client.on('ready', function() {
client.post('invoices', { price: 10.00, currency: 'USD' });
});
it complains
var client = new BitPay('apikey'
TypeError: object is not a function
at Object.<anonymous> (/home/enigma/WebstormProjects/expensereports/server/api/btc/btc.controller.js:6:14)
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> (/home/enigma/WebstormProjects/expensereports/server/api/btc/index.js:4:18)
at Module._compile (module.js:456:26)
at Object.Module._extensions..js (module.js:474:10)
I also tried a couple of other ways non of them worked so my question how am I supposed to connect to this service?
If I use bitpay keygen to create a api.key file locally. How could I set this in my settings on bitpay.com to avoid {“error”: “Invalid token”}?
There's a realistic possibility this API token is invalid. The 1st error message displayed means the API token's length is way too short and therefore invalid. Please verify you entered the correct API keys and enter it as a string. Are you sure you didn't remove the first character of the token when copying and pasting? Are you sure you didn't pick the wrong token? Example:
var client = new BitPay('MY_192_BIT_HUGE_API_TOKEN'); //192 bit string
Best regards,