flynns82
Member
Hi,
I need a script that, when the bot remains alone or is moved to a channel where there is only him, if he stays there for x hours, he stops and disconnects.
PREMISE: I know some programming language (medium-low knowledge), but javascript absolutely nothing, this said, I tried to do something with what I found on the internet but I still could not make anything work.
someone could tell me what there is it wrong in the code? and how to fix it?
or, alternatively, if it is completely wrong, to do it?(if it is not too much a waste of time)
Thanks so much!
I need a script that, when the bot remains alone or is moved to a channel where there is only him, if he stays there for x hours, he stops and disconnects.
PREMISE: I know some programming language (medium-low knowledge), but javascript absolutely nothing, this said, I tried to do something with what I found on the internet but I still could not make anything work.
someone could tell me what there is it wrong in the code? and how to fix it?
or, alternatively, if it is completely wrong, to do it?(if it is not too much a waste of time)
Thanks so much!
JavaScript:
registerPlugin({
name: 'LogoutWhenAlone',
version: '1.1',
description: 'This script disconnect the bot when it is alone by x time.',
author: 'Marco Canazza <[email protected]>',
vars: [{
name: 'mode',
title: 'Set Milliseconds',
type: 'number'
}]
}, function(sinusbot, config) {
var engine = require('engine'),
backend = require('backend'),
event = require('event'),
msg = config.message ;
event.on('clientMove', function(ev) {
if (backend.getCurrentChannel().getClientCount() <= 1 ) {
setTimeout(function(){
if (backend.getCurrentChannel().getClientCount() <= 1 ) {
disconnect();
}
}, msg );
}
});
});