Skip to content

Commit de39079

Browse files
committed
Added Message Functions
1 parent c4b551f commit de39079

File tree

5 files changed

+35
-0
lines changed

5 files changed

+35
-0
lines changed

src/index.ts

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,19 +6,34 @@ import {
66
parseGuildEvents,
77
parsePrivateChat,
88
parseSkyblockCoopChat,
9+
sendGuildMessage,
10+
sendPrivateMessage,
11+
sendSkyblockCoopMessage,
12+
sendGuildOfficerMessage,
913
} from "./modules/index.js";
1014

1115
import type { Bot } from "../types/index.d.ts";
1216
export type * from "../types/index.d.ts";
1317

1418
export const HyFlayer = (bot: Bot): void => {
19+
/* Structures */
1520
bot.mowojang = new MowojangClient();
1621
bot.hypixel = {
1722
location: {},
1823
} as Bot["hypixel"];
24+
25+
/* Functions */
26+
bot.sendGuildMessage = (msg: string) => sendGuildMessage(bot, msg);
27+
bot.sendGuildOfficerMessage = (msg: string) => sendGuildOfficerMessage(bot, msg);
28+
bot.sendPrivateMessage = (player: string, msg: string) => sendPrivateMessage(bot, player, msg);
29+
bot.sendSkyblockCoopMessage = (msg: string) => sendSkyblockCoopMessage(bot, msg);
30+
31+
/* Location Parsing */
1932
parseLocation(bot);
2033
bot.once("spawn", () => getLocation(bot));
2134
bot.on("respawn", () => getLocation(bot));
35+
36+
/* Chat Parsers */
2237
parsePrivateChat(bot);
2338
parseSkyblockCoopChat(bot);
2439
parseGuildChat(bot);

src/modules/guild.ts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,3 +71,11 @@ export const parseGuildEvents = (bot: Bot) => {
7171
});
7272
});
7373
};
74+
75+
export const sendGuildMessage = (bot: Bot, msg: string) => {
76+
bot.chat(`/gc ${msg}`);
77+
};
78+
79+
export const sendGuildOfficerMessage = (bot: Bot, msg: string) => {
80+
bot.chat(`/oc ${msg}`);
81+
};

src/modules/pm.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,3 +20,7 @@ export const parsePrivateChat = (bot: Bot) => {
2020
});
2121
});
2222
};
23+
24+
export const sendPrivateMessage = (bot: Bot, player: string, msg: string) => {
25+
bot.chat(`/msg ${player} ${msg}`);
26+
};

src/modules/skyblock.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,3 +20,7 @@ export const parseSkyblockCoopChat = (bot: Bot) => {
2020
});
2121
});
2222
};
23+
24+
export const sendSkyblockCoopMessage = (bot: Bot, msg: string) => {
25+
bot.chat(`/coop ${msg}`);
26+
};

types/index.d.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,10 @@ export interface Bot extends MineflayerBot {
5757
hypixel: {
5858
location: LocationEvent;
5959
};
60+
sendGuildMessage: (msg: string) => void;
61+
sendGuildOfficerMessage: (msg: string) => void;
62+
sendPrivateMessage: (player: string, msg: string) => void;
63+
sendSkyblockCoopMessage: (msg: string) => void;
6064
on<U extends keyof BotEvents>(event: U, listener: BotEvents[U]): this;
6165
once<U extends keyof BotEvents>(event: U, listener: BotEvents[U]): this;
6266
emit<U extends keyof BotEvents>(event: U, ...args: Parameters<BotEvents[U]>): void;

0 commit comments

Comments
 (0)