-
Notifications
You must be signed in to change notification settings - Fork 49
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #722 from nyxx-discord/dev
Deploy 6.5.0
- Loading branch information
Showing
43 changed files
with
938 additions
and
34 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,8 +2,9 @@ name: Run unit tests | |
|
||
on: | ||
push: | ||
branches-ignore: | ||
- main | ||
branches: | ||
- dev | ||
- next | ||
pull_request: | ||
|
||
jobs: | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
import 'dart:convert'; | ||
import 'dart:io'; | ||
import 'package:path/path.dart' as p; | ||
|
||
class SoundBuilder { | ||
List<int> data; | ||
String format; | ||
|
||
SoundBuilder({required this.data, required this.format}); | ||
|
||
SoundBuilder.mp3(this.data) : format = 'mpeg'; | ||
|
||
SoundBuilder.ogg(this.data) : format = 'ogg'; | ||
|
||
static Future<SoundBuilder> fromFile(File file, {String? format}) async { | ||
format ??= p.extension(file.path).substring(1); | ||
|
||
const formats = { | ||
'mp3': 'mpeg', | ||
'mpeg': 'mpeg', | ||
'ogg': 'ogg', | ||
}; | ||
|
||
final actualFormat = formats[format]; | ||
|
||
if (actualFormat == null) { | ||
throw ArgumentError.value(format, 'format', 'Unsupported format'); | ||
} | ||
|
||
final data = await file.readAsBytes(); | ||
|
||
return SoundBuilder(data: data, format: actualFormat); | ||
} | ||
|
||
List<int> buildRawData() => data; | ||
|
||
String buildDataString() => 'data:audio/$format;base64,${base64Encode(data)}'; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
import 'package:nyxx/src/builders/builder.dart'; | ||
import 'package:nyxx/src/builders/sentinels.dart'; | ||
import 'package:nyxx/src/builders/sound.dart'; | ||
import 'package:nyxx/src/models/snowflake.dart'; | ||
import 'package:nyxx/src/models/soundboard/soundboard.dart'; | ||
import 'package:nyxx/src/utils/building_helpers.dart'; | ||
|
||
class SoundboardSoundBuilder extends CreateBuilder<SoundboardSound> { | ||
String name; | ||
|
||
SoundBuilder sound; | ||
|
||
double? volume; | ||
|
||
String? emojiName; | ||
|
||
Snowflake? emojiId; | ||
|
||
SoundboardSoundBuilder({required this.name, required this.sound, this.volume, this.emojiName, this.emojiId}); | ||
|
||
@override | ||
Map<String, Object?> build() => { | ||
'name': name, | ||
'sound': sound.buildDataString(), | ||
if (volume != null) 'volume': volume, | ||
...makeEmojiMap(emojiId: emojiId, emojiName: emojiName), | ||
}; | ||
} | ||
|
||
class SoundboardSoundUpdateBuilder extends UpdateBuilder<SoundboardSound> { | ||
String name; | ||
|
||
double? volume; | ||
|
||
String? emojiName; | ||
|
||
Snowflake? emojiId; | ||
|
||
SoundboardSoundUpdateBuilder({required this.name, this.volume = sentinelDouble, this.emojiName = sentinelString, this.emojiId = sentinelSnowflake}); | ||
|
||
@override | ||
Map<String, Object?> build() => { | ||
'name': name, | ||
if (volume != sentinelDouble) 'volume': volume, | ||
if (!(identical(emojiName, sentinelString) || identical(emojiId, sentinelSnowflake))) ...makeEmojiMap(emojiId: emojiId, emojiName: emojiName), | ||
}; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.