Form Types
Switch
DBD.formTypes.switch(disabled),
disabled
boolean
requiredIndicate if the switch should be disabled or not.
Data required for getActualSet function
Boolean, to be turned on or not.
Important:
Please note that if(saved.state)
will return false if data is not set. If you want to default state to be true, use this:
getActualSet: ({ guild, user }) => {
return SAVED_STATE == null || SAVED_STATE == undefined
? DEFAULT_STATE
: SAVED_STATE;
};
Data returned
Boolean, true if turned on - false if turned off.
Example Usage
{
optionId: 'switch_coffee',
optionName: "Coffee switch",
optionDescription: "Do you want coffee to be sent daily to you?",
optionType: DBD.formTypes.switch(false),
getActualSet: async ({guild}) => {
const SAVED_STATE = switchData[guild.id];
const DEFAULT_STATE = true;
return (SAVED_STATE == null || SAVED_STATE == undefined) ? DEFAULT_STATE : SAVED_STATE;
},
setNew: async ({guild,newData}) => {
switchData[guild.id] = newData;
return;
}
},