![](/img/trans.png)
[英]The default Firebase app does not exist. Make sure you call initializeApp() before using any of the Firebase services. at FirebaseAppError
[英]'The default Firebase app does not exist. Make sure to initialize the SDK by calling initialize_app()'
我正在嘗試使用用於數據存儲的 Firebase 實時數據庫制作一個 python discord 機器人。 我在腳本開頭初始化應用程序,但是,當我嘗試創建引用時,出現錯誤The default Firebase app does not exist. Make sure to initialize the SDK by calling initialize_app()
The default Firebase app does not exist. Make sure to initialize the SDK by calling initialize_app()
。 我不知道為什么會這樣,因為我初始化了它? 一些代碼示例:
### I initialise the firebase app here?
# Variable def
client = commands.Bot(command_prefix=">", help_command=None)
slash = SlashCommand(client, sync_commands=True)
token = os.environ['TOKEN']
BotGuilds = [916737523017986079]
cred_obj = firebase_admin.credentials.Certificate('rtdb-key.json')
firebase_admin.initialize_app(cred_obj, {
'databaseURL':'https://datastoretuu-default-rtdb.firebaseio.com/'
}, f"main_bot")
### Cause of error
async def info(ctx: SlashContext, player: str=None):
if player is None:
player = ctx.author.nick
tuu_logo = get(ctx.guild.emojis, name="tuu")
pm_logo = get(ctx.guild.emojis, name="pm")
roblox_logo = get(ctx.guild.emojis, name="roblox")
discord_logo = get(ctx.guild.emojis, name="discord")
apiresponse = requests.get(f"https://api.roblox.com/users/get-by-username?username={player}").json()
playerid = apiresponse['Id']
current_ref = db.reference(f"TUUPointStorage/{playerid}/Points")
# ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - Error is here
result = current_ref.get()
非常感謝您的幫助!
事實證明,如果您不給應用程序命名,它將再次開始工作。 感謝 MatsLindh 的回答。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.