Binato/server/Bot.ts
2023-10-04 16:13:16 +01:00

34 lines
No EOL
1.1 KiB
TypeScript

import ICommand from "./interfaces/ICommand";
import Channel from "./objects/Channel";
import Shared from "./objects/Shared";
import User from "./objects/User";
// Commands
import RankingCommand from "./commands/Ranking";
import AdminCommand from "./commands/Admin";
import MultiplayerCommands from "./commands/Multiplayer";
import HelpCommand from "./commands/Help";
import RollCommand from "./commands/Roll";
export default class Bot {
public user:User;
private commands:{ [id: string]: ICommand } = {};
public constructor(shared:Shared, botUser:User) {
this.user = botUser;
this.commands["help"] = new HelpCommand(shared, this.commands);
this.commands["ranking"] = new RankingCommand(shared);
this.commands["admin"] = new AdminCommand(shared);
this.commands["mp"] = new MultiplayerCommands(shared);
this.commands["roll"] = new RollCommand(shared);
}
public OnMessage(channel:Channel, sender:User, text:string) {
const args = text.split(" ");
const command = this.commands[`${args.shift()?.replace("!", "").toLowerCase()}`];
if (command) {
command.exec(channel, sender, args);
}
}
}