Discord Python bot 在语音频道中创建活跃成员的文件
Discord Python bot creating a file of active member in a vocal channel
我尝试得到一个 Python bot
来创建一个文件,其中包含活跃在声乐频道中的人的名字(隔离期间的课堂参与清单)。
我正在使用 Datacamp 网站学习 Python 两个月(顺便推荐一下 - 老师可以免费访问...)。
我尝试了很多从多个来源获取的代码行,甚至尝试编写我的代码,但我无法理解我遇到的所有错误......
我也试过 discord.py
文档,但它对我来说就像 Chinese/Python :-) ...
这是为了介绍(基本上是说不要指望我做任何事情,或者不要指望我理解任何东西......除了我有一个机器人 运行,他可以做所有花哨的事情,比如回答"hello"、"ping"/"pong"、准备好...)。
该线程看起来正是我需要的,但可能由于重写而无法正常工作。
(discord.py) Getting a list of all of the members in a specific voice channel
我在 PC 上使用 Pycharm。
使用Python 3.8
Discord.py1.3.2
起点是(只给出用户数):
@client.event
async def on_message(message):
if message.content.startswith('!member'):
for member in message.channel
print(member)
感谢阅读。
下面是一个非常基本的示例,它将创建一个文本文件,其中包含调用命令时位于特定语音通道中的所有人。请注意,您必须更新 client.get_channel
为您要检查的语音通道的 ID。
您可以通过在机器人有权访问的文本通道中键入 !attendance test.txt
来使用它。这将创建一个名为 test.txt
的文件,其中将包含当前语音频道中每个人的姓名。
from discord.ext import commands
client = commands.Bot(command_prefix='!')
@client.command()
async def attendance(ctx, filename):
channel = client.get_channel(123456789) # Replace with voice channel ID
with open(filename, 'w') as file:
for member in channel.members:
file.write(member.name + '\n')
client.run('token')
我尝试得到一个 Python bot
来创建一个文件,其中包含活跃在声乐频道中的人的名字(隔离期间的课堂参与清单)。
我正在使用 Datacamp 网站学习 Python 两个月(顺便推荐一下 - 老师可以免费访问...)。
我尝试了很多从多个来源获取的代码行,甚至尝试编写我的代码,但我无法理解我遇到的所有错误......
我也试过 discord.py
文档,但它对我来说就像 Chinese/Python :-) ...
这是为了介绍(基本上是说不要指望我做任何事情,或者不要指望我理解任何东西......除了我有一个机器人 运行,他可以做所有花哨的事情,比如回答"hello"、"ping"/"pong"、准备好...)。
该线程看起来正是我需要的,但可能由于重写而无法正常工作。 (discord.py) Getting a list of all of the members in a specific voice channel
我在 PC 上使用 Pycharm。
使用Python 3.8 Discord.py1.3.2
起点是(只给出用户数):
@client.event
async def on_message(message):
if message.content.startswith('!member'):
for member in message.channel
print(member)
感谢阅读。
下面是一个非常基本的示例,它将创建一个文本文件,其中包含调用命令时位于特定语音通道中的所有人。请注意,您必须更新 client.get_channel
为您要检查的语音通道的 ID。
您可以通过在机器人有权访问的文本通道中键入 !attendance test.txt
来使用它。这将创建一个名为 test.txt
的文件,其中将包含当前语音频道中每个人的姓名。
from discord.ext import commands
client = commands.Bot(command_prefix='!')
@client.command()
async def attendance(ctx, filename):
channel = client.get_channel(123456789) # Replace with voice channel ID
with open(filename, 'w') as file:
for member in channel.members:
file.write(member.name + '\n')
client.run('token')