Reputation: 125
I have this code in my addm file in a folder called commands. I attached the code below
const { Message } = require('discord.js')
const Client = require('../bot')
const stats = require('./stats')
module.exports = {
name: `addm`,
/**
* @param {Client} client
* @param {Message} message
* @param {String[]} args
*/
run: async(client, message, args) => {
if(message.author.id === '649755456927170601' || message.author.id === '670869760753401877' || message.author.id === '750057963946901634'|| message.author.id === '718510263392796793' || message.author.id === '622442733294059526' || message.author.id === '719976950655090753' || message.author.id === '820626007773544448') {
const user = message.mentions.members.first()
if(!user) {
return message.reply("You need to specify an id")
}
const d = args[0]
if(!args[0]) {
message.reply("Please specify an amount format: $addm 5000 @user")
} else {
message.reply(`Added ${d} bobux to ${user}'s bal`)
return await client.economy.addBal(user.id, d)
}
} else {
return message.reply("You can't use this command")
}
const data1 = await stats.findOne({Name:'Boblox'})
data1.Ran += 1
data1.save()
},
timeout: 200
}
But I keep getting the error that
(node:26272) UnhandledPromiseRejectionWarning: Error: Cannot find module 'C:\Users\Sochum\Desktop\commands\addm.js'
Require stack:
- C:\Users\Sochum\Desktop\BobloxBot\bot.js
- C:\Users\Sochum\Desktop\BobloxBot\mainstart.js
at Function.Module._resolveFilename (internal/modules/cjs/loader.js:880:15)
at Function.Module._load (internal/modules/cjs/loader.js:725:27)
at Module.require (internal/modules/cjs/loader.js:952:19)
at require (internal/modules/cjs/helpers.js:88:18)
at C:\Users\Sochum\Desktop\BobloxBot\bot.js:80:20
at Array.map (<anonymous>)
at EconomyClient.commandHandler (C:\Users\Sochum\Desktop\BobloxBot\bot.js:79:52)
at EconomyClient.start (C:\Users\Sochum\Desktop\BobloxBot\bot.js:88:10)
at Object.<anonymous> (C:\Users\Sochum\Desktop\BobloxBot\mainstart.js:3:21)
at Module._compile (internal/modules/cjs/loader.js:1063:30)
at Module.load (internal/modules/cjs/loader.js:928:32)
at Function.Module._load (internal/modules/cjs/loader.js:769:14)
at Function.executeUserEntryPoint [as runMain] (internal/modules/run_main.js:72:12)
at internal/main/run_main_module.js:17:47
(node:26272) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). To terminate the node process on unhandled promise rejection, use the CLI flag `--unhandled-rejections=strict` (see https://nodejs.org/api/cli.html#cli_unhandled_rejections_mode). (rejection id: 1)
(node:26272) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.
(node:24136) UnhandledPromiseRejectionWarning: Error [SHARDING_READY_TIMEOUT]: Shard 0's Client took too long to become ready.
at Timeout.onTimeout (C:\Users\Sochum\Desktop\BobloxBot\node_modules\discord.js\src\sharding\Shard.js:163:16)
at listOnTimeout (internal/timers.js:554:17)
at processTimers (internal/timers.js:497:7)
(Use `node --trace-warnings ...` to show where the warning was created)
(node:24136) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). To terminate the node process on unhandled promise rejection, use the CLI flag `--unhandled-rejections=strict` (see https://nodejs.org/api/cli.html#cli_unhandled_rejections_mode). (rejection id: 1)
(node:24136) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.
PS C:\Users\Sochum\Desktop\BobloxBot> node .
Launched shard 0
(node:18272) Warning: Accessing non-existent property 'MongoError' of module exports inside circular dependency
(Use `node --trace-warnings ...` to show where the warning was created)
(node:18272) UnhandledPromiseRejectionWarning: Error: Cannot find module 'C:\Users\Sochum\Desktop\commands\addm.js'
Require stack:
- C:\Users\Sochum\Desktop\BobloxBot\bot.js
- C:\Users\Sochum\Desktop\BobloxBot\mainstart.js
at Function.Module._resolveFilename (internal/modules/cjs/loader.js:880:15)
at Function.Module._load (internal/modules/cjs/loader.js:725:27)
at Module.require (internal/modules/cjs/loader.js:952:19)
at require (internal/modules/cjs/helpers.js:88:18)
at C:\Users\Sochum\Desktop\BobloxBot\bot.js:78:20
at Array.map (<anonymous>)
at EconomyClient.commandHandler (C:\Users\Sochum\Desktop\BobloxBot\bot.js:77:52)
at EconomyClient.start (C:\Users\Sochum\Desktop\BobloxBot\bot.js:86:10)
at Object.<anonymous> (C:\Users\Sochum\Desktop\BobloxBot\mainstart.js:3:21)
at Module._compile (internal/modules/cjs/loader.js:1063:30)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:1092:10)
at Module.load (internal/modules/cjs/loader.js:928:32)
at Function.Module._load (internal/modules/cjs/loader.js:769:14)
at Function.executeUserEntryPoint [as runMain] (internal/modules/run_main.js:72:12)
at internal/main/run_main_module.js:17:47
(node:18272) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). To terminate the node process on unhandled promise rejection, use the CLI flag `--unhandled-rejections=strict` (see https://nodejs.org/api/cli.html#cli_unhandled_rejections_mode). (rejection id: 1)
(node:18272) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.
Here is the index.js code where I run everything.
const { ShardingManager } = require('discord.js');
const manager = new ShardingManager('./mainstart.js', {
token: "#######",
})
manager.on('shardCreate', shard => console.log(`Launched shard ${shard.id}`));
manager.spawn();
There is a file called bot.js that is outside the commands folder, so I am not sure why this error is appearing. The code is ran from the index.js file which connects to the main bot.js file
Upvotes: 0
Views: 298
Reputation: 193
If I am seeing correctly, your project is named BobloxBot
from your terminal output. So I think you might be trying to import from C:\Users\Sochum\Desktop\BobloxBot\commands\addm.js
, not from C:\Users\Sochum\Desktop\commands\addm.js
. The part of the code, which you have shared, seems fine. So the problem probably lies with your mainstart.js
where it is importing from the wrong path.
Upvotes: 1