Romejanic / slasher

A framework to simplify the creation of Discord bots.
MIT License
3 stars 2 forks source link

TypeError: Cannot read properties of undefined (reading 'intents') #14

Closed Superredstone closed 2 years ago

Superredstone commented 2 years ago

The application crashes with the following error:

C:\Users\Patrick\Documents\Programming\JS\mastery-bot\node_modules\discord.js-slasher\build\src\api\wrapped-client.js:139 if (!options.intents) { ^

TypeError: Cannot read properties of undefined (reading 'intents') at filterOptions (C:\Users\Patrick\Documents\Programming\JS\mastery-bot\node_modules\discord.js-slasher\build\src\api\wrapped-client.js:139:18) at new SlasherClient (C:\Users\Patrick\Documents\Programming\JS\mastery-bot\node_modules\discord.js-slasher\build\src\api\wrapped-client.js:17:15) at Object. (C:\Users\Patrick\Documents\Programming\JS\mastery-bot\index.js:3:16) at Module._compile (node:internal/modules/cjs/loader:1119:14) at Module._extensions..js (node:internal/modules/cjs/loader:1173:10) at Module.load (node:internal/modules/cjs/loader:997:32) at Module._load (node:internal/modules/cjs/loader:838:12) at Function.executeUserEntryPoint [as runMain] (node:internal/modules/run_main:81:12) at node:internal/main/run_main_module:18:47

Node.js v18.9.0

To Reproduce Steps to reproduce the behavior:

  1. Create a file named index.js with the following code:

const { SlasherClient } = require("discord.js-slasher");

const client = new SlasherClient();

client.on("ready", () => { console.log(Bot logged in as ${client.user.tag}); });

client.on("command", (ctx) => { if (ctx.command == "test") { ctx.reply(This is a test! You are ${ctx.user.username}!) } });

client.login();

  1. Create a commands.json file and fill it with a command named "test"
  2. Run npx slasher and save auth.json
  3. Run node index.js

Environment (please complete the following information):

Romejanic commented 2 years ago

Hey there, thanks for the report.

Looks like you're missing the options object in your client constructor, which is required in slasher.

Try changing that line to this

const client = new SlasherClient({ useAuth: true });

Let me know if this issue still persists.

Thank you

Superredstone commented 2 years ago

That works! Thanks. (And sorry for the stupid question)