Search code examples
pythonif-statementdiscordnotificationsdiscord.py

Notification settings always being the same


No matter the notification settings, tip will always be equal to NotificationLevel.only_mentions. If you print notifications before the if statement however, it will print the correct notification settings. How can I fix it?

@bot.command()
async def notifications(ctx):
  notifications = ctx.guild.default_notifications

  if notifications == "NotificationLevel.only_mentions":
    tip = "Tip: message1"

  else:
    tip = "Tip: message2"

Solution

  • ctx.guild.default_notifications.name == "WhatYouWantToCompare"
    

    Should be what you are looking for. You can't compare an Enum the way you are trying to do this.

    Adapted to your case, it would be:

    if notifications.name == "only_mentions":