(discord.py) Getting a list of all of the members in a specific voice channel((discord.py) 获取特定语音频道中所有成员的列表)
问题描述
所以我正在尝试使用 python 中的 discord.py 库为我的突袭不和谐编写一个突袭机器人.该脚本应该在语音频道中形成一个成员列表以进行袭击.由于某种原因,此脚本无法正常工作.每当打印 memids 时,它只会打印一个空列表.
So I'm attempting to write a raiding bot for my raiding discord using the discord.py library in python. This scripts is supposed to be forming a list of members in the voice channel for raiding. For some reason, this script is not working. Whenever memids is printed, it just prints an empty list.
如果有人熟悉 discord.py 并且可以告诉我为什么这不起作用,请这样做.这真的让我很困扰,我已经尽我所能来解决它.
If anyone is familiar with discord.py and could tell me why this isn't working, please do. It's really troubling me and I have tried everything in my knowledge to fix it.
#find raiding
voice_channel = discord.utils.get(ctx.message.server.channels, id = '440014722587426816')
#finds the members
members = voice_channel.voice_members
memids = []
for member in members:
memids.append(member.id)
print(memids)
推荐答案
如果你知道频道的id,你可以这样做.为我工作:D
If you know the id of the channel you can do it this way. Works for me :D
channel = client.get_channel(1234567890) #gets the channel you want to get the list from
members = channel.members #finds members connected to the channel
memids = [] #(list)
for member in members:
memids.append(member.id)
print(memids) #print info
这篇关于(discord.py) 获取特定语音频道中所有成员的列表的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:(discord.py) 获取特定语音频道中所有成员的列表
基础教程推荐
- Dask.array.套用_沿_轴:由于额外的元素([1]),使用dask.array的每一行作为另一个函数的输入失败 2022-01-01
- 筛选NumPy数组 2022-01-01
- 线程时出现 msgbox 错误,GUI 块 2022-01-01
- 何时使用 os.name、sys.platform 或 platform.system? 2022-01-01
- 如何让 python 脚本监听来自另一个脚本的输入 2022-01-01
- 使用PyInstaller后在Windows中打开可执行文件时出错 2022-01-01
- 如何在海运重新绘制中自定义标题和y标签 2022-01-01
- Python kivy 入口点 inflateRest2 无法定位 libpng16-16.dll 2022-01-01
- 在 Python 中,如果我在一个“with"中返回.块,文件还会关闭吗? 2022-01-01
- 用于分类数据的跳跃记号标签 2022-01-01