Events

Deep structure of events

Within events, the client property returns several useful properties. Such as the database property, which allows you to perform searches and save data to the MongoDB database, or the config property, which returns the properties set in config.powerdiscord.js.

Example of events/interactionCreate.js
module.exports = {
    name: "interactionCreate",
    run: async (client, interaction) => {
    
        let db = await client.database({ guildId: "123"}, "guilds");

        if(interaction.customId === "my-button") {
            db.myname = "ronaldzav"
            await db.save()
            
            await interaction.reply({ content: "Your name has been saved." });
        
        }

    }};

Last updated