Skip to content

Commit

Permalink
Merge pull request #32 from nyxx-discord/maintenance/update-postgres-…
Browse files Browse the repository at this point in the history
…package

maintenance: Update postgres package
  • Loading branch information
l7ssha authored Oct 17, 2024
2 parents 3b41455 + e04bf40 commit 987fd72
Show file tree
Hide file tree
Showing 20 changed files with 1,589 additions and 479 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 987fd72

Please sign in to comment.