Python 同时运行两个discord bot令牌

Python 同时运行两个discord bot令牌,python,discord,discord.py,token,Python,Discord,Discord.py,Token,我需要帮助来创建一个脚本,该脚本允许您运行多个bot令牌,而无需对每个bot始终重复命令代码,例如: 导入不一致 从discord.ext导入命令 导入异步 client1=commands.Bot(命令前缀='?') client2=commands.Bot(命令前缀='?') @client1.event _ready()上的异步定义: 等待客户1.更改状态(活动=不和谐。游戏(“?命令”)) 打印('连接到bot:{}'。格式(client1.user.name)) 打印('Bot-ID:

我需要帮助来创建一个脚本,该脚本允许您运行多个bot令牌,而无需对每个bot始终重复命令代码,例如:

导入不一致
从discord.ext导入命令
导入异步
client1=commands.Bot(命令前缀='?')
client2=commands.Bot(命令前缀='?')
@client1.event
_ready()上的异步定义:
等待客户1.更改状态(活动=不和谐。游戏(“?命令”))
打印('连接到bot:{}'。格式(client1.user.name))
打印('Bot-ID:{}'。格式(client1.user.ID))
@client2.event
_ready()上的异步定义:
等待客户2.更改状态(活动=不和谐。游戏(“?命令”))
打印('连接到bot:{}'。格式(client2.user.name))
打印('Bot-ID:{}'。格式(client2.user.ID))
loop=asyncio.get\u event\u loop()
loop.create_任务(client1.start('ODExMzI2MTU1NzM0OTA4OTQ4.YCwkXQ.xxxxxxxxxxxxxxxxxxxx'))
创建_任务(client2.start('ODExMzI4NTU0NTc4MDgzODcx.YCwmmQ.xxxxxxxxxxxxxxxxxxxxxxxx'))
loop.run_forever()
我想把它变成这样:

import discord
from discord.ext import commands
import asyncio

client = commands.Bot(command_prefix='?')
token = ["ODExMzI2MTU1NzM0OTA4OTQ4.YCwkXQ.xxxxxxxxxxxxxxxxxxxxxxxxxxx",  "ODExMzI4NTU0NTc4MDgzODcx.YCwmmQ.xxxxxxxxxxxxxxxxxxxxxxxxxxx"]

@client.event
async def on_ready():
    await client.change_presence(activity=discord.Game('?commands'))
    print('Connected to bot: {}'.format(client.user.name))
    print('Bot ID: {}'.format(client.user.id))

client.run(token)
但是它说 发生异常:AttributeError “list”对象没有属性“strip”,任何人都可以帮助我吗?

也许可以试试

for tok in token:
  client.run(tok)


或者,或者将其抽象为一个新模块并创建多个实例(在函数中或作为一个类),我尝试这样做:
import discord from discord.ext import commands import asyncio client=commands.Bot(command_prefix='?')token=[“ODExMzI4NTU0NTc4MDgzODcx.YCwmmQ.xxxxxxxxx”,“ODExMzI2MTU1NzM0OTA4OTQ4.YCwkXQ.xxxxxxxx”]用于令牌中的tok:client.run(tok)
但它仅运行1个botoh,然后idk how
client = commands.Bot(command_prefix='?')
bot = commands.Bot(command_prefix='?')

bot.run('bottoken')
client.run('bottoken')