Deprecated: Use of "parent" in callables is deprecated in /var/www/html/forum/src/vendor/league/flysystem-eventable-filesystem/src/EventableFilesystem.php on line 431
  • 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 getChannel Name?

Status
Not open for further replies.

sestry

Member
Hello Guys,

I am working on a littel script for my server.

The idea is that you can write in the channel chat "!sperren" and the channel is closed.

But I want, that the channel becomes his original name after writing "!entsperren". And their is the problem.
I dont know how I become the channel name. I have already tried with an channel update event, but this is really bad.
I hope you can help me, and sry for my bad English.

And thank you!


Code:
registerPlugin({
    name: 'SperreChannel',
    version: '1.0',
    description: 'Sperrt auf Befehl den Channel in dem man sich befindet.',
    author: '--------- <-------->',
 
   
   
},


function(sinusbot, config) {
    var clientId;
    var clientUid;
    var channel;
    var channel_name;
    var gesperrt;
    var id;
   
    sinusbot.on('chat', function(ev) {
       
        if(ev.mode == 2){
            if(ev.msg == "!sperren"){
                if(gesperrt != "true"){
                clientId = ev.clientId;
                clientUid = ev.clientUid   
                channel = ev.channel;
               
               
               
                id = sinusbot.getCurrentChannelId();
               
               
                chatPrivate(clientId, sinusbot.getCurrentChannelId())
                      if(id == channel){
                        if(gesperrt != "true"){
                       channel_name = ev.name;

                       
                        chatServer('Der Channel "' + channel_name + '" ist nun gesperrt!')
                       
                   
                        gesperrt = "true";
                        channelUpdate(channel, { name: 'GESPERRT', maxClients: 1})
                        chatPrivate(clientId, "Der Channel ist nun gesperrt!")
                        }
                      }
                   
               
                   
               
               
            } else {chatPrivate(ev.clientId, "Leider kann im moment erstmal nur ein Channel gesperrt sein. Dies wird aber noch ausgebessert!")}
            }
           
           
           
           
           
           
           
           
           
           
           
           
           
           
           
           
           
            if(ev.msg == "!entsperren"){
                if(gesperrt == "true"){
                    if(clientId == ev.clientId){
               
               
                chatServer('Der Channel "' + channel_name + '" ist nun entsperrt!')
                       
                       
                        gesperrt = "false";
                        channelUpdate(channel, { name: channel_name, maxClients: 32})
                        chatPrivate(clientId, "Der Channel ist nun entgesperrt!")
               
               
               
                   
                    } else {chatPrivate(ev.clientId, "Du kannst den Channel nicht entsperren!")}
               
            } else {chatPrivate(ev.clientId, "Leider kann im moment erstmal nur ein Channel gesperrt sein. Dies wird aber noch ausgebessert!")}
            }
        }
       
   
    });
   

       
       
       
       
       
       
        });
 

Tunakill

Well-Known Member
Contributor
Insider
Du kannst ihn so herausfinden:
Code:
function getChannelName(channel_id) {
      var channel = sinusbot.getChannels();
      for (var i = 0; i < channel.length; i++) {
        if(channel[i].id == channel_id) {
       
          return channel[i].name;
       
        }
      }
    }
Du kannst auch anstatt 'sinusbot.getCurrentChannelId()' 'ev.channel' benutzen.
Und du solltest besser sinusbot.chatPrivate() benutzen.
 
Status
Not open for further replies.
Top