Skip to content

Commit

Permalink
Added text fields for Spotify related ENVs
Browse files Browse the repository at this point in the history
  • Loading branch information
furtidev committed Sep 2, 2022
1 parent 4660317 commit c6d12ad
Showing 1 changed file with 15 additions and 1 deletion.
16 changes: 15 additions & 1 deletion guicer.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,12 @@ def build(self) -> Column:
self.owner_id = TextField(
hint_text='Enter your Discord user ID'
)
self.spotify_client_secret = TextField(
hint_text='Enter your Spotify client secret'
)
self.spotify_client_id = TextField(
hint_text='Enter your Spotify client ID'
)
self.error_viewer = Text(
value='Please fill in all the text fields!',
color='red',
Expand All @@ -61,6 +67,10 @@ def build(self) -> Column:
self.bot_token,
Text(value='Owner ID', size=20),
self.owner_id,
Text(value='Spotify Client Secet', size=20),
self.spotify_client_secret,
Text(value='Spotify Client ID', size=20),
self.spotify_client_id,
IconButton(icon='check', bgcolor='white', icon_color='black', on_click=self.generate_config),
self.error_viewer,
self.success_viewer,
Expand All @@ -71,6 +81,8 @@ def generate_config(self, _) -> None:
if (
len(self.bot_token.value) == 0
or len(self.owner_id.value) == 0
or len(self.spotify_client_id.value) == 0
or len(self.spotify_client_secret.value) == 0
):
self.error_viewer.visible = True

Expand All @@ -79,7 +91,9 @@ def generate_config(self, _) -> None:
write_mode = 'w' if os.path.exists(here) else 'x'

with open(here, write_mode) as f:
f.write(f'DISCORD_TOKEN={self.bot_token.value}\nDISCORD_OWNER_ID={self.owner_id.value}')
f.write(f'''DISCORD_TOKEN={self.bot_token.value}\nDISCORD_OWNER_ID={self.owner_id.value}
SPOTIFY_CLIENT_SECRET={self.spotify_client_secret.value}
SPOTIFY_CLIENT_ID={self.spotify_client_id.value}''')
self.success_viewer.visible = True
self.update()

Expand Down

0 comments on commit c6d12ad

Please sign in to comment.