from discord.ext import commands
client = commands.Bot(command_prefix = '.')
channel = None
@client.event
async def on_ready():
channel = client.get_channel(677999369642836037)
async def members_list(request):
curMembers = []
for member in channel.members:
curMembers.append(member)
return render(request, "discordTool/discordTool.html", {
'members_list': curMembers,
})
client.run('my token')
我使用django,并且我很清楚我需要将bot代码放置在另一个文件中,我的主要问题是我不知道如果放置了bot,我将如何从bot中获取成员列表在另一个文件中?或如何调用该机器人并仅在需要它运行时才运行它?