• If you need help or want to discuss things, you now can also join us on our Discord Server!
  • A first preview of the unlimited version of SinusBot can be found in the Upcoming Changes thread. A version for Windows will follow, but we don't have a release date, yet.

EN Channels are not updating!

WolfW3lp3

New Member
Hey,

I'am new at Script Development, i don't know why the channels don't change their Codec(-Quality)!
Here is my Code:
Code:
registerPlugin({
    name: 'Channel Updater - Quality',
    version: '1.3.1',
    description: 'Changing',
    author: 'WolfsWelpe',
    vars: []

}, function(sinusbot, config) {
    var engine = require('engine');
    var event = require('event');
    
    var currentChannel;
    var newChannel;
    
    var codecOld;
    var qualityOld;
    var codecNew = 5;
    var qualityNew = 10;
    
    engine.log("Quality Script Loaded");
    
    event.on('clientMove', function(ev) {
        if(ev.client.isSelf()) {
            if(ev.fromChannel != null) {
                currentChannel = ev.fromChannel;
                newChannel = ev.toChannel;
                engine.log(currentChannel.name() + " >> " + newChannel.name());
                engine.log(currentChannel.codec() + ";" + currentChannel.codecQuality());
                if(codecOld != null && qualityOld != null) {
                currentChannel.setCodec(codecOld);
                currentChannel.setCodecQuality(qualityOld);
                };
                if(newChannel.name() != "● Freie Musikbots"){
                codecOld = newChannel.codec();
                qualityOld = newChannel.codecQuality();
                currentChannel.setCodec(codecNew);
                currentChannel.setCodecQuality(qualityNew);
                } else {
                codecOld = null;
                qualityOld = null;
                }
            };
        };
    });
});
I hope you can help me :)
 
So I kinda have the same issue.

Setting the codec doesn't work for me. Nevertheless setting the quality does.
So I looked into the API Docs and it says:
Code:
setCodec(codec: any, quality: number)
But if you try to do this, you just get an error informing you about you should only use one parameter and not 2.

So I don't know what to do ether ^_^
 
So I kinda have the same issue.

Setting the codec doesn't work for me. Nevertheless setting the quality does.
So I looked into the API Docs and it says:
Code:
setCodec(codec: any, quality: number)
But if you try to do this, you just get an error informing you about you should only use one parameter and not 2.

So I don't know what to do ether ^_^
For me its working:
JavaScript:
var ch = 8 // ChannelID
ch = backend.getChannelByID(ch)
engine.log(ch)
engine.log('Current Codec: ' + ch.codec())
engine.log('Current Codec Quality: ' + ch.codecQuality())
ch.setCodec(5)
ch.setCodecQuality(10)
setTimeout(function(){
    engine.log('New Codec: ' + ch.codec())
    engine.log('New Codec Quality: ' + ch.codecQuality())
}, 1000);

Perl:
2018-03-15T16:16:39+01:00 welcome :96 New Codec Quality: 10
2018-03-15T16:16:39+01:00 welcome :95 New Codec: 5
2018-03-15T16:16:38+01:00 welcome :91 Current Codec Quality: 6
2018-03-15T16:16:38+01:00 welcome :90 Current Codec: 4
2018-03-15T16:16:38+01:00 welcome :89 Channel{ ID: <8>, Name: <╔• Gaming Lounge> }
2018-03-15T16:16:38+01:00 Loading script welcome
 
Hey,

I'am new at Script Development, i don't know why the channels don't change their Codec(-Quality)!
Here is my Code:
Code:
                currentChannel = ev.fromChannel;

                currentChannel.setCodec(codecOld);
                currentChannel.setCodecQuality(qualityOld);

                currentChannel.setCodec(codecNew);
                currentChannel.setCodecQuality(qualityNew);
currentChannel = ev.fromChannel will give u "<nil>"
you need the ID of the channel before you can set the codec.

try with
Code:
                currentChannel = ev.fromChannel.id();

                currentChannel.setCodec(codecOld);
                currentChannel.setCodecQuality(qualityOld);

                currentChannel.setCodec(codecNew);
                currentChannel.setCodecQuality(qualityNew);
 
But if you try to do this, you just get an error informing you about you should only use one parameter and not 2.
The documentation seems to be wrong, the correct function is .setCodecQuality(), as @Kamikaze mentioned.

// Edit: I fixed it in the doc
 
Last edited:
currentChannel = ev.fromChannel will give u "<nil>"
you need the ID of the channel before you can set the codec.

Thats wrong and if the fromChannel is null your call will result in a NullpointerException as you cant call .id() from a null object.

You just have to check if the fromChannel and toChannel are set, as the fromChannel is not available on connects and the toChannel not on disconnects
 
Back
Top Bottom