|
1 month ago | |
---|---|---|
.gitignore | 1 month ago | |
README.md | 1 month ago | |
index.js | 1 month ago | |
package.json | 1 month ago | |
yarn.lock | 1 month ago |
NeDB-based database hosted on Discord.
From npm :
yarn add discord-nedb
or
npm install discord-nedb
discord.js
: Discord API wrappernedb-promises
: NeDB wrapper with Promises
nedb
: JS database)const Datastore = require('discord-nedb');
const database = new Datastore(
'token',
'guildId',
'channelId',
'userId',
'messageId'
);
const messageId = await database.loadDatabase();
token
parameter is a required bot tokenguildId
+ channelId
or userId
messageId
is undefined, a new message will be createdloadDatabase
, which will return messageId
, especially useful at first initializationMethods provided by nedb-promises
(check Datastore
docs) :
find
findOne
count
update
remove
ensureIndex
removeIndex
await database.persistence.compactDatafile();
Database compaction is automatically called when the message exceeds Discord's maximum limit.
If compaction doesn't free enough space for additional data, an error will be thrown.
await database.deleteDatabase(
isDeletingLocally,
isDeletingRemotely
)
isDeletingLocally
is true
(default), the local database file is deleted.isDeletingRemotely
is true
(not default), the Discord message is deleted.0.1.0
(2020-12-17) • Initial releaseThis project is released under the MIT license.