【问题标题】:Get the channel of the Bot? Discord.py获取Bot的频道?不和谐.py
【发布时间】:2021-11-15 09:09:42
【问题描述】:

我想知道机器人在哪个不和谐语音频道中。我只找到了一种知道用户在哪个语音频道中的方法:

@client.command()
async def write(ctx):
    channel = ctx.message.author.voice.channel
    print(channel)

感谢您的帮助!

【问题讨论】:

    标签: python discord discord.py bots channel


    【解决方案1】:

    来自API,它位于VoiceClient

    @client.command()
    async def write(ctx):
        channel = ctx.voice_client.channel
        print(channel)
    

    【讨论】:

    • 仅供参考,您可能想检查 ctx.voice_client 是否为 None 以防机器人不在语音频道中
    猜你喜欢
    • 2021-06-22
    • 2020-05-07
    • 2020-10-23
    • 1970-01-01
    • 2021-03-11
    • 2021-01-19
    • 2021-02-10
    • 2020-11-07
    • 1970-01-01
    相关资源
    最近更新 更多