Skip to content

Commit

Permalink
Merge pull request #33 from nyxx-discord/feature/sonarr-wizarr-integr…
Browse files Browse the repository at this point in the history
…ation

basic sonarr impl; fix postgres code
  • Loading branch information
l7ssha authored Oct 17, 2024
2 parents c5f2c98 + eb18dba commit e04bf40
Show file tree
Hide file tree
Showing 19 changed files with 1,577 additions and 459 deletions.
13 changes: 10 additions & 3 deletions bin/running_on_dart.dart
Original file line number Diff line number Diff line change
Expand Up @@ -36,11 +36,18 @@ void main() async {
..addConverter(manageableTagConverter)
..addConverter(durationConverter)
..addConverter(reminderConverter)
..addConverter(packageDocsConverter);
..addConverter(packageDocsConverter)
..addConverter(jellyfinConfigConverter)
..addConverter(jellyfinConfigUserConverter);

commands.onCommandError.listen((error) {
if (error is CheckFailedException) {
error.context.respond(MessageBuilder(content: "Sorry, you can't use that command!"));
return;
}

if (error is UncaughtException && error.exception is JellyfinConfigNotFoundException) {
error.context.respond(MessageBuilder(content: error.message));
}
});

Expand Down Expand Up @@ -70,10 +77,10 @@ void main() async {
..registerSingleton(() => ModLogsModule())
..registerSingleton(() => TagModule())
..registerSingleton(() => DocsModule())
..registerSingleton(() => JellyfinModule());
..registerSingleton(() => JellyfinModuleV2());

await Injector.appInstance.get<DatabaseService>().init();
await Injector.appInstance.get<JellyfinModule>().init();
await Injector.appInstance.get<JellyfinModuleV2>().init();
await Injector.appInstance.get<DocsModule>().init();
await Injector.appInstance.get<TagModule>().init();
await Injector.appInstance.get<ModLogsModule>().init();
Expand Down
28 changes: 1 addition & 27 deletions lib/src/checks.dart
Original file line number Diff line number Diff line change
Expand Up @@ -37,32 +37,6 @@ Future<(bool?, FeatureSetting?)> fetchAndCheckSetting(CommandContext context) as
return (null, setting);
}

final jellyfinFeatureUserCommandCheck = Check(
(CommandContext context) async {
final (checkResult, setting) = await fetchAndCheckSetting(context);
if (checkResult != null) {
return checkResult;
}

final roleId = Snowflake.parse(setting!.dataAsJson!['user_commands_role']);

return context.member!.roleIds.contains(roleId);
},
);

final jellyfinFeatureAdminCommandCheck = Check(
(CommandContext context) async {
final (checkResult, setting) = await fetchAndCheckSetting(context);
if (checkResult != null) {
return checkResult;
}

final roleId = Snowflake.parse(setting!.dataAsJson!['admin_commands_role']);

return context.member!.roleIds.contains(roleId);
},
);

final jellyfinFeatureCreateInstanceCommandCheck = Check(
(CommandContext context) async {
final (checkResult, setting) = await fetchAndCheckSetting(context);
Expand All @@ -72,6 +46,6 @@ final jellyfinFeatureCreateInstanceCommandCheck = Check(

final roleId = Snowflake.parse(setting!.dataAsJson!['create_instance_role']);

return context.member!.roleIds.contains(roleId);
return (context.member?.permissions?.isAdministrator ?? false) || context.member!.roleIds.contains(roleId);
},
);
Loading

0 comments on commit e04bf40

Please sign in to comment.