Skip to content

Latest commit

 

History

History
139 lines (100 loc) · 4.86 KB

events.md

File metadata and controls

139 lines (100 loc) · 4.86 KB

Events

Instead of sending confirmation messages for example, you can use events integrated in the module. These give you more flexibility, including the possibility to translate messages. There are many different events available, including the following:


starboardCreate

This event is emitted when a starboard is created. It can be used to send a confirmation message in the starboard's channel, to set up a log system, ... The callback function is invoked with the new starboard as argument.

manager.on("starboardCreate", (data) => {
  const channel = client.channels.cache.get(data.channelId);
  channel.send(`This channel is now a starboard!`);
});

starboardDelete

This event is emitted when a starboard is deleted or when the channel of this starboard is deleted. It can be used to send a confirmation message in the starboard channel, to make a log system, ... The callback function is invoked with the deleted starboard as argument.

manager.on("starboardDelete", (data) => {
  const channel = client.channels.cache.get(data.channelId);
  if (channel) channel.send(`Starboard deleted ! ChannelID: ${data.channelId}`);
});

starboardReactionAdd

This event is emitted when a user reacts to a message eligible for the starboard, whether the message is cached or not. If the message does not meet the criteria of the options (ex: allowNsfw, starBotMsg, ...) then the event will not be emitted. The callback function is invoked with the emoji, the message and the user as arguments.

manager.on("starboardReactionAdd", (emoji, message, user) => {
  console.log(`${user.username} reacted to a message with ${emoji} (message id: ${message.id}).`);
});

starboardReactionRemove

Like the starboardReactionAdd event, this event is emitted when a user removes his reaction from an eligible message to the starboard, whether it is cached or not. The callback function is invoked with the emoji, the message and the user as arguments.

manager.on("starboardReactionRemove", (emoji, message, user) => {
  console.log(`${user.username} removed his reaction (${emoji}) to a message (id: ${message.id}).`);
});

starboardReactionRemoveAll

This event is emitted when all reactions of a message are deleted at once. The callback function is invoked with the message as argument.

manager.on("starboardReactionRemoveAll", (message) => {
  console.log(`The reactions of the message with id ${message.id} have all been removed.`);
});

starboardReactionNsfw

This event is emitted when a user reacts to a message in an nsfw channel whereas the starboard corresponding to his reaction has the allowNsfw option disabled. The callback function is invoked with the emoji, the message and the user as arguments.

manager.on("starboardReactionNsfw", (emoji, message, user) => {
  message.channel.send(
    `${user.username}, you cannot add messages from an nsfw channel to the starboard.`,
  );
});

starboardNoSelfStar

This event is emitted when a user reacts to a message whereas the starboard corresponding to his reaction has the selfStar option disabled. The callback function is invoked with the emoji, the post and the user as arguments.

manager.on("starboardNoSelfStar", (emoji, message, user) => {
  message.channel.send(`${user.username}, you cannot star your own messages.`);
});

starboardNoStarBot

This event is emitted when a user reacts to a bot message whereas the starboard corresponding to his reaction has the starBot option disabled. The callback function is invoked with the emoji, the message and the user as arguments.

manager.on("starboardNoStarBot", (emoji, message, user) => {
  message.channel.send(`${user.username}, you cannot star bot messages.`);
});

starboardAlreadyStarred

This event is emitted when a user reacts to a starboard embed. The callback function is invoked with the emoji, the message and the user as arguments.

manager.on("starboardAlreadyStarred", (emoji, message, user) => {
  message.channel.send(`${user.username}, this message is already in the starboard.`);
});

starboardNoEmptyMsg

This event is emitted when a user reacts to a message that has no exploitable content. For example, a message that has neither text nor image (like some embeds). The callback function is invoked with the emoji, the message and the user as arguments.

manager.on("starboardNoEmptyMsg", (emoji, message, user) => {
  message.channel.send(`${user.username}, you cannot star an empty message.`);
});

starboardEdited

This event is emitted when a starboard is modified. The callback function is invoked with the old starboard and the new starboard as arguments.

manager.on("starboardEdited", (oldStarboard, newStarboard) => {
  const channel = client.channels.cache.get(newStarboard.channelId);
  channel.send(`Starboard (channel ${newStarboard.channelId}) edited !`);
});