SimonLeclere / discord-easy-dashboard

💻 Simple module to facilitate the creation of dashboard using discord.js and express
https://www.npmjs.com/package/discord-easy-dashboard
71 stars 11 forks source link

Examples for databases #18

Closed NotSoMik closed 1 year ago

NotSoMik commented 2 years ago

Yo, can you please tell us how to use databases in your package such as mongodb enmap, would be very nice

EclipseGame18 commented 1 year ago

when setting your settings (strings or boolean) with your get and set functions simply use MongoDB to set and retrieve the data:

const get = async(discordClient, guild) => {
    const get_setting = await settings.findOne({_id: guild.id})
    return get_setting
    }
const set = async(discordClient, guild, value) => {
    await settings.findOneAndUpdate({
        _id: guild.id
        },{
        _id: guild.id,
        toggle: value,

        },{
            upsert: true
        })
}

(these are basic examples do not just copy this code, you will get errors)