如何获取不和谐服务器中所有成员的列表?

时间:2021-02-06 17:20:09

标签: python discord

main.py

import discord
import os
from kmf import playkmf

client = discord.Client()

@client.event
async def on_ready():
    print('We have logged in as {0.user}'.format(client))


@client.event
async def on_message(message):
    if message.author == client.user:
        return 
    
    if message.content.startswith('-='):

        if message.content == '-= playkmf':
            await playkmf(message)
        else :
            await message.channel.send("type -=help for help")


client.run(os.getenv('TOKEN'))

kmf.py

async def playkmf(message) :
    allMembers = message.guild.members
    for x in allMembers:
        print(x.name)
    await message.channel.send('KMF started')

当我在控制台输入“-= playkmf”时的输出

We have logged in as JujuGames#6518
JujuGames

Discord 服务器中有 5 个成员。输出仅显示 1 个成员。

0 个答案:

没有答案