Sending Messages Outside the Main Client

SkillCommunication

Explains how to send Discord messages from cron jobs that don't have a NypsiClient/gateway connection, covering WebhookClient vs the shared getRest() REST client. Use when writing or editing a scheduled job in src/scheduled/jobs/ that needs to post a message to a channel.

Available today. Use it from your connected AI after setup.

Connect ahel once, and every AI you use reads what you have installed.

Then ask your AI: use the Sending Messages Outside the Main Client skill

What this skill tells your AI

The instructions your AI receives, as published by mxz7/nypsi in .agents/skills/discord-messaging/SKILL.md and read by ahel’s review.

Two patterns exist in src/scheduled/jobs/ for posting messages from cron jobs (no NypsiClient/gateway connection available):

  1. WebhookClient (discord.js) - used when a dedicated webhook URL exists in env (e.g. LOTTERY_HOOK, TOPCOMMANDS_HOOK, per-guild birthdayHook). Simple, but requires a webhook to be created/stored per destination.
  2. Shared REST client (src/utils/rest.ts, getRest()) - wraps @discordjs/rest, authed with BOT_TOKEN. Post directly to a channel with rest.post(Routes.channelMessages(channelId), { body: { embeds: [...] } }). Embeds must be plain JSON (.toJSON() on CustomEmbed/EmbedBuilder instances, not the builder objects themselves). Preferred when you already know a channel ID and don't want to manage a separate webhook URL/secret (e.g. topbalance.ts posts to channel 833052442069434429 this way).

getRest(client?) returns client.rest if a NypsiClient is passed (has an active gateway connection), otherwise a standalone REST instance - use the standalone version in jobs since they don't have a client instance.

Signals

GitHub stars
69
Forks
31
Last commit
Sep 2026

ahel review

  • S4info
    community integration — published by mxz7, not discord

Automated review, not a security audit. Ruleset v1.

Advanced
Catalog kind
skill
Gateway key
discord-messaging
Source
github.com/mxz7/nypsi