discordjs / Commando

Official command framework for discord.js
Apache License 2.0
495 stars 242 forks source link

SettingProvider set and remove dont work #376

Closed Fuchsi2 closed 3 years ago

Fuchsi2 commented 3 years ago

hi

I am trying to make a Discord Bot with the guild configurations saved in the settingprovider. but if I do client.provider.set("<some id>", "test", "a value"); it returns this:

TypeError: Cannot read property 'run' of null at SQLiteProvider.set (E:\Documents\projectdir\botroot\node_modules\discord.js-commando\src\providers\sqlite.js:147:34)
at CommandoClient. (E:\Documents\projectdir\botroot\bots\discord\discord.js:55:31) at processTicksAndRejections (internal/process/task_queues.js:93:5)

the settings are accessible in the code but not saved in the .sqlite3 file.

I played around a bit with the package code and found out that there is not realy the problem: \src\providers\sqlite.js:147:34 I think the problem is this: \src\providers\sqlite.js:88:9 // Prepare statements const statements = await Promise.all([ this.db.prepare('INSERT OR REPLACE INTO settings VALUES(?, ?)'), this.db.prepare('DELETE FROM settings WHERE guild = ?') ]); this.insertOrReplaceStmt = statements[0]; this.deleteStmt = statements[1]; console.log(this.insertOrReplaceStmt) //console.log added by me and it returns:

Statement { stmt: Statement {} }

Reinstalling the package doesnt help.

I am running a Windows 10 PC with: node version: v14.15.4 npm version: 6.14.10 discord.js-commando version: 0.12.2

pls help

Fuchsi2 commented 3 years ago

I found the solution. just use the "providerReady" event and it works