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 个成员。