This code is pretty good for those bots that are in servers with limited resources.
Set all needed variables.
client.variables({
cpuLimit: '100', // Below your maximum CPU.
ramLimit: '$maxRam', // If $maxRam doesn't works, put the limit manually.
onLimit: 'false'
})
Setting the resource monitor
client.loopCommand({
executeOnStartup: true,
every: 2*60*1000, // 2 minutes.
'$if': 'old',
channel: 'channel ID here',
code: `
$if[$cpu[os]>$getVar[cpuLimit]&&$ram>$getVar[ramLimit]]
$setVar[onLimit;true]
$else
$setVar[onLimit;false]
$endif
`
})
Setting normal commands
You must use something like this for commands to be used only if bot isn't using too much resources: $onlyIf[$getVar[onLimit]==false;Bot is running under limited mode, this command is not available, try again later.]
client.command({
name: 'ping',
code: `
$sendMessage[Pong!]
$onlyIf[$getVar[onLimit]==false;Bot is running under limited mode, this command is not available, try again later.]
`
})