SyntaxError: Unexpected identifier Embed Message Discord.js - javascript

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.

Related

Discord bot does not run

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.

Cypress Task: The plugins file is missing or invalid

When I added my custom task I started getting some errors and I'm not sure how to solve it. I was following the example from RWA: https://github.com/cypress-io/cypress-realworld-app/blob/develop/cypress/plugins/index.ts
cypress/plugins/index.js
import axios from "axios";
import { percyHealthCheck } from "#percy/cypress/task";
import { bookingCancel } from "../../server/api/booking-controller";
export default (on, config) => {
on("task", {
percyHealthCheck,
async "booking:cancel"(user, bookingId, options) {
const response = await axios({
baseURL: Cypress.env("apiUrl"),
...bookingCancel(user, bookingId, options),
});
return response;
},
});
return config;
};
My errors:
Error: The plugins file is missing or invalid.
Your `pluginsFile` is set to `/cypress/plugins/index.js`, but either the file is missing, it contains a syntax error, or threw an error when required. The `pluginsFile` must be a `.js`, `.ts`, or `.coffee` file.
Or you might have renamed the extension of your `pluginsFile`. If that's the case, restart the test runner.
Please fix this, or set `pluginsFile` to `false` if a plugins file is not necessary for your project.
at Object.get (/Users/nikomel/Library/Caches/Cypress/5.5.0/Cypress.app/Contents/Resources/app/packages/server/lib/errors.js:968:15)
at EventEmitter.<anonymous> (/Users/nikomel/Library/Caches/Cypress/5.5.0/Cypress.app/Contents/Resources/app/packages/server/lib/plugins/index.js:144:21)
at EventEmitter.emit (events.js:310:20)
at ChildProcess.<anonymous> (/Users/nikomel/Library/Caches/Cypress/5.5.0/Cypress.app/Contents/Resources/app/packages/server/lib/plugins/util.js:19:22)
at ChildProcess.emit (events.js:310:20)
at emit (internal/child_process.js:876:12)
at processTicksAndRejections (internal/process/task_queues.js:85:21)
/cypress/plugins/index.js:1
import { percyHealthCheck } from "#percy/cypress/task";
^^^^^^
SyntaxError: Cannot use import statement outside a module
at wrapSafe (internal/modules/cjs/loader.js:1051:16)
at Module._compile (internal/modules/cjs/loader.js:1101:27)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:1166:10)
at Module.load (internal/modules/cjs/loader.js:981:32)
at Module._load (internal/modules/cjs/loader.js:881:14)
at Function.Module._load (electron/js2c/asar.js:769:28)
at Module.require (internal/modules/cjs/loader.js:1023:19)
at require (internal/modules/cjs/helpers.js:77:18)
at runPlugins (/Users/nikomel/Library/Caches/Cypress/5.5.0/Cypress.app/Contents/Resources/app/packages/server/lib/plugins/child/run_plugins.js:213:15)
at Object.<anonymous> (/Users/nikomel/Library/Caches/Cypress/5.5.0/Cypress.app/Contents/Resources/app/packages/server/lib/plugins/child/index.js:8:25)
at Module._compile (internal/modules/cjs/loader.js:1145:30)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:1166:10)
at Module.load (internal/modules/cjs/loader.js:981:32)
at Module._load (internal/modules/cjs/loader.js:881:14)
at Function.Module._load (electron/js2c/asar.js:769:28)
at Function.executeUserEntryPoint [as runMain] (internal/modules/run_main.js:74:12)
NOTE: I verified that pluginsFile has the correct path and I even tried explicitly provide the path to the file and it didn't resolve the problem.
Looks like you might have a stray comma in your fourth to last line
});
return response;
}, <------------------ here
});
return config;
};
I got the same error, I had forgotten to execute the following code:
npm install --save-dev cypress-cucumber-preprocessor

SyntaxError: Identifier 'embed' has already been declared

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.

SyntaxError: Unexpected end of input Discord Bot

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.

Syntax Error while using Aysnc/Await in Node.js

I am relatively new to Node.js I have ran myself into an error the code is:
async function loadingOneImage(file){
........
}
async function generateDataset() {
const {image, target} = await loadingOneImage(file)
}
generateDataset();
The structure of the code can be seen above. I have a function generateDataset() that is being called initially. Inside generateDataset() another function loadingOneImage() is being called. But once I run the program I run myself into the following error:
/home/nauyan/Desktop/EsperSolutions/TensorFlow.js/tfjs-examples/simple-object-detection/dataprep.js:85
const {image, target} = await loadingOneImage(file)
^^^^^
SyntaxError: await is only valid in async function
at Module._compile (internal/modules/cjs/loader.js:721:23)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:787:10)
at Module.load (internal/modules/cjs/loader.js:653:32)
at tryModuleLoad (internal/modules/cjs/loader.js:593:12)
at Function.Module._load (internal/modules/cjs/loader.js:585:3)
at Function.Module.runMain (internal/modules/cjs/loader.js:829:12)
at startup (internal/bootstrap/node.js:283:19)
at bootstrapNodeJSCore (internal/bootstrap/node.js:622:3)
Can someone please advise me regarding this problem.

Categories