wv3-discord.js-stock
v1.1.1
Published
Stock bot helpers and bootstrapping built on top of wv3-discord.js.
Downloads
199
Maintainers
Readme
wv3-discord.js-stock
wv3-discord.js-stock is the stock-bot convenience layer built on top of wv3-discord.js.
It keeps the original package shape:
Clientwith default command and event loadingBaseMainClientfor custom startup controlGeneralCmdsandStockCmdshelpersWebAutomationPlaywright helperslogandEventHandler
The implementation now uses wv3-discord.js for the Discord client, REST API, slash-command builders, embeds, attachments, collections, and event constants.
Changelog
See CHANGELOG.md for version history from 1.0-pre1 through the current release.
Install
This repo currently wires the package to the sibling wv3-discord.js project through a local file dependency:
npm installIf you publish the package, replace the file: dependency in package.json with a semver release of wv3-discord.js.
Requirements:
- Node.js 18+
- a Discord bot token
- a Discord application ID
- a Discord guild ID for slash command deployment
Quick Start
const { Client } = require("wv3-discord.js-stock");
const bot = new Client({
config: {
token: process.env.DISCORD_BOT_TOKEN,
clientId: process.env.DISCORD_CLIENT_ID,
guildId: process.env.DISCORD_GUILD_ID
}
});
bot.boot();By default, Client loads the package command and event folders and deploys guild commands before logging in.
Default Commands
/ping/about/status/help
Add Commands
Inline command example:
const { Client, SlashCommandBuilder } = require("wv3-discord.js-stock");
const bot = new Client({
cmds: [
{
data: new SlashCommandBuilder()
.setName("hello")
.setDescription("Say hello"),
async execute(interaction) {
await interaction.reply("Hello!");
}
}
],
config: {
token: process.env.DISCORD_BOT_TOKEN,
clientId: process.env.DISCORD_CLIENT_ID,
guildId: process.env.DISCORD_GUILD_ID
}
});
bot.boot();File-based loading example:
const { Client } = require("wv3-discord.js-stock");
const bot = new Client({
files: {
commands: ["./commands"],
events: ["./events"]
},
config: {
token: process.env.DISCORD_BOT_TOKEN,
clientId: process.env.DISCORD_CLIENT_ID,
guildId: process.env.DISCORD_GUILD_ID
}
});
bot.boot();Command modules can export either a single command object or an object with a commands array.
BaseMainClient
Use BaseMainClient when you want the same command deployment and module loading helpers without the stock defaults.
const {
BaseMainClient,
GatewayIntentBits,
SlashCommandBuilder
} = require("wv3-discord.js-stock");
const bot = new BaseMainClient({
cmds: [
{
data: new SlashCommandBuilder()
.setName("ping")
.setDescription("Ping"),
async execute(interaction) {
await interaction.reply("Pong!");
}
}
],
config: {
token: process.env.DISCORD_BOT_TOKEN,
clientId: process.env.DISCORD_CLIENT_ID,
guildId: process.env.DISCORD_GUILD_ID,
intents: [GatewayIntentBits.Guilds]
}
});
bot.start();Stock Helpers
StockCmds exports:
createStockService(options)createStockCommands(options)maskInventoryLine(line)
createStockCommands() expects:
clientensureStaff(interaction)dataDirnotifyChannelIdlog
It provides:
/stock/restock/create-order
Web Automation
WebAutomation exports:
openBrowser(options)createAutomationSession(options)runAutomation(options)runAutomationStep(page, step, index)runAutomationSteps(page, steps)runExample()
Core Re-exports
The package also re-exports the wv3-discord.js core surface, including:
WV3ClientRESTRoutesCollectionGatewayIntentBitsEventsEmbedBuilderAttachmentBuilderSlashCommandBuilder
Notes
- Guild slash commands are deployed with
Routes.applicationGuildCommands(...). - If
autoDeployCommandsis not set tofalse, commands deploy automatically. - If
autoLoginis not set tofalse, the bot logs in automatically. - If
token,clientId, orguildIdare missing, deployment is skipped with a warning.
