通知设置总是相同的

发布于 2025-02-03 03:54:51 字数 418 浏览 3 评论 0原文

无论通知设置如何,提示始终等于notificationlevel.only_mentions。如果您在之前打印通知如果语句,它将打印正确的通知设置。我该如何修复?

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

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

  else:
    tip = "Tip: message2"

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"

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

一枫情书 2025-02-10 03:54:51
ctx.guild.default_notifications.name == "WhatYouWantToCompare"

应该是您想要的。您无法比较enum您尝试执行此操作的方式。

适应您的案子,这将是:

if notifications.name == "only_mentions":
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":
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文