1
0
forked from noxious/server

Update command manager and commands to OOP

This commit is contained in:
2024-09-30 22:29:58 +02:00
parent 3ec4bc2557
commit 6ac827630a
4 changed files with 68 additions and 46 deletions

View File

@ -2,8 +2,12 @@ import { Server } from 'socket.io'
type CommandInput = string[]
module.exports = function (input: CommandInput, io: Server) {
const message: string = input.join(' ') ?? null
if (!message) return console.log('message is required')
io.emit('notification', { message: message })
}
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 })
}
}