import {CommandBus, CommandHandler, EventBus, ICommandHandler} from "@nestjs/cqrs";
import {BanPlayerCommand} from "../commands/ban-player.command";
import {Promise} from "mongoose";
import {SetGuestPropertyCommand} from "../../guests/command/set-guest-property.command";
@CommandHandler(BanPlayerCommand)
export class BanPlayerCommandHandler implements ICommandHandler<BanPlayerCommand> {
  constructor(private eventBus: EventBus, private commandBus: CommandBus) {
  }
  async execute(command: BanPlayerCommand): Promise<any> {
    await this.commandBus.execute(new SetGuestPropertyCommand(command.user, 'bannedFor', '2'));
    return Promise.resolve(true);
  }

}