diff --git a/lib/nyxx_extensions.dart b/lib/nyxx_extensions.dart index 811e2ff..9d81c80 100644 --- a/lib/nyxx_extensions.dart +++ b/lib/nyxx_extensions.dart @@ -30,3 +30,4 @@ export 'src/extensions/role.dart'; export 'src/extensions/scheduled_event.dart'; export 'src/extensions/snowflake_entity.dart'; export 'src/extensions/user.dart'; +export 'src/extensions/list.dart'; diff --git a/lib/src/extensions/list.dart b/lib/src/extensions/list.dart new file mode 100644 index 0000000..6aec1a0 --- /dev/null +++ b/lib/src/extensions/list.dart @@ -0,0 +1,11 @@ +import 'package:nyxx/nyxx.dart'; + +/// Extensions for fetching lists of [SnowflakeEntity]s. +extension PartialList> + on List> { + /// Get all the entities in this list using the cached entity if possible. + Future> get() => Future.wait(map((entity) => entity.get())); + + /// Fetch all the entities in this list. + Future> fetch() => Future.wait(map((entity) => entity.fetch())); +}