omano
Member
Hello there, so first I would like to say I'm not a coder. I took lot of time before to create a few scripts for my personal use, looking how other scripts were made, on the older API version. Most of my scripts still work, but the last one I created had weird bugs. Someone here (where I linked to my original script) https://forum.sinusbot.com/threads/ev-clientnick-problem-in-my-script.3512/#post-19139 adviced me to use the new API as I'm using the old one. I tried to understand how it worked but to me it seems more complicated than expected and I can not succeed in converting my old script.
Here is a simplified version of the script:
I would like someone to help me convert this little piece of simplified script to the new API, from there I think I could get all my scripts to the new API. I tried to convert my script and so far I was only able to have the bot say the sentence when any client moves (not only from the bot channel) and I couldn't have the information if the bot is playing a track https://www.sinusbot.com/docs/scripting/#Audio.isPlaying or couldn't have playURL https://www.sinusbot.com/docs/scripting/#Media.playURL to work, couldn't retrieve the current bot channel https://www.sinusbot.com/docs/scripting/#Backend.getCurrentChannel and so on. I really have a lack of knowledge here, I know, and there is surely only a little something i didn't understand to be able to use the new API
Really appreciate anyone guiding me in the right direction
Here is a simplified version of the script:
Code:
registerPlugin({
name: 'Client Leave Music or Sentence',
version: '1',
description: 'Script to play track or say something on client leave',
author: '®omano',
vars: { }
}, function(sinusbot, config, info){
sinusbot.on('clientMove', function(ev){
if (ev.clientUid == '4Wa3D3xeXWzeXLWvoAwZJLvTnBw=' && ev.oldChannel == sinusbot.getCurrentChannelId()) {
play('track://e06d0578-f567-41f5-8503-40224fb33acb');
} else { if (ev.oldChannel == sinusbot.getCurrentChannelId()) {
say ('client ' + ev.clientNick + ' left the channel');}
}
});
});
I would like someone to help me convert this little piece of simplified script to the new API, from there I think I could get all my scripts to the new API. I tried to convert my script and so far I was only able to have the bot say the sentence when any client moves (not only from the bot channel) and I couldn't have the information if the bot is playing a track https://www.sinusbot.com/docs/scripting/#Audio.isPlaying or couldn't have playURL https://www.sinusbot.com/docs/scripting/#Media.playURL to work, couldn't retrieve the current bot channel https://www.sinusbot.com/docs/scripting/#Backend.getCurrentChannel and so on. I really have a lack of knowledge here, I know, and there is surely only a little something i didn't understand to be able to use the new API
Really appreciate anyone guiding me in the right direction
Last edited: