Back

[python SDK] unsupported operand type(s) for +: 'NoneType' and 'str'

  • 0
  • Databases
  • Cloud
! Himanshu<3
26 Jan, 2024, 06:15

Help me in python sdk idk why this error occured but it was not before 2 days it occured today even if the data is not None it says none and am also providing the same data type as in attribute.

Codes.

TypeScript
@commands.command(name="addofficial", aliases=['addstaff', 'aoff'], help="Adds an user as official to DB.")
    @commands.is_owner()
    async def addofficial(self, ctx: commands.Context, user: discord.Member):
       if not user:
          await ctx.send("Please mention/send an userId")
       else:
          await addOfficialToDB(id=str(user.id))
       await ctx.send("Done!")

addOfficialToDB func,

TypeScript
async def addOfficialToDB(id: str):
    try:
        databases.create_document(
            database_id=os.environ.get("DB_ID"),
            collection_id=os.environ.get("DB_OFFC_COLLECTION_ID"),
            document_id=ID.unique(),
            data={
                "id": str(id)
            }
        )
        await WebLog(f"Added official {id} to database.")
    except AppwriteException as e:
        print(e.message)

Error:

TypeScript
 unsupported operand type(s) for +: 'NoneType' and 'str'
TL;DR
The developer is encountering an error in their Python SDK code. The error states "unsupported operand type(s) for +: 'NoneType' and 'str'". They mention that the error just started occurring today and they are providing the correct data type in the attribute. The provided code shows a function called `addofficial` which is a Discord bot command. It takes a mention of a user as an argument and tries to add that user as an official to a database using the `addOfficialToDB` function. If the `user` argument is not provided, it sends a message asking for the user to be mentioned or their ID
Drake
26 Jan, 2024, 06:20

Maybe the environment variables aren't set

Drake
26 Jan, 2024, 06:27

Btw, I suggest you don't wrap stuff with str because you're forcing things to be strings which can mask problems

! Himanshu<3
26 Jan, 2024, 06:44

let me try this if it can fix

! Himanshu<3
26 Jan, 2024, 06:44

huh everything is fine

! Himanshu<3
26 Jan, 2024, 06:44

in .env

Reply

Reply to this thread by joining our Discord

Reply on Discord

Need support?

Join our Discord

Get community support by joining our Discord server.

Join Discord

Get premium support

Join Appwrite Pro and get email support from our team.

Learn more