Skip to content
Advertisement

Discord.py editing channel by word that is in the name

I am making statistics bot, and i have a problem, with voice channel containing member count. I want to make bot update name of that channel, on_member_join, on_member_remove and when user use command refresh but i tried many times at different ways, and it stil don’t work, i want to make him edit channel that contains in name “Members:” but i can get channel at most with constant name. Is there any way to get channel by containing “Members:”?

Okay, i tried Łukasz’s code, but it still don’t changes the channel name. My code:

JavaScript

And my channel screenshots (maybe it will be important):
enter image description here

enter image description here

Can you please tell me why it’s not working?

Advertisement

Answer

You should use the in keyword, e.g

JavaScript

To get all channels that contain the word members:

JavaScript

If you want a one-liner:

JavaScript

Then you can loop through every channel and edit it:

JavaScript

Note: There’s a heavy ratelimit for editing channels (2 requests per 10 minutes per channel iirc) you should use this wisely

Reference:

Advertisement