Skip to content

if msg: not returning True when msg != None where msg is discord.Message #212

@nosv1

Description

@nosv1

Summary

using a discord.Message as a boolean no longer works.

Reproduction Steps

msg = some discord.Message object
if msg:
  print('yes')

the print doesn't get printed

this appears to have been broken sometime between 1.7.3 to 2.0.0a as downgrading from 2.0.0a to 1.7.3 solved the issue.

Minimal Reproducible Code

# get msg
    msg = None
    msg_id = Support.get_id_from_str(args[3])
    msg_id = int(msg_id[0]) if msg_id else None
    try:
        msg = await channel.fetch_message(msg_id) if channel and msg_id else None    
    except discord.errors.NotFound:
        pass # error message below

    if msg and msg.author.id == Support.ids.phyner_id: # msg found and phyner is author
        embed = msg.embeds[0] if msg.embeds else None
        ...

Expected Results

normally, if it found the message, it would enter that bottom if statement given msg is not None

Actual Results

it doesn't consider if msg != None equal to if msg:

Intents

intents = discord.Intents.all()

System Information

python 3.9.5
py-cord 2.0.0a

py-cord 1.7.3 appears to work

Checklist

  • I have searched the open issues for duplicates.
  • I have shown the entire traceback, if possible.
  • I have removed my token from display, if visible.

Additional Context

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    unconfirmed bugA bug report that needs triaging

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions