File tree Expand file tree Collapse file tree 2 files changed +23
-2
lines changed Expand file tree Collapse file tree 2 files changed +23
-2
lines changed Original file line number Diff line number Diff line change @@ -24,7 +24,12 @@ enum CdnFormat {
24
24
/// The Lottie format.
25
25
///
26
26
/// This is only available to sticker endpoints where [Sticker.formatType] is [StickerFormatType.lottie] .
27
- lottie._('lottie' );
27
+ lottie._('lottie' ),
28
+
29
+ /// The mp3/ogg format.
30
+ ///
31
+ /// This is only available to soundboard endpoints.
32
+ mp3._('' );
28
33
29
34
/// The extension to use on the CDN endpoint for this format.
30
35
final String extension ;
@@ -75,7 +80,11 @@ class CdnAsset {
75
80
for (final part in base .parts) {
76
81
route.add (part);
77
82
}
78
- route.add (HttpRoutePart ('$hash .${format .extension }' ));
83
+
84
+ // Soundboard assets don't have any extension.
85
+ final ext = format == CdnFormat .mp3 ? '' : '.${format .extension }' ;
86
+
87
+ route.add (HttpRoutePart ('$hash $ext ' ));
79
88
80
89
return CdnRequest (route, queryParameters: {if (size != null ) 'size' : size.toString ()});
81
90
}
Original file line number Diff line number Diff line change
1
+ import 'package:nyxx/src/http/cdn/cdn_asset.dart' ;
1
2
import 'package:nyxx/src/http/managers/soundboard_manager.dart' ;
3
+ import 'package:nyxx/src/http/route.dart' ;
2
4
import 'package:nyxx/src/models/emoji.dart' ;
3
5
import 'package:nyxx/src/models/guild/guild.dart' ;
4
6
import 'package:nyxx/src/models/snowflake.dart' ;
@@ -10,6 +12,16 @@ class PartialSoundboardSound extends WritableSnowflakeEntity<SoundboardSound> {
10
12
final SoundboardManager manager;
11
13
12
14
PartialSoundboardSound ({required super .id, required this .manager});
15
+
16
+ /// The sound asset for this soundboard sound.
17
+ CdnAsset get sound => CdnAsset (
18
+ client: manager.client,
19
+ base : HttpRoute ()..soundboardSounds (),
20
+ // We can't use .soundboardSounds(id: id.toString()) because hash would be empty, adding an empty string will populate
21
+ // `route.segments` which will join it with a trailing slash and Discord doesn't handle trailing slashes.
22
+ hash: id.toString (),
23
+ defaultFormat: CdnFormat .mp3,
24
+ );
13
25
}
14
26
15
27
class SoundboardSound extends PartialSoundboardSound {
You can’t perform that action at this time.
0 commit comments