This commit is contained in:
array-in-a-matrix 2023-11-06 13:41:23 -05:00
parent e39dc85ddc
commit f0b9e7b1ba

View file

@ -2,6 +2,7 @@ import config from './config.json' assert {type: "json"};
import { MatrixClient, SimpleFsStorageProvider, AutojoinRoomsMixin } from "matrix-bot-sdk";
const storage = new SimpleFsStorageProvider("storage.json");
client.addPreprocessor(new RichRepliesPreprocessor(false));
const client = new MatrixClient(config.homeserver, config.token, storage);
AutojoinRoomsMixin.setupOnClient(client);
@ -11,8 +12,9 @@ client.start().then(() => console.log(`Client has started!`));
client.on("room.message", (roomId, event) => {
// ? check if the message's text is not empty and isn't sent by the bot itself
if (! event["content"] || event["sender"] === config.user) return;
const message = event["content"]["body"].toLowerCase();
// ? if message starts with the bot's <prefix + command> then execute the command
if (event["content"]["body"].toLowerCase().startsWith(config.prefix + "COMMAND")){
if (message.startsWith(config.prefix + "COMMAND")){
//
// TODO: START CODE HERE