#An error i don't know how to fix..

90 messages ยท Page 1 of 1 (latest)

dense needle
#

display your folder structure

thorny drift
#

u mean this?:

thorny drift
dense needle
#

nah that is fine

#

src/commands doesn't exist

#

your path should be ../commands/order.js etc in your index.js

thorny drift
#

like this?

#

import rolesCommand from '../command/roles.js';

dense needle
#

๐Ÿ‘

thorny drift
#

stil doesnt wiork

dense needle
#

commands

#

you missed the s

thorny drift
#

ohh

#

SyntaxError: The requested module '../commands/order.js' does not provide an export named 'default'

thorny drift
#

import orderCommand from '../commands/order.js';

#

is the problem

#

the problem is the orderComman =d bit

dense needle
#

how ๐Ÿค”

#

what error does it show now

thorny drift
#

const commands = [OrderCommand, RolesCommand]; i call them there

thorny drift
dense needle
#

did you try:

import * as OrderCommand from 'path'
thorny drift
#

in index.js

dense needle
#

indeed

thorny drift
#

`import * as OrderCommand from 'path'
^^^^^^^^^^^^^^^^^^^^^^^^

SyntaxError: Identifier 'OrderCommand' has already been declared`

thorny drift
dense needle
#

bruh.. we are running in circles. please show your index.js (remove your token when posting here)

dense needle
#

notLikeDaro you have to change stuff too when updating your code

dense needle
#

line 4-5 also replace path with the actual path

thorny drift
#

you mean get rid of:
import OrderCommand from '../commands/order.js'; import RolesCommand from '../commands/roles.js';

#

ohhh

thorny drift
#

how do you do the last part

dense needle
#

either use ESM or CJS completely.
don't know what they are?

Google is your best friend

dense needle
#

you should know, not me. it's your workspace

#

require is based of CJS

thorny drift
#

but u told me to put:
import * as OrderCommand from '../commands/order.js' import * as RolesCommand from '../commands/roles.js'

thorny drift
# dense needle `require` is based of CJS

CommonJS uses the require('./file.js') syntax for importing other modules and the module.exports = syntax for exporting stuff from modules ESM uses the import {stuff} from './file.js' syntax for importing and the export stuff syntax for exports

#

and the rest of my code is using:
const { Client, GatewayIntentBits, Routes, ChatInputCommandInteraction, SortOrderType } = require('discord.js'); const { config } = require('dotenv'); const { REST } = require('@discordjs/rest');

#

not import

dense needle
thorny drift
#

so how do i make it just CommonJS

#

by putting const { OrderCommand } = require('../commands/order.js');

dense needle
#

you need to change your exports everywhere you did it in ESM style too

dense needle
#

I can't say if I don't know how you exported it in CJS

thorny drift
dense needle
#

again.. it depends on yourhow you export

thorny drift
#

i'll show u when i get back home on my pc

dense needle
thorny drift
#

@dense needle ๐Ÿ™‚

dense needle
thorny drift
#

which line

grave martenBOT
#

mdn WebAssembly.Module.exports()
The WebAssembly.Module.exports() function returns an array containing descriptions of all the declared exports of the given Module.

dense needle
#

oop, wrong one

thorny drift
dense needle
thorny drift
#

got an error:
module.exports defualt rolesCommand.toJSON();

thorny drift
#

even tho on the line before it has one

dense needle
#

please.. that's not the syntax

thorny drift
#

so what do i put

thorny drift
#

pls can u just tell me ive been having this error for 2 days now

#

and i want to code

#

like this?
module.exports = { rolesCommand.toJSON }

dense needle
#

to json is a function

thorny drift
#

so what do i put

dense needle
#

plus an object needs key-value pairs

thorny drift
thorny drift
thorny drift
dense needle
#

the problem with this is that it requires you to have knowledge with basic js data type therefore if you don't it's hard to fully cover the whole point. I'd recommend you to visit one of the #resources (personally prefer javascript.info) to learn more on objects and destructuring assignment

thorny drift
#

please can u just tell me, im using codecademy and learning now

#

ive been doing it for a week

#

so please can u say what i need to write

dense needle
thorny drift
#

actually nvm i have made them all ESM

#

import { OrderCommand } from '../commands/order.js'; ^^^^^^^^^^^^ SyntaxError: The requested module '../commands/order.js' does not provide an export named 'OrderCommand'

#

I literally have exported it
export default orderCommand.toJSON();