create-seedcord 0.1.3 → 0.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.mjs
CHANGED
|
@@ -1922,7 +1922,7 @@ const chalk = createChalk();
|
|
|
1922
1922
|
const chalkStderr = createChalk({ level: stderrColor ? stderrColor.level : 0 });
|
|
1923
1923
|
|
|
1924
1924
|
//#endregion
|
|
1925
|
-
//#region ../../packages/errors/dist/SeedcordError-
|
|
1925
|
+
//#region ../../packages/errors/dist/SeedcordError-DnV6q4mB.mjs
|
|
1926
1926
|
/**
|
|
1927
1927
|
* All Seedcord error codes.
|
|
1928
1928
|
*/
|
|
@@ -1979,6 +1979,10 @@ let SeedcordErrorCode = /* @__PURE__ */ function(SeedcordErrorCode) {
|
|
|
1979
1979
|
SeedcordErrorCode[SeedcordErrorCode["CoreApplicationUnavailable"] = 1209] = "CoreApplicationUnavailable";
|
|
1980
1980
|
/** A generated accessor was read before startup resolved its values. */
|
|
1981
1981
|
SeedcordErrorCode[SeedcordErrorCode["CoreAccessorUnresolved"] = 1210] = "CoreAccessorUnresolved";
|
|
1982
|
+
/** A startup or shutdown task was added to a core built by `createSeedcord`. */
|
|
1983
|
+
SeedcordErrorCode[SeedcordErrorCode["CoreLifecycleUnavailable"] = 1211] = "CoreLifecycleUnavailable";
|
|
1984
|
+
/** `emit` was called on the bus. It reaches listeners and skips every subscriber. */
|
|
1985
|
+
SeedcordErrorCode[SeedcordErrorCode["CoreBusEmitUnavailable"] = 1212] = "CoreBusEmitUnavailable";
|
|
1982
1986
|
/** Interaction middleware decorated with disallowed event filters. */
|
|
1983
1987
|
SeedcordErrorCode[SeedcordErrorCode["DecoratorInteractionEventFilter"] = 1301] = "DecoratorInteractionEventFilter";
|
|
1984
1988
|
/** A command decorator attempted to re-register an existing command scope. */
|
|
@@ -2039,6 +2043,16 @@ let SeedcordErrorCode = /* @__PURE__ */ function(SeedcordErrorCode) {
|
|
|
2039
2043
|
SeedcordErrorCode[SeedcordErrorCode["EventMiddlewareNameUnavailable"] = 1613] = "EventMiddlewareNameUnavailable";
|
|
2040
2044
|
/** An autocomplete payload carried no focused option. */
|
|
2041
2045
|
SeedcordErrorCode[SeedcordErrorCode["AutocompleteNoFocusedOption"] = 1614] = "AutocompleteNoFocusedOption";
|
|
2046
|
+
/** A context menu handler's match() has no arm for the command name that fired. */
|
|
2047
|
+
SeedcordErrorCode[SeedcordErrorCode["ContextMenuMatchArmMissing"] = 1615] = "ContextMenuMatchArmMissing";
|
|
2048
|
+
/** No field in the submitted modal carries the requested custom id. */
|
|
2049
|
+
SeedcordErrorCode[SeedcordErrorCode["ModalFieldNotFound"] = 1616] = "ModalFieldNotFound";
|
|
2050
|
+
/** A modal field getter was called on a field of another kind. */
|
|
2051
|
+
SeedcordErrorCode[SeedcordErrorCode["ModalFieldWrongKind"] = 1617] = "ModalFieldWrongKind";
|
|
2052
|
+
/** Nothing was picked in a modal field read as required. */
|
|
2053
|
+
SeedcordErrorCode[SeedcordErrorCode["ModalFieldEmpty"] = 1618] = "ModalFieldEmpty";
|
|
2054
|
+
/** A channel select field picked a channel outside the types getSelectedChannels() allows. */
|
|
2055
|
+
SeedcordErrorCode[SeedcordErrorCode["ModalFieldChannelType"] = 1619] = "ModalFieldChannelType";
|
|
2042
2056
|
/** A Cooldown gate was given a duration string that is not a well-formed positive duration. */
|
|
2043
2057
|
SeedcordErrorCode[SeedcordErrorCode["GateInvalidCooldownDuration"] = 1701] = "GateInvalidCooldownDuration";
|
|
2044
2058
|
/** A paginator source was given a perPage that is not a positive integer. */
|
|
@@ -2057,6 +2071,8 @@ let SeedcordErrorCode = /* @__PURE__ */ function(SeedcordErrorCode) {
|
|
|
2057
2071
|
SeedcordErrorCode[SeedcordErrorCode["PluginOptionsRejected"] = 2001] = "PluginOptionsRejected";
|
|
2058
2072
|
/** Two or more plugins threw while disposing. */
|
|
2059
2073
|
SeedcordErrorCode[SeedcordErrorCode["PluginDisposeFailures"] = 2002] = "PluginDisposeFailures";
|
|
2074
|
+
/** A plugin declared a lifecycle timeout that is not a positive, finite number of milliseconds. */
|
|
2075
|
+
SeedcordErrorCode[SeedcordErrorCode["PluginInvalidLifecycleTimeout"] = 2003] = "PluginInvalidLifecycleTimeout";
|
|
2060
2076
|
/** Mongoose service class is missing the `@RegisterMongooseService` decorator. */
|
|
2061
2077
|
SeedcordErrorCode[SeedcordErrorCode["PluginMongooseServiceDecoratorMissing"] = 2101] = "PluginMongooseServiceDecoratorMissing";
|
|
2062
2078
|
/** Mongoose client failed to establish a connection. */
|
|
@@ -2145,6 +2161,8 @@ let SeedcordErrorCode = /* @__PURE__ */ function(SeedcordErrorCode) {
|
|
|
2145
2161
|
SeedcordErrorCode[SeedcordErrorCode["CliTunnelUnreachable"] = 3125] = "CliTunnelUnreachable";
|
|
2146
2162
|
/** A config field is present with the wrong shape. */
|
|
2147
2163
|
SeedcordErrorCode[SeedcordErrorCode["CliConfigInvalidField"] = 3126] = "CliConfigInvalidField";
|
|
2164
|
+
/** A class carrying `@RegisterCommand` threw while codegen constructed it. */
|
|
2165
|
+
SeedcordErrorCode[SeedcordErrorCode["CliCodegenCommandConstructorThrew"] = 3127] = "CliCodegenCommandConstructorThrew";
|
|
2148
2166
|
/** A create prompt was cancelled (Ctrl-C), and nothing has been written yet. */
|
|
2149
2167
|
SeedcordErrorCode[SeedcordErrorCode["CreateCancelled"] = 3201] = "CreateCancelled";
|
|
2150
2168
|
/** A flag supplied an answer for a question the earlier answers skip. */
|
|
@@ -2206,6 +2224,8 @@ const messages = {
|
|
|
2206
2224
|
[1208]: (key) => `Plugin key "${key}" is a channel the framework logs on. Pick another key.`,
|
|
2207
2225
|
[1209]: () => "The bot's application id resolves during startup. You read it before that. Read it inside a handler, inside a plugin's ready(), or after start() resolves.",
|
|
2208
2226
|
[1210]: (accessor, key) => `${accessor}.${key} has no value yet. ${accessor} fills during startup, and a read at the top of a file runs before that.`,
|
|
2227
|
+
[1211]: (accessor) => `core.${accessor}.addTask() does not work here. This bot was built with createSeedcord() whose build never runs startup or shutdown. Your task would never run. Do the work inside your handler instead. To use startup and shutdown, run the bot on node with new Seedcord(config).start().`,
|
|
2228
|
+
[1212]: (event) => `core.bus.emit('${event}') would reach your on() listeners and skip every Subscriber class. Call core.bus.publish('${event}', data) to run both.`,
|
|
2209
2229
|
[1301]: () => "Interaction middleware cannot specify event filters.",
|
|
2210
2230
|
[1302]: (commandName, existingScope, requestedScope) => `Command "${commandName}" is already registered as a "${existingScope}" command and cannot be re-registered as a "${requestedScope}" command.`,
|
|
2211
2231
|
[1303]: () => "RegisterCommand(\"global\") cannot have guilds specified.",
|
|
@@ -2234,8 +2254,13 @@ const messages = {
|
|
|
2234
2254
|
[1610]: (route) => `match() has no arm for the command route ${JSON.stringify(route)}.`,
|
|
2235
2255
|
[1611]: (field) => `match() has no arm for the focused field ${JSON.stringify(field)}.`,
|
|
2236
2256
|
[1612]: (event) => `match() has no arm for the event ${JSON.stringify(event)}.`,
|
|
2257
|
+
[1615]: (name) => `match() has no arm for the context menu command ${JSON.stringify(name)}.`,
|
|
2237
2258
|
[1613]: () => `this.eventName is only available on middleware the controller constructed with a fired event name.`,
|
|
2238
2259
|
[1614]: () => `Autocomplete payload has no focused option.`,
|
|
2260
|
+
[1616]: (customId) => `The submitted modal carries no field with the custom id ${JSON.stringify(customId)}. Check it against the id you gave the component when you built the modal.`,
|
|
2261
|
+
[1617]: (customId, kind, getter) => getter ? `Modal field ${JSON.stringify(customId)} holds ${kind}. Read it with ${getter}().` : `Modal field ${JSON.stringify(customId)} holds ${kind}. No getter reads that kind.`,
|
|
2262
|
+
[1618]: (customId) => `Modal field ${JSON.stringify(customId)} carries no selection. Build the component as required, or read it without the required argument.`,
|
|
2263
|
+
[1619]: (customId, picked, allowed) => `Modal field ${JSON.stringify(customId)} picked a ${picked} channel. This read allows ${allowed}.`,
|
|
2239
2264
|
[1701]: (input) => `Cooldown duration ${JSON.stringify(input)} is not valid. Pass a number of seconds or a duration string like '30m', '24h', or '500ms'.`,
|
|
2240
2265
|
[1801]: (perPage) => `perPage must be a positive integer, got ${perPage}.`,
|
|
2241
2266
|
[1802]: (count) => `A control row holds at most 5 buttons, got ${count}.`,
|
|
@@ -2245,6 +2270,7 @@ const messages = {
|
|
|
2245
2270
|
[1902]: () => "Color must be within the range 0 to 16777215 (0xffffff).",
|
|
2246
2271
|
[2001]: (pluginName, reason) => `${pluginName} rejected its options, ${reason.replace(/\.$/, "")}.`,
|
|
2247
2272
|
[2002]: (count) => `${count} plugins failed to dispose.`,
|
|
2273
|
+
[2003]: (pluginName, field, declared) => `${pluginName} declared lifecycle ${field}.timeout as ${declared}. Pass a positive number of milliseconds, or omit it for the default.`,
|
|
2248
2274
|
[2101]: (className) => `Missing @RegisterMongooseService on ${className}.`,
|
|
2249
2275
|
[2102]: (databaseName) => databaseName ? `Could not connect to MongoDB (${databaseName}).` : "Could not connect to MongoDB.",
|
|
2250
2276
|
[2103]: () => "Failed to disconnect from MongoDB cleanly during shutdown.",
|
|
@@ -2278,6 +2304,7 @@ const messages = {
|
|
|
2278
2304
|
[3113]: (targetPath, reason) => `Failed to write bootstrap file at ${targetPath}: ${reason}`,
|
|
2279
2305
|
[3114]: (route, firstFile, secondFile) => `Two commands resolve to the same slash route \`${route}\`. Defined in ${firstFile} and ${secondFile}. Rename one.`,
|
|
2280
2306
|
[3115]: (dir, reason) => `Could not read the commands directory ${dir} during codegen. ${reason}`,
|
|
2307
|
+
[3127]: (name, file, reason) => `${name} threw while codegen constructed it. Fix its constructor in ${file}. ${reason}`,
|
|
2281
2308
|
[3116]: (kind, name, firstFile, secondFile) => `Two ${kind} context-menu commands share the name \`${name}\`. Defined in ${firstFile} and ${secondFile}. Rename one.`,
|
|
2282
2309
|
[3117]: (reason) => `Could not resolve the application from the bot token. ${reason}`,
|
|
2283
2310
|
[3118]: () => "No guilds given. Pass --guild <ids...> or --all-guilds. Global commands are never touched.",
|
|
@@ -2411,7 +2438,7 @@ function isSeedcordError(error, type, code) {
|
|
|
2411
2438
|
|
|
2412
2439
|
//#endregion
|
|
2413
2440
|
//#region src/cli/banner.ts
|
|
2414
|
-
function banner(version = "0.
|
|
2441
|
+
function banner(version = "0.2.0") {
|
|
2415
2442
|
const wordmark = `${paint.flesh.bold("seed")}${paint.rind.bold("cord")}${paint.mute(" create")}`;
|
|
2416
2443
|
if (version === void 0) return wordmark;
|
|
2417
2444
|
return `${wordmark}${paint.pith(` • v${version}`)}`;
|
|
@@ -2423,10 +2450,10 @@ const ENV_NAME = "DISCORD_BOT_TOKEN";
|
|
|
2423
2450
|
/** @internal */
|
|
2424
2451
|
function validateDiscordToken(raw) {
|
|
2425
2452
|
if (raw === null || raw === void 0) throw new SeedcordError(1005, [ENV_NAME]);
|
|
2426
|
-
if (typeof raw !== "string") throw new
|
|
2453
|
+
if (typeof raw !== "string") throw new SeedcordTypeError(1006, [ENV_NAME]);
|
|
2427
2454
|
const value = raw.trim();
|
|
2428
2455
|
if (value === "") throw new SeedcordError(1005, [ENV_NAME]);
|
|
2429
|
-
if (!/^[A-Za-z\d_-]{24,}\.[A-Za-z\d_-]{6,}\.[A-Za-z\d_-]{27,}$/.test(value)) throw new
|
|
2456
|
+
if (!/^[A-Za-z\d_-]{24,}\.[A-Za-z\d_-]{6,}\.[A-Za-z\d_-]{27,}$/.test(value)) throw new SeedcordTypeError(1006, [ENV_NAME]);
|
|
2430
2457
|
return value;
|
|
2431
2458
|
}
|
|
2432
2459
|
|
|
@@ -11067,6 +11094,7 @@ const DEV_PACKAGES = [
|
|
|
11067
11094
|
"@seedcord/eslint-config",
|
|
11068
11095
|
"@seedcord/tsconfig",
|
|
11069
11096
|
"@types/node",
|
|
11097
|
+
"jiti",
|
|
11070
11098
|
"prettier",
|
|
11071
11099
|
"seedcord",
|
|
11072
11100
|
"typescript@~6.0"
|