【发布时间】:2019-08-02 05:26:22
【问题描述】:
我需要服务器中所有语音通道的列表,我在文档中看到了 get_all_channels,但我不确定如何实现它。
https://discordpy.readthedocs.io/en/latest/api.html?highlight=voice%20channels
【问题讨论】:
标签: python bots discord discord.py
我需要服务器中所有语音通道的列表,我在文档中看到了 get_all_channels,但我不确定如何实现它。
https://discordpy.readthedocs.io/en/latest/api.html?highlight=voice%20channels
【问题讨论】:
标签: python bots discord discord.py
从1.0.0+版本开始,您可以通过discord.Guild.voice_channels获取所有语音通道:
@client.command()
async def channels(ctx):
voice_channel_list = ctx.guild.voice_channels
# ...
【讨论】:
循环通过Server.channels 检查Channel.type 与ChannelType.voice
from discord import ChannelType
@bot.command(pass_context=True)
async def voicechannels(ctx):
channels = (c.name for c in ctx.message.server.channels if c.type==ChannelType.voice)
await bot.say("\n".join(channels))
【讨论】: