首页 > 解决方案 > discord.py 问题:如何在不和谐中检查第一个加入语音聊天的用户

问题描述

所以我正在制作一个机器人,当人们加入特定的 VC 时它会喜欢它。它将使用首先加入该特定 vc 的人创建新的语音通道。不要介意我的英语,我知道我的英语很烂。:c 我正在尝试这个

from discord.ext import commands
import discord 
import os

bot = commands.Bot(command_prefix = ">")
client = discord.Client()

@commands.command()
async def join_voice(self, ctx):
    connected = ctx.author.voice
    if connected:
      await create_voice_channel("I want to add a person who triggered the bot by join specific VC to  set name of new VC to their name.")
client.run(os.getenv('TOKEN'))

标签: pythonpython-3.xdiscord.py

解决方案


我认为您正在寻找的是on_voice_state_update协程功能。我不太确定你想对传递给函数的数据做什么,但你可能可以在这里找到你想要的。

对于任何其他问题,请尝试检查discord.py API 参考


推荐阅读