wv3-discord-rewrite
v1.0.5
Published
````md # WV3 Discord Utils Rewrite
Readme
# WV3 Discord Utils Rewrite
A modular CommonJS toolkit for building Electron apps, Discord bots, and Express servers with a unified WV3-style structure.
## Features
- Electron application builder
- Discord bot builder
- Express server builder
- Startup and initialization flow
- Built-in error manager
- Structured WV3 and Playwright error maps
- CommonJS-ready package layout
## Installation
```bash
npm installUsage
const WV3 = require("./index");Main Export
const WV3 = require("./index");
module.exports = {
Application: {
__init,
error,
build: {
electron,
discord,
express
}
},
Manager,
Errors
};Export Overview
Application.__init()
Runs the application startup and initialization flow.
Application.error
Shared error handler instance.
Application.build.electron
Electron application builder instance.
Application.build.discord
Discord bot builder instance.
Application.build.express
Express server builder instance.
Manager
Error manager class export.
Errors
Predefined error definitions.
Project Structure
.
├── index.js
├── builders
│ ├── ElectronBuilder.js
│ ├── DiscordBuilder.js
│ └── ExpressBuilder.js
├── managers
│ ├── ApplicationStart.js
│ ├── ApplicationEvents.js
│ └── ApplicationErrs.js
└── utils
├── ApplicationSetup.js
├── ApplicationRuntime.js
└── ApplicationErrors.jsQuick Start
Run App Initialization
const WV3 = require("./index");
WV3.Application.__init();Electron Builder
Build and control Electron windows with a chainable API.
Supported Options
- app name
- width and height
- minimum width and height
- background color
- preload file
- local HTML file
- remote URL
- theme mode
- devtools
- frameless mode
- transparent mode
Example
const WV3 = require("./index");
WV3.Application.build.electron
.setName("WV3 Desktop")
.setSize(1400, 900)
.setMinSize(1000, 700)
.setHTML("index.html")
.enableDevtools(true)
.build();Available Methods
setName(name)
setSize(width, height)
setMinSize(width, height)
setIcon(iconPath)
setPreload(preloadPath)
setHTML(htmlFile)
setURL(url)
setBackground(color)
enableDevtools(state)
setTheme(mode)
build()
getWindow()
quit()Discord Builder
Create and manage a Discord bot using discord.js with a chainable setup flow.
Supported Features
- bot token setup
- prefix configuration
- intents
- partials
- presence
- command registration
- event registration
- runtime upgrade support
- start and stop helpers
Example
const WV3 = require("./index");
const bot = WV3.Application.build.discord
.setToken("YOUR_TOKEN")
.setPrefix("!")
.addCommand("ping", async ({ message }) => {
await message.reply("pong");
})
.addEvent("ready", (client) => {
console.log(`${client.user.tag} is online`);
});
bot.start();Available Methods
setToken(token)
setPrefix(prefix)
setIntents(intents)
addIntent(intent)
setPresence(presence)
addCommand(name, run)
addEvent(eventName, run, once)
buildClient()
upgrade(newOptions)
start()
stop()
getClient()Express Builder
Create an Express server with chainable configuration and route helpers.
Supported Features
- port and host setup
- JSON middleware
- URL-encoded middleware
- static folder support
- views folder support
- view engine support
- route helpers
- render helper
- JSON response helper
- redirect helper
- not found handler
- error handler
- server upgrade and stop support
Example
const WV3 = require("./index");
WV3.Application.build.express
.setPort(3000)
.setHost("0.0.0.0")
.setViewEngine("ejs")
.get("/", (req, res) => {
res.send("WV3 Express Server Running");
})
.listen((port, host) => {
console.log(`Server running on http://${host}:${port}`);
});Available Methods
setPort(port)
setHost(host)
setViews(viewsPath)
setPublic(publicPath)
setViewEngine(viewEngine)
set(name, value)
use(middleware)
useAt(route, middleware)
get(route, handler)
post(route, handler)
put(route, handler)
patch(route, handler)
delete(route, handler)
all(route, handler)
render(route, view, data)
json(route, data)
redirect(from, to)
notFound(handler)
error(handler)
listen(callback)
upgrade(newOptions)
stop()
getApp()
getServer()Error System
WV3 includes a structured error system for internal application handling.
Included Error Groups
playwrightwv3
Example
const WV3 = require("./index");
try {
WV3.Application.error.throw("wv3", "INIT_FAILED");
} catch (err) {
console.log(err);
}Error Manager Features
- push mapped errors
- throw grouped errors
- get all stored errors
- get a specific error
- delete an error
- clear errors
- log formatted errors
Application Startup Flow
The initialization flow uses internal setup helpers for startup and runtime verification.
Startup Actions
- prompts for Playwright install
- installs Playwright
- installs Chromium
- installs WV3-related packages
- verifies browser launch
- continues initialization
Example
const WV3 = require("./index");
WV3.Application.__init();Custom Client Events
The package includes a custom event-based client with cache support.
Event Names
{
READY: "ready",
MESSAGE_CREATE: "messageCreate",
GUILD_CREATE: "guildCreate",
CHANNEL_CREATE: "channelCreate",
ERROR: "error",
DEBUG: "debug",
DISCONNECT: "disconnect"
}Best Use Cases
WV3 is useful when you want one package to help you:
- build a desktop Electron app
- run a Discord bot
- create an Express backend
- keep a shared WV3 application structure
- manage startup and error flows in one place
Example Combined Usage
const WV3 = require("./index");
// initialize
WV3.Application.__init();
// express
WV3.Application.build.express
.setPort(3000)
.get("/", (req, res) => res.send("Hello from WV3"))
.listen();
// discord
WV3.Application.build.discord
.setToken("YOUR_TOKEN")
.setPrefix("!")
.addCommand("ping", async ({ message }) => {
await message.reply("pong");
})
.start();
// electron
WV3.Application.build.electron
.setName("WV3 App")
.setHTML("index.html")
.build();Notes
- Built for CommonJS
- Builder instances are exposed directly from the main export
- Startup currently depends on install permissions and local package installation
- Intended for WV3-style application scaffolding
