Skip to content

Commit

Permalink
don't accept empty env variables 😅
Browse files Browse the repository at this point in the history
  • Loading branch information
pixelcmtd committed Dec 28, 2024
1 parent ef468b2 commit 67dbc4c
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 6 deletions.
13 changes: 8 additions & 5 deletions bin/jana.dart
Original file line number Diff line number Diff line change
Expand Up @@ -52,17 +52,20 @@ extension SendJson on TextChannel {
}

void main(List<String> argv) async {
final token = Platform.environment['JANA_DISCORD_TOKEN'] ?? argv.firstOrNull;
final env = Platform.environment;
final token = env['JANA_DISCORD_TOKEN']?.isNotEmpty ?? false
? env['JANA_DISCORD_TOKEN']
: argv.firstOrNull;
if (token == null || token.isEmpty) {
stderr.writeln('No token provided (env JANA_DISCORD_TOKEN or pass as arg)');
exit(1);
}

final lavalink = Platform.environment.containsKey('JANA_LAVALINK_BASE') &&
Platform.environment.containsKey('JANA_LAVALINK_PASSWORD')
final lavalink = (env['JANA_LAVALINK_BASE']?.isNotEmpty ?? false) &&
(env['JANA_LAVALINK_PASSWORD']?.isNotEmpty ?? false)
? LavalinkPlugin(
base: Uri.parse(Platform.environment['JANA_LAVALINK_BASE']!),
password: Platform.environment['JANA_LAVALINK_PASSWORD']!,
base: Uri.parse(env['JANA_LAVALINK_BASE']!),
password: env['JANA_LAVALINK_PASSWORD']!,
)
: null;

Expand Down
2 changes: 1 addition & 1 deletion pubspec.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
name: jana
description: A Discord bot
version: 2.0.0-beta.1
version: 2.0.0-beta.2
homepage: https://github.com/chrissxMedia/jana

environment:
Expand Down

0 comments on commit 67dbc4c

Please sign in to comment.