mineral-dart / core

🧡 The neuralgic heart of the application, this module gathers all the functionalities of the framework.
https://mineral-foundation.org
MIT License
27 stars 8 forks source link

[Packet] - Add rest of the implementation in guild ban add #172

Closed LeadcodeDev closed 2 months ago

LeadcodeDev commented 4 months ago

Missing cache alteration

Please consider :

final class GuildBanAddPacket implements ListenablePacket {
  @override
  PacketType get packetType => PacketType.guildBanAdd;

  final LoggerContract logger;
  final MarshallerContract marshaller;

  const GuildBanAddPacket(this.logger, this.marshaller);

  @override
  Future<void> listen(ShardMessage message, DispatchEvent dispatch) async {
    final server = await marshaller.dataStore.server.getServer(message.payload['guild_id']);
    final user = await marshaller.serializers.user.serializeRemote(message.payload['user']);
    final member = server.members.list[user.id];

    logger.trace('GuildBanAddPacket: ${user.username} was ban in ${server.name}');

    dispatch(event: Event.serverBanAdd, params: [member, user, server]);

    server.members.list.remove(user.id);
  }
}