通知设置总是相同的
无论通知设置如何,提示
始终等于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 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
应该是您想要的。您无法比较
enum
您尝试执行此操作的方式。适应您的案子,这将是:
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: