[英]'The default Firebase app does not exist. Make sure to initialize the SDK by calling initialize_app()'
I'm trying to make a python discord bot with the use of the Firebase Realtime Database for datastores.我正在尝试使用用于数据存储的 Firebase 实时数据库制作一个 python discord 机器人。 I'm initializing the app at the start of the script, however, when I try to create a reference I get the error
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()
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 don't know why this is happening since I initialized it?我不知道为什么会这样,因为我初始化了它? Some code samples:
一些代码示例:
### 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()
Help is greatly appreciated!非常感谢您的帮助!
Turns out, if you give the application no name it will start working again.事实证明,如果您不给应用程序命名,它将再次开始工作。 Thanks to MatsLindh for the answer.
感谢 MatsLindh 的回答。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.