Discord.js error '.addChoice' is not a function - discord.js

i have some Problems with my Code that somehow none of my friends have ...
Some Code to see:
module.exports = {
data: new SlashCommandBuilder()
.setName('equipment')
.setDescription('Gives you Information about specific Equipments')
.addStringOption(option =>
option.setName('type')
.setDescription('Specify the Equipment')
.setRequired(true)
.addChoice('Flashlight', 'flashlight')
),
...
The Code is Cut here because its not necesery for it above to work.
My Error Code:
PS C:\Users\enric\Desktop\Ghosty Phasmo Help> node .
C:\Users\enric\Desktop\Ghosty Phasmo Help\commands\phasmo\equipment.js:15
.addChoice('Flashlight', 'flashlight')
^
TypeError: option.setName(...).setDescription(...).setRequired(...).addChoice is not a function
at C:\Users\enric\Desktop\Ghosty Phasmo Help\commands\phasmo\equipment.js:15:18
at MixedClass._sharedAddOptionMethod (C:\Users\enric\Desktop\Ghosty Phasmo Help\node_modules\#discordjs\builders\dist\index.js:1334:50)
at MixedClass.addStringOption (C:\Users\enric\Desktop\Ghosty Phasmo Help\node_modules\#discordjs\builders\dist\index.js:1323:17)
at Object.<anonymous> (C:\Users\enric\Desktop\Ghosty Phasmo Help\commands\phasmo\equipment.js:11:7)
at Module._compile (node:internal/modules/cjs/loader:1103:14)
at Object.Module._extensions..js (node:internal/modules/cjs/loader:1157:10)
at Module.load (node:internal/modules/cjs/loader:981:32)
at Function.Module._load (node:internal/modules/cjs/loader:822:12)
at Module.require (node:internal/modules/cjs/loader:1005:19)
at require (node:internal/modules/cjs/helpers:102:18)
Somehow my Discord.js thinks that im using a Function. I copied the Code from other friends where this completely work. but somehow the same Error message appears.

.addChoice() is outdated. Now, there is only .addChoices() (with an s)
.addStringOption(option =>
option.setName('type')
.setDescription('Specify the Equipment')
.setRequired(true)
.addChoices({
name: 'Flashlight',
value: 'flashlight'
})
)

Related

TypeError: Cannot read properties of undefined (reading 'set') (discord.js)

Im trying to make a discord music bot and i have to admit that i dont have much knowledge on javascript so im just following a tutorial. Now this is the code he wrote
const slashFiles = fs.readdirSync("./slash").filter(file => file.endsWith(".js"))
for (const file of slashFiles){
const slashcmd = require(`./slash/${file}`)
client.toLocaleLowerCase.set(slashcmd.data.name, slashcmd)
if (LOAD_SLASH) commands.push(slashcmd.data.toJSON())
}
and thats the error im getting
client.toLocaleLowerCase.set(slashcmd.data.name, slashcmd)
^
TypeError: Cannot read properties of undefined (reading 'set')
at Object.<anonymous> (C:\Users\stelj\Desktop\bot\main.js:31:30)
at Module._compile (node:internal/modules/cjs/loader:1103:14)
at Object.Module._extensions..js (node:internal/modules/cjs/loader:1157:10)
at Module.load (node:internal/modules/cjs/loader:981:32)
at Function.Module._load (node:internal/modules/cjs/loader:822:12)
at Function.executeUserEntryPoint [as runMain] (node:internal/modules/run_main:77:12)
at node:internal/main/run_main_module:17:47
Pls help

node:internal/modules/cjs/loader:936 Eror

I'm getting this error:
I tried to install Npm again, if anyone comes across I would be happy to help
node:internal/modules/cjs/loader:936
throw err;
^
at Module.load (node:internal/modules/cjs/loader:981:32)
at Function.Module._load (node:internal/modules/cjs/loader:822:12)
at Module.require (node:internal/modules/cjs/loader:1005:19) {
code: 'MODULE_NOT_FOUND',
requireStack: [
'C:\\Users\\yehon\\OneDrive\\שולחן העבודה\\yehonatan\\Work_projects\\Manhattan-client-13-03-2022_v2\\config\\paths.js',
'C:\\Users\\yehon\\OneDrive\\שולחן העבודה\\yehonatan\\Work_projects\\Manhattan-client-13-03-2022_v2\\config\\env.js',
'C:\\Users\\yehon\\OneDrive\\שולחן העבודה\\yehonatan\\Work_projects\\Manhattan-client-13-03-2022_v2\\scripts\\start.js'
]
}

npm start command giving cannot find module 'isexe' error

C:\Users\bahub\Documents\React-Projects\contact-manager-app>npm start
contact-manager-app#0.1.0 start
react-scripts start
node:internal/modules/cjs/loader:936
throw err;
^
Error: Cannot find module 'isexe'
Require stack:
C:\Users\bahub\Documents\React-Projects\contact-manager-app\node_modules\which\which.js
C:\Users\bahub\Documents\React-Projects\contact-manager-app\node_modules\cross-spawn\lib\util\resolveCommand.js
C:\Users\bahub\Documents\React-Projects\contact-manager-app\node_modules\cross-spawn\lib\parse.js
C:\Users\bahub\Documents\React-Projects\contact-manager-app\node_modules\cross-spawn\index.js
C:\Users\bahub\Documents\React-Projects\contact-manager-app\node_modules\react-dev-utils\crossSpawn.js
C:\Users\bahub\Documents\React-Projects\contact-manager-app\node_modules\react-scripts\bin\react-scripts.js
at Function.Module._resolveFilename (node:internal/modules/cjs/loader:933:15)
at Function.Module._load (node:internal/modules/cjs/loader:778:27)
at Module.require (node:internal/modules/cjs/loader:1005:19)
at require (node:internal/modules/cjs/helpers:102:18)
at Object. (C:\Users\bahub\Documents\React-Projects\contact-manager-app\node_modules\which\which.js:10:13)
at Module._compile (node:internal/modules/cjs/loader:1101:14)
at Object.Module._extensions..js (node:internal/modules/cjs/loader:1153:10)
at Module.load (node:internal/modules/cjs/loader:981:32)
at Function.Module._load (node:internal/modules/cjs/loader:822:12)
at Module.require (node:internal/modules/cjs/loader:1005:19) {
code: 'MODULE_NOT_FOUND',
requireStack: [
'C:\Users\bahub\Documents\React-Projects\contact-manager-app\node_modules\which\which.js',
'C:\Users\bahub\Documents\React-Projects\contact-manager-app\node_modules\cross-spawn\lib\util\resolveCommand.js',
'C:\Users\bahub\Documents\React-Projects\contact-manager-app\node_modules\cross-spawn\lib\parse.js',
'C:\Users\bahub\Documents\React-Projects\contact-manager-app\node_modules\cross-spawn\index.js',
'C:\Users\bahub\Documents\React-Projects\contact-manager-app\node_modules\react-dev-utils\crossSpawn.js',
'C:\Users\bahub\Documents\React-Projects\contact-manager-app\node_modules\react-scripts\bin\react-scripts.js'
]
}

"Discord is not refined"

I am very new to coding and I tried coding my own discord bot and I got the "discord is not refined" in command prompt. I am currently just trying to turn on the bot to see if it works, anyways here is the code
const Discord = require("discord.js");
const client = new Discord.Client();
client.once('ready'), () => {
console.log('HelloMyFriend is online!');
};
client.login('<token>');
stack trace
events.js:131
throw new ERR_INVALID_ARG_TYPE('listener', 'Function', listener);
^
TypeError [ERR_INVALID_ARG_TYPE]: The "listener" argument must be of type function. Received undefined
←[90m at checkListener (events.js:131:11)←[39m
←[90m at Client.once (events.js:496:3)←[39m
at Object.<anonymous> (C:\Users\jamie\Desktop\DiscordBot\main.js:7:8)
←[90m at Module._compile (internal/modules/cjs/loader.js:1068:30)←[39m
←[90m at Object.Module._extensions..js (internal/modules/cjs/loader.js:1097:10)←[39m
←[90m at Module.load (internal/modules/cjs/loader.js:933:32)←[39m
←[90m at Function.Module._load (internal/modules/cjs/loader.js:774:14)←[39m
←[90m at Function.executeUserEntryPoint [as runMain] (internal/modules/run_main.js:72:12)←[39m
←[90m at internal/main/run_main_module.js:17:47←[39m {
code: ←[32m'ERR_INVALID_ARG_TYPE'←[39m
}
The first event on ready is wrong. You shouldn't be closing the parentheses after the 'ready'.
You should also use on instead of once.
client.on('ready', () => {
console.log('HelloMyFriend is online!');
});
To overcome this error you can replace your ready event with the following:
client.once('ready', () => {
console.log('HelloMyFriend is online!');
});
I would also recommend an .env file to protect the token of the bot. Once it becomes public, it should be generated again in the Discord Developer Portal to prevent possible hijacking of the bot.

Protractor- getText() showing error in async/await

Failing to perform getText() and use in expect condition using async/await. Following is the it block
it('Apply permission to a folder', async () => {
await docsHomePage.clickProject();
await projectsPage.projectCreateNewFolderAndSelect("AutoProject");
await projectsPage.uploadFile('Aug2017.pdf');
//uploadMessageElement = await projectsPage.getFileUploadSuccessMessage();
let uploadMessageText = element(by.id('projects-upload-success-new'));
expect(await uploadMessageText.getText()).toEqual('1 new Document created sucessfully');
await projectsPage.clickFileUploadSuccessCloseButton();
});
Getting the following error:
2) Non Angular CLM Page Apply permission to a folder
Message:
Failed: script timeout
(Session info: chrome=79.0.3945.117)
Stack:
ScriptTimeoutError: script timeout
(Session info: chrome=79.0.3945.117)
at Object.throwDecodedError
(C:\Users\sagar.ladwa\AppData\Roaming\npm\node_modules\protractor\node_modules\selenium- webdriver\lib\error.js:514:15)
at parseHttpResponse (C:\Users\sagar.ladwa\AppData\Roaming\npm\node_modules\protractor\node_modules\selenium-webdriver\lib\http.js:519:13)
at doSend.then.response (C:\Users\sagar.ladwa\AppData\Roaming\npm\node_modules\protractor\node_modules\selenium-webdriver\lib\http.js:441:30)
at process._tickCallback (internal/process/next_tick.js:68:7)Error
at ElementArrayFinder.applyAction_ (C:\Users\sagar.ladwa\AppData\Roaming\npm\node_modules\protractor\built\element.js:459:27)
at ElementArrayFinder.(anonymous function).args [as getText] (C:\Users\sagar.ladwa\AppData\Roaming\npm\node_modules\protractor\built\element.js:91:29)
at ElementFinder.(anonymous function).args [as getText] (C:\Users\sagar.ladwa\AppData\Roaming\npm\node_modules\protractor\built\element.js:831:22)
at UserContext.it (C:\Users\sagar.ladwa\Downloads\protractor-initial-project-master\protractor-initial-project-master\specs\user-groups-permission.js:57:45)
at process._tickCallback (internal/process/next_tick.js:68:7)
From asynchronous test:
Error
at Suite.describe (C:\Users\sagar.ladwa\Downloads\protractor-initial-project-master\protractor-initial-project-master\specs\user-groups-permission.js:49:5)
at Object.<anonymous> (C:\Users\sagar.ladwa\Downloads\protractor-initial-project-master\protractor-initial-project-master\specs\user-groups-permission.js:7:1)
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)
Getting similar issue when we tried to create a page-object.
It's your console.log which is causing the issue. If you want to print the text you will need to await uploadMessageText.getText() there also.
This will likely be easier for you
let uploadMessageText = await element(by.id('projects-upload-success-new')).getText()
console.log('-----------------------------------'+uploadMessageText);
expect(uploadMessageText).toEqual('1 new Document created sucessfully');

Resources