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, Signals, execute } from 'sunar';

const signal = new Signal(Signals.GuildMemberAdd);

execute(signal, (message) => {
	// handle execution
});

export { signal };

Implementation

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

import { Signal, Signals, execute } from 'sunar';
import { TextChannel } from 'discord.js';

const signal = new Signal(Signals.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

Prop

Type

Sunar Signals

Prop

Type

Find all available events in the discord.js documentation.

How is this guide?

Last updated on