From c401709ce9a9bafe02035340d13f6f47e07514ca Mon Sep 17 00:00:00 2001 From: Tabby <41929769+tabby-cat-nya@users.noreply.github.com> Date: Sun, 2 Nov 2025 15:20:03 +1100 Subject: [PATCH] added support for .env filea nd made a new key --- .gitignore | 1 + main.gd | 21 +++++++++++---------- 2 files changed, 12 insertions(+), 10 deletions(-) diff --git a/.gitignore b/.gitignore index edadb58..7b8d11c 100644 --- a/.gitignore +++ b/.gitignore @@ -2,3 +2,4 @@ .godot/ /android/ environment.env +.env diff --git a/main.gd b/main.gd index d864358..bb22819 100644 --- a/main.gd +++ b/main.gd @@ -7,13 +7,14 @@ var interactions = {} var application_commands = {} -#func _load_bot_token() -> String: - ## read from .env file DISORD_BOT_TOKEN - #var lines = FileAccess.get_file_as_string(".env").split("\n") - #for line in lines: - #if line.begins_with("DISCORD_BOT_TOKEN="): - #return line.split("=")[1] - #return "" +func _load_bot_token() -> String: + # read from .env file DISORD_BOT_TOKEN + var lines = FileAccess.get_file_as_string(".env").split("\n") + #print(lines) + for line in lines: + if line.begins_with("DISCORD_BOT_TOKEN="): + return line.split("=")[1] + return "" func _ready() -> void: var bot = DiscordBot.new() @@ -22,9 +23,9 @@ func _ready() -> void: # Try to read token from global environment variables var token = OS.get_environment("DISCORD_BOT_TOKEN") if not token or (token and len(token) < 10): - # Read token from local .env file - #token = _load_bot_token() - token = "MTQzMzAyNTMwMzYzODQ0MjAzNQ.G3r4My.IdnvCw6xTBfoitEzvhPgxeErSDgcMCsznmLnvI" + #Read token from local .env file + token = _load_bot_token() + bot.TOKEN = token #bot.INTENTS = 4609