discord-easy-dashboard now supports custom cookies storage ! It allows to store login informations, current settings, etc. You have to choose your storage system and implement it. This is a guide to make it easier.
/!\ This section of the documentation has been written for an older version of discord-easy-dashboard. The code may not work as expected. /!\
Here we will use Redis as a storage for cookies, but you can use any database you want
-
Setup the Redis server on your PC. Click here for help
-
Install required dependencies using npm :
npm i redis connect-redis
- Now you can setup the Redis client and session object
const redis = require('redis');
const connectRedis = require('connect-redis');
const session = require('express-session');
const RedisStore = connectRedis(session)
const redisClient = redis.createClient({
host: 'localhost',
port: 6379
})
redisClient.on('error', function (err) {
console.log('Could not establish a connection with redis. ' + err);
});
redisClient.on('connect', function (err) {
console.log('Connected to redis successfully');
});
const sessionObject = {
store: new RedisStore({ client: redisClient }),
secret: `discord-easy-dashboard-${Date.now()}-${Math.random().toString(36)}`,
resave: false,
saveUninitialized: false,
cookie: {
secure: false, // if true only transmit cookie over https
httpOnly: false, // if true prevent client side JS from reading the cookie
maxAge: 1000 * 60 * 10 // session max age in miliseconds
}
};
- Finally, you can use the session object in your dashboard
client.dashboard = new Dashboard(client, {
// Other options
session: sessionObject,
});