Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix/command role and member serialization #226

Merged
merged 2 commits into from
Dec 26, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
# 4.0.0-dev.8
- Fix `Member` option in commands
- Fix `Role` option in commands

# 4.0.0-dev.7
- Add missing `LogLevel` enum in exports
- Fix parent channel as ServerChannel
Expand Down
11 changes: 6 additions & 5 deletions lib/src/domains/commands/command_interaction_dispatcher.dart
Original file line number Diff line number Diff line change
Expand Up @@ -81,15 +81,16 @@ final class CommandInteractionDispatcher

options[Symbol(option['name'])] = switch (type) {
CommandOptionType.user => switch (commandContext) {
ServerCommandContext() => await _dataStore.member.getMember(
serverId: commandContext.server.id,
memberId: option['value']),
ServerCommandContext() => await _dataStore.member
.getMember(serverId: commandContext.server.id, memberId: option['value'])
..server = commandContext.server,
_ => _marshaller.serializers.user.serialize(option['value']),
},
CommandOptionType.channel =>
await _marshaller.serializers.channels.serialize(option['value']),
CommandOptionType.role =>
await _marshaller.serializers.role.serialize(option['value']),
CommandOptionType.role => await _dataStore.role.getRole(
serverId: data['guild_id'],
roleId: option['value']),
// TODO attachement
_ => option['value'],
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ final class MemberPart implements MemberPartContract {
@override
Future<Member> getMember(
{required Snowflake serverId, required Snowflake memberId}) async {

final cacheKeys = _marshaller.cacheKey;
final memberCacheKey = cacheKeys.member(serverId, memberId);

Expand Down
2 changes: 1 addition & 1 deletion pubspec.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
name: mineral
description: Mineral is a Discord framework for designing discord bots in Dart.
version: 4.0.0-dev.7
version: 4.0.0-dev.8

repository: https://github.com/mineral-dart/core
# homepage: https://www.example.com
Expand Down