server/src/commands/alert.ts
2024-09-30 22:42:46 +02:00

14 lines
368 B
TypeScript

import { Server } from 'socket.io'
type CommandInput = string[]
export default class AlertCommand {
constructor(private readonly io: Server) {}
public execute(input: CommandInput): void {
const message: string = input.join(' ') ?? null
if (!message) return console.log('message is required')
this.io.emit('notification', { message: message })
}
}