通知设置始终相同

Notification settings always being the same

无论通知设置如何,tip 将始终等于 NotificationLevel.only_mentions。但是,如果您在 if 语句之前打印 notifications,它将打印正确的通知设置。我该如何解决?

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

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

  else:
    tip = "Tip: message2"
ctx.guild.default_notifications.name == "WhatYouWantToCompare"

应该是你要找的。您无法比较 Enum 您尝试这样做的方式。

根据你的情况,应该是:

if notifications.name == "only_mentions":