Sunar

Signal

Signals in Sunar correspond to events in discord.js. They allow you to handle various actions and responses that occur within your Discord bot, such as messages being sent, users joining or leaving, and more.

Usage

import { Signal, execute } from 'sunar';
 
const signal = new Signal('messageCreate');
 
execute(signal, (message) => {
	// handle execution
});
 
export { signal };

Implementation

The following example demonstrates how to implement a Signal using Sunar:

import { Signal, execute } from 'sunar';
import { TextChannel } from 'discord.js';
 
const signal = new Signal('guildMemberAdd');
 
execute(signal, (member) => {
	const channel = member.guild.channels.cache.find(
		(c) => c.name === 'welcomes',
	);
 
	if (!(channel instanceof TextChannel)) return;
 
	channel.send({ content: `${member} just joined!` });
});
 
export { signal };

Reference

SignalOptions

PropTypeDefault
once
boolean
-

Last updated on

On this page

GitHubEdit on Github ↗