• We would like to invite you to check out the latest 1.0 alpha versions. You can read more about what's new here. Please note, that this is still an early release and will contain new bugs ¯\_(ツ)_/¯
  • 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