The method direct.send()
is used to send a direct message to a specific user. It requires two parameters: the user ID of the recipient and the message to be sent.
// Assuming you have defined the Highrise instance as "bot".
bot.on("messageCreate", (user_id, data, message) => {
if (message === "hello") {
bot.direct.send(data.id, "Hello, world!").catch(e => console.error(e));
}
});
Note: ****In order to receive messages, AutoFetchMessages
should be enabled in the Highrise configuration. Here's an example of how to enable AutoFetchMessages
:
const bot = new Highrise({
Events: [
Events.DirectMessages // Listen for direct messages.
],
AutoFetchMessages: true, // Fetches messages on direct message events.
});
Go Back: Sending Messages