我在这里使用python。
当我为我正在使用 replit 制作的不和谐机器人运行代码时,我收到此错误:AttributeError: 'NoneType' object has no attribute 'strip'
我正在使用本教程制作一个不和谐的机器人:https ://www.freecodecamp.org/news/create-a-discord-bot-with-python/
代码:
import discord
import os
client = discord.Client()
@client.event
async def on_ready():
print('We have logged in as {Funni bot B)}'.format(client))
@client.event
async def on_message(message):
if message.author == client.user:
return
if message.content.startswith('$IHaveNoBobux'):
await message.channel.send('haha sucks to be you B)')
if message.content.startswith('$GiveMeFreeBobuxNow'):
await message.channel.send('no stupid noob B)')
client.run(os.getenv('TOKEN'))
有人可以帮我解决这个错误吗?我的大脑很小,几乎没有蟒蛇,所以有些事情可能需要大量解释。:/
这是我运行代码时的完整控制台:
回溯(最后一次调用):文件“main.py”,第 21 行,在 client.run(os.getenv('TOKEN')) 文件“/home/runner/go-away-this-isnt-for-you /venv/lib/python3.8/site-packages/discord/client.py”,第 723 行,在运行中返回 future.result() 文件“/home/runner/go-away-this-isnt-for-you/ venv/lib/python3.8/site-packages/discord/client.py”,第 702 行,在运行器中等待 self.start(*args, **kwargs) 文件“/home/runner/go-away-this-isnt -for-you/venv/lib/python3.8/site-packages/discord/client.py”,第 665 行,在开始等待 self.login(*args, bot=bot) 文件“/home/runner/go- away-this-isnt-for-you/venv/lib/python3.8/site-packages/discord/client.py”,第 511 行,登录等待 self.http.static_login(token.strip(), bot=bot ) AttributeError: 'NoneType' 对象没有属性 'strip'
我还有一个名为“env”的环境,其中包含以下内容:
TOKEN=[the discord bots token is would be right here but im not going to show it because its the password]