• TeamSpeak has reported a vulnerability in it's client that can potentially lead to RCE. A new version has been released that fixes it. So please update the client in your bot installation as soon as possible as well. Click here for more information.
  • If you need help or want to discuss things, you now can also join us on our Discord Server!

EN Find channel id of Client(who's sending msg to bot)

Vizi

New Member
Hey.. what is easiest way to determine id of a channel where client is(when he's on other channel than bot)?
i tried client.getChannels() but i i get '[object Object]' :S
 

DrWarpMan

Active Member
Contributor
Insider
Because he can be in multiple channels at once, you need to loop through the "client.getChannels()".
 

Diesmon

Tuetchen Dominator
is awesome!
Contributor
Insider
to explain this a bit further:

you can use
Code:
client.getChannels()[0]
to get the first element of the array which is sufficient if your script is designed for TS3 only.

But as soon as you want to support Discord, then you should use the
Code:
client.getAudioChannel()
which will always return only one channel, which is the currently used Audio Channel.

This will always be the same channel as
Code:
client.getChannels()[0]
if used in the TeamSpeak backend, but on Discord it might give you another channel, since Discord supports multiply channels (Audio + Text channels)

So in general the
Code:
client.getAudioChannel()
should be safer.

Also see: https://sinusbot.github.io/scripting-docs/#clientgetchannels and https://sinusbot.github.io/scripting-docs/#clientgetaudiochannel for more about this and further documentation.
 
Top