Binato/server/Bot.ts

34 lines
1.1 KiB
TypeScript
Raw Permalink Normal View History

2023-09-10 12:59:22 +01:00
import ICommand from "./interfaces/ICommand";
import Channel from "./objects/Channel";
import Shared from "./objects/Shared";
import User from "./objects/User";
2023-08-20 13:03:01 +01:00
// Commands
2023-09-10 12:59:22 +01:00
import RankingCommand from "./commands/Ranking";
2023-10-04 16:13:16 +01:00
import AdminCommand from "./commands/Admin";
2023-09-10 12:59:22 +01:00
import MultiplayerCommands from "./commands/Multiplayer";
import HelpCommand from "./commands/Help";
import RollCommand from "./commands/Roll";
2023-08-20 13:03:01 +01:00
2023-09-10 12:59:22 +01:00
export default class Bot {
2023-08-20 13:03:01 +01:00
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);
2023-10-04 16:13:16 +01:00
this.commands["admin"] = new AdminCommand(shared);
2023-08-20 13:03:01 +01:00
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);
}
}
}