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

Guild ID showing as undefined #27

Closed lockyz closed 2 years ago

lockyz commented 2 years ago

I use mySQL in order to handle the settings within my bot but for some reason the guild ID when getting settings from the dashboard is only ever showing as undefined or as "null" within the actual database file.

Here is the code for one of the functions to change a setting as an example of my code

const setxpEnable = (guild, value) => {

    let guildset = client.getGuSett.get(guild.id)

    if(value === true) {
        guildset = { guildID: guild.id, enableLogging: guildset.enableLogging, enableWelcome: guildset.enableWelcome, enableXP: 'true', enableRoleOnJoin: guildset.enableRoleOnJoin, enableBoosts: guildset.enableBoosts, enableLeave: guildset.enableLeave };
        client.setGuSett.run(guildset);
    }

    if(value === false) {
        guildset = { guildID: guild.id, enableLogging: guildset.enableLogging, enableWelcome: guildset.enableWelcome, enableXP: 'false', enableRoleOnJoin: guildset.enableRoleOnJoin, enableBoosts: guildset.enableBoosts, enableLeave: guildset.enableLeave };
        client.setGuSett.run(guildset);
    }
}

When outputting the guild id using console.log(guild.id) it always comes out as undefined.

I'm assuming it's being formatted as an object instead of a string, snowflake or the like but I would like some clarification.

lockyz commented 2 years ago

I figured it out, just simple user error of not reading the documentation correctly.