How to fix Attribute Error 'NoneType' object has no attribute 'strip'

43
September 21, 2021, at 04:50 AM

I am currently making a discord bot in python. I am relatively new and have no idea how to fix this error. It sounds like some other people have had this error before, but I'm not sure how to use their solutions in my code. So far the bot should just respond with "Hello!" when the user types "$hello" I expect this to return the message "Bot has connected to Discord!", but get this error - AttributeError: 'NoneType' object has no attribute 'strip'

Here is my code:

# bot.py
import os
import discord
from dotenv import load_dotenv
load_dotenv()
TOKEN = os.getenv('DISCORD_TOKEN')
client = discord.Client()

@client.event
async def on_ready():
    print(f'{client.user} has connected to Discord!')

async def on_message(message):
    if message.author == client.user:
        return
    if message.content.startswith('$hello'):
        await message.channel.send('Hello!')
client.run(os.getenv('DISCORD_TOKEN'))

Any solutions would be appreciated! Thanks

READ ALSO
Android - How to share dependencies between testImplementation and androidTestImplementation

Android - How to share dependencies between testImplementation and androidTestImplementation

I'm still fairly new to Android and Gradle, coming from a webdev/maven backgroundI have the MockK library which I want to use in both "normal" unit tests as well as instrumented androidTest tests

39
Rinvex laravel-addresses

Rinvex laravel-addresses

As a beginner Laravel, as using it for few weeks, I find it very frustrating and lost with Rinvex Laravel address and their instruction is a bit lost for beginner people like me, I have lookup google and seems not many details or induction on Rinvex...

54
Can't import from absolute paths using Typescript and NodeJS

Can't import from absolute paths using Typescript and NodeJS

I've tried many things to solve this issueI'm trying to import from absolute paths defined on my tsconfig

61
How to store data from user into Array or ArrayList? [closed]

How to store data from user into Array or ArrayList? [closed]

Want to improve this question? Add details and clarify the problem by editing this post

70