Skip to content

IsoBones/wedgetail

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Wedgetail — Discord Unit Advertisement Bot

Discord bot for managing Arma unit recruitment ads with a 14-day cooldown, in-place edit/delete, and clean embed posts.

Features

  • /advertise slash command opens a 5-field modal (unit name, op times, era(s), important info, Discord invite)
  • Posts a tidy embed alongside an @user is recruiting for **Unit Name** message + the invite, so Discord still auto-embeds the unit's server preview
  • 14-day cooldown between fresh posts
  • Edit and Delete buttons on every confirmation reply (no need to re-run the command)
  • Modal pre-fills with previous values when editing
  • Cooldown messages use Discord's relative timestamp format (renders as "in 3 days", localised per user)
  • Discord invite validation: accepts discord.gg/x, https://discord.gg/x, or discord.com/invite/x, normalised to canonical form
  • Editing during cooldown preserves the original timestamp (you can't game the cooldown by bumping)
  • After cooldown expires, posting deletes the old message and posts fresh, bumping the ad to the bottom of the channel
  • Configurable embed colour via EMBED_COLOR env var
  • All ads stored in ads.json (auto-created)

Install

You need Node.js 18 or newer. Get it from nodejs.org if you don't have it.

From a release zip

  1. Download the source zip from the repo (green Code button → Download ZIP) or grab a tagged release zip.
  2. Extract it.
  3. Open a terminal in the extracted folder.
  4. cp .env.example .env and fill in TOKEN and AD_CHANNEL_ID.
  5. npm install
  6. npm run build
  7. npm start

From git

git clone https://github.com/IsoBones/Wedgetail.git
cd Wedgetail
cp .env.example .env       # then edit .env
npm install
npm run build
npm start

Dev mode (auto-reload, no separate build step)

npm install
npm run dev

On CubeCoders AMP

Using AMP's Generic Module / Node.js App Runner:

  1. Create a new instance using the Node.js App Runner template.
  2. Upload the bot files (or extract the zip into the instance's working directory).
  3. Set the start command to node dist/bot.js.
  4. In the instance's environment variables, set TOKEN and AD_CHANNEL_ID (and optionally EMBED_COLOR). You can use .env instead if you'd rather.
  5. From the AMP console, run npm install then npm run build once.
  6. Start the instance.

Configuration

Variable Required Default Description
TOKEN yes Discord bot token from the Developer Portal
AD_CHANNEL_ID yes Channel where ads are posted
EMBED_COLOR no #14B8A6 6-digit hex colour for the embed
CLIENT_ID no Reserved for future use
GUILD_ID no Reserved for future use

Bot Permissions

The bot needs the following permissions in the ad channel:

  • Send Messages
  • Embed Links
  • Read Message History
  • Use Application Commands

(No Manage Messages needed — the bot only edits and deletes its own posts.)

File Structure

wedgetail/
├── src/
│   ├── bot.ts          # Entry point, client, login, signal handling
│   ├── config.ts       # Env loading + theme
│   ├── logger.ts       # Console + file logging
│   ├── storage.ts      # ads.json persistence (in-memory cache)
│   ├── util.ts         # Invite validation + time helpers
│   ├── components.ts   # Modal, embed, and button builders
│   └── handlers.ts     # Interaction handlers + router
├── dist/               # Compiled JS (generated by `npm run build`)
├── ads.json            # User ad data (auto-generated)
├── console_output.txt  # Bot logs (auto-generated)
├── .env                # Your credentials (DON'T COMMIT)
├── .env.example
├── package.json
└── tsconfig.json

How It Works

First post: User runs /advertise → modal opens → submits → bot posts message + embed in ad channel and stores the message ID. Cooldown starts.

During cooldown: Re-running /advertise shows an ephemeral notice with the unlock time (relative timestamp) plus Edit/Delete buttons. Editing updates the same message in-place; the cooldown timer is preserved. Deleting removes the message and resets the cooldown.

After cooldown expires: Running /advertise opens the modal pre-filled with previous values. Submitting deletes the old message and posts a fresh one at the bottom of the channel. Cooldown resets.

If the ad message gets manually deleted: Bot detects the missing message on next edit/submit and posts a fresh one.

Updating

  1. Stop the bot.
  2. Pull / re-download the new version (overwrite the source files but keep your .env and ads.json).
  3. npm install (in case dependencies changed).
  4. npm run build
  5. npm start

Old ads.json records auto-migrate, so no data loss when upgrading from earlier versions.

Troubleshooting

Bot won't start: Check TOKEN and AD_CHANNEL_ID are set in .env (or in your environment). The bot exits with a clear error if either is missing.

Commands not showing in Discord: Bot needs the applications.commands scope when invited. After first run, wait a few minutes for Discord to register the global command.

Can't post ads: Verify AD_CHANNEL_ID is correct and the bot has Send Messages + Embed Links permission in that channel.

"Invalid invite" error when submitting: The invite needs to be in one of these forms: discord.gg/code, https://discord.gg/code, discord.com/invite/code. Vanity URLs and custom domains aren't supported.

Licence

GPL-3.0 — see LICENSE.

About

A node.js Discord unit advertisement bot

Resources

License

Stars

Watchers

Forks

Packages

 
 
 

Contributors