• 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 Find channel id of Client(who's sending msg to bot)

Vizi

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

Well-Known 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