無論通知設定如何,tip都將始終等于NotificationLevel.only_mentions。但是,如果您notifications在 if 陳述句之前列印,它將列印正確的通知設定。有任何想法嗎?
@bot.command()
async def notifications(ctx):
notifications = ctx.guild.default_notifications
if notifications == "NotificationLevel.only_mentions":
tip = "Tip: message1"
else:
tip = "Tip: message2"
uj5u.com熱心網友回復:
ctx.guild.default_notifications.name == "WhatYouWantToCompare"
應該是你正在尋找的。您無法比較Enum您嘗試執行此操作的方式。
適應您的情況,它將是:
if notifications.name == "only_mentions":
轉載請註明出處,本文鏈接:https://www.uj5u.com/caozuo/483882.html
上一篇:Ruby浮動到日期時間
