create-seedcord 0.1.2 → 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 +43 -6
- package/dist/index.mjs.map +1 -1
- package/package.json +4 -4
- package/templates/package.json.hbs +1 -0
- package/templates/prettier.config.ts.hbs +3 -0
- package/templates/tsconfig.json.hbs +1 -1
- package/templates/prettier.config.mjs.hbs +0 -3
- /package/templates/{eslint.config.mjs.hbs → eslint.config.ts.hbs} +0 -0
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
|
*/
|
|
@@ -1939,6 +1939,12 @@ let SeedcordErrorCode = /* @__PURE__ */ function(SeedcordErrorCode) {
|
|
|
1939
1939
|
SeedcordErrorCode[SeedcordErrorCode["ConfigMissingEnv"] = 1005] = "ConfigMissingEnv";
|
|
1940
1940
|
/** An environment variable is present and fails validation. */
|
|
1941
1941
|
SeedcordErrorCode[SeedcordErrorCode["ConfigInvalidEnv"] = 1006] = "ConfigInvalidEnv";
|
|
1942
|
+
/** A command usable in a guild is registered without the `Guilds` intent that caches guilds. */
|
|
1943
|
+
SeedcordErrorCode[SeedcordErrorCode["MissingGuildsIntent"] = 1007] = "MissingGuildsIntent";
|
|
1944
|
+
/** The running Node version is below the range seedcord declares in `engines`. */
|
|
1945
|
+
SeedcordErrorCode[SeedcordErrorCode["UnsupportedNodeVersion"] = 1008] = "UnsupportedNodeVersion";
|
|
1946
|
+
/** `DISCORD_BOT_TOKEN` passed its shape check and carries no readable application id. */
|
|
1947
|
+
SeedcordErrorCode[SeedcordErrorCode["ConfigTokenUnreadable"] = 1009] = "ConfigTokenUnreadable";
|
|
1942
1948
|
/** Attempted to add lifecycle tasks after startup already completed. */
|
|
1943
1949
|
SeedcordErrorCode[SeedcordErrorCode["LifecycleAddAfterCompletion"] = 1101] = "LifecycleAddAfterCompletion";
|
|
1944
1950
|
/** Attempted to add lifecycle tasks while startup is still running. */
|
|
@@ -1969,10 +1975,14 @@ let SeedcordErrorCode = /* @__PURE__ */ function(SeedcordErrorCode) {
|
|
|
1969
1975
|
SeedcordErrorCode[SeedcordErrorCode["CoreDirectoryUnreadable"] = 1207] = "CoreDirectoryUnreadable";
|
|
1970
1976
|
/** A plugin was attached under a key the framework logs on. */
|
|
1971
1977
|
SeedcordErrorCode[SeedcordErrorCode["CorePluginReservedChannel"] = 1208] = "CorePluginReservedChannel";
|
|
1972
|
-
/**
|
|
1978
|
+
/** The application id was read before startup resolved it. */
|
|
1973
1979
|
SeedcordErrorCode[SeedcordErrorCode["CoreApplicationUnavailable"] = 1209] = "CoreApplicationUnavailable";
|
|
1974
1980
|
/** A generated accessor was read before startup resolved its values. */
|
|
1975
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";
|
|
1976
1986
|
/** Interaction middleware decorated with disallowed event filters. */
|
|
1977
1987
|
SeedcordErrorCode[SeedcordErrorCode["DecoratorInteractionEventFilter"] = 1301] = "DecoratorInteractionEventFilter";
|
|
1978
1988
|
/** A command decorator attempted to re-register an existing command scope. */
|
|
@@ -2033,6 +2043,16 @@ let SeedcordErrorCode = /* @__PURE__ */ function(SeedcordErrorCode) {
|
|
|
2033
2043
|
SeedcordErrorCode[SeedcordErrorCode["EventMiddlewareNameUnavailable"] = 1613] = "EventMiddlewareNameUnavailable";
|
|
2034
2044
|
/** An autocomplete payload carried no focused option. */
|
|
2035
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";
|
|
2036
2056
|
/** A Cooldown gate was given a duration string that is not a well-formed positive duration. */
|
|
2037
2057
|
SeedcordErrorCode[SeedcordErrorCode["GateInvalidCooldownDuration"] = 1701] = "GateInvalidCooldownDuration";
|
|
2038
2058
|
/** A paginator source was given a perPage that is not a positive integer. */
|
|
@@ -2051,6 +2071,8 @@ let SeedcordErrorCode = /* @__PURE__ */ function(SeedcordErrorCode) {
|
|
|
2051
2071
|
SeedcordErrorCode[SeedcordErrorCode["PluginOptionsRejected"] = 2001] = "PluginOptionsRejected";
|
|
2052
2072
|
/** Two or more plugins threw while disposing. */
|
|
2053
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";
|
|
2054
2076
|
/** Mongoose service class is missing the `@RegisterMongooseService` decorator. */
|
|
2055
2077
|
SeedcordErrorCode[SeedcordErrorCode["PluginMongooseServiceDecoratorMissing"] = 2101] = "PluginMongooseServiceDecoratorMissing";
|
|
2056
2078
|
/** Mongoose client failed to establish a connection. */
|
|
@@ -2139,6 +2161,8 @@ let SeedcordErrorCode = /* @__PURE__ */ function(SeedcordErrorCode) {
|
|
|
2139
2161
|
SeedcordErrorCode[SeedcordErrorCode["CliTunnelUnreachable"] = 3125] = "CliTunnelUnreachable";
|
|
2140
2162
|
/** A config field is present with the wrong shape. */
|
|
2141
2163
|
SeedcordErrorCode[SeedcordErrorCode["CliConfigInvalidField"] = 3126] = "CliConfigInvalidField";
|
|
2164
|
+
/** A class carrying `@RegisterCommand` threw while codegen constructed it. */
|
|
2165
|
+
SeedcordErrorCode[SeedcordErrorCode["CliCodegenCommandConstructorThrew"] = 3127] = "CliCodegenCommandConstructorThrew";
|
|
2142
2166
|
/** A create prompt was cancelled (Ctrl-C), and nothing has been written yet. */
|
|
2143
2167
|
SeedcordErrorCode[SeedcordErrorCode["CreateCancelled"] = 3201] = "CreateCancelled";
|
|
2144
2168
|
/** A flag supplied an answer for a question the earlier answers skip. */
|
|
@@ -2180,6 +2204,9 @@ const messages = {
|
|
|
2180
2204
|
[1002]: (envKey) => `${envKey} is not a well-formed Discord webhook url.`,
|
|
2181
2205
|
[1003]: (envKey) => `The webhook behind ${envKey} does not exist on Discord.`,
|
|
2182
2206
|
[1001]: (count, failures) => `Could not resolve ${count} configured emoji${count === 1 ? "" : "s"} at startup.\n${failures}`,
|
|
2207
|
+
[1009]: () => "DISCORD_BOT_TOKEN carries no readable application id. Discord builds the first part of a bot token from that id, so a token failing here is truncated or mistyped. Copy it again from your application's Bot page.",
|
|
2208
|
+
[1007]: (commands) => `Add GatewayIntentBits.Guilds to clientOptions.intents. Without it discord.js doesn't cache any guild, so interaction.guild is null inside these commands: ${commands}.`,
|
|
2209
|
+
[1008]: (required, running) => `seedcord requires Node ${required} and this process runs ${running}. Upgrade Node before starting the bot.`,
|
|
2183
2210
|
[1101]: () => "Cannot add tasks after startup sequence has already completed.",
|
|
2184
2211
|
[1102]: () => "Cannot add tasks while startup sequence is in progress.",
|
|
2185
2212
|
[1103]: () => "Cannot remove tasks while startup sequence is in progress.",
|
|
@@ -2195,8 +2222,10 @@ const messages = {
|
|
|
2195
2222
|
[1206]: (file) => `${file} threw while importing.`,
|
|
2196
2223
|
[1207]: (dir) => `${dir} could not be read.`,
|
|
2197
2224
|
[1208]: (key) => `Plugin key "${key}" is a channel the framework logs on. Pick another key.`,
|
|
2198
|
-
[1209]: () => "The bot's application id
|
|
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.",
|
|
2199
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.`,
|
|
2200
2229
|
[1301]: () => "Interaction middleware cannot specify event filters.",
|
|
2201
2230
|
[1302]: (commandName, existingScope, requestedScope) => `Command "${commandName}" is already registered as a "${existingScope}" command and cannot be re-registered as a "${requestedScope}" command.`,
|
|
2202
2231
|
[1303]: () => "RegisterCommand(\"global\") cannot have guilds specified.",
|
|
@@ -2225,8 +2254,13 @@ const messages = {
|
|
|
2225
2254
|
[1610]: (route) => `match() has no arm for the command route ${JSON.stringify(route)}.`,
|
|
2226
2255
|
[1611]: (field) => `match() has no arm for the focused field ${JSON.stringify(field)}.`,
|
|
2227
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)}.`,
|
|
2228
2258
|
[1613]: () => `this.eventName is only available on middleware the controller constructed with a fired event name.`,
|
|
2229
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}.`,
|
|
2230
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'.`,
|
|
2231
2265
|
[1801]: (perPage) => `perPage must be a positive integer, got ${perPage}.`,
|
|
2232
2266
|
[1802]: (count) => `A control row holds at most 5 buttons, got ${count}.`,
|
|
@@ -2236,6 +2270,7 @@ const messages = {
|
|
|
2236
2270
|
[1902]: () => "Color must be within the range 0 to 16777215 (0xffffff).",
|
|
2237
2271
|
[2001]: (pluginName, reason) => `${pluginName} rejected its options, ${reason.replace(/\.$/, "")}.`,
|
|
2238
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.`,
|
|
2239
2274
|
[2101]: (className) => `Missing @RegisterMongooseService on ${className}.`,
|
|
2240
2275
|
[2102]: (databaseName) => databaseName ? `Could not connect to MongoDB (${databaseName}).` : "Could not connect to MongoDB.",
|
|
2241
2276
|
[2103]: () => "Failed to disconnect from MongoDB cleanly during shutdown.",
|
|
@@ -2269,6 +2304,7 @@ const messages = {
|
|
|
2269
2304
|
[3113]: (targetPath, reason) => `Failed to write bootstrap file at ${targetPath}: ${reason}`,
|
|
2270
2305
|
[3114]: (route, firstFile, secondFile) => `Two commands resolve to the same slash route \`${route}\`. Defined in ${firstFile} and ${secondFile}. Rename one.`,
|
|
2271
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}`,
|
|
2272
2308
|
[3116]: (kind, name, firstFile, secondFile) => `Two ${kind} context-menu commands share the name \`${name}\`. Defined in ${firstFile} and ${secondFile}. Rename one.`,
|
|
2273
2309
|
[3117]: (reason) => `Could not resolve the application from the bot token. ${reason}`,
|
|
2274
2310
|
[3118]: () => "No guilds given. Pass --guild <ids...> or --all-guilds. Global commands are never touched.",
|
|
@@ -2402,7 +2438,7 @@ function isSeedcordError(error, type, code) {
|
|
|
2402
2438
|
|
|
2403
2439
|
//#endregion
|
|
2404
2440
|
//#region src/cli/banner.ts
|
|
2405
|
-
function banner(version = "0.
|
|
2441
|
+
function banner(version = "0.2.0") {
|
|
2406
2442
|
const wordmark = `${paint.flesh.bold("seed")}${paint.rind.bold("cord")}${paint.mute(" create")}`;
|
|
2407
2443
|
if (version === void 0) return wordmark;
|
|
2408
2444
|
return `${wordmark}${paint.pith(` • v${version}`)}`;
|
|
@@ -2414,10 +2450,10 @@ const ENV_NAME = "DISCORD_BOT_TOKEN";
|
|
|
2414
2450
|
/** @internal */
|
|
2415
2451
|
function validateDiscordToken(raw) {
|
|
2416
2452
|
if (raw === null || raw === void 0) throw new SeedcordError(1005, [ENV_NAME]);
|
|
2417
|
-
if (typeof raw !== "string") throw new
|
|
2453
|
+
if (typeof raw !== "string") throw new SeedcordTypeError(1006, [ENV_NAME]);
|
|
2418
2454
|
const value = raw.trim();
|
|
2419
2455
|
if (value === "") throw new SeedcordError(1005, [ENV_NAME]);
|
|
2420
|
-
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]);
|
|
2421
2457
|
return value;
|
|
2422
2458
|
}
|
|
2423
2459
|
|
|
@@ -11058,6 +11094,7 @@ const DEV_PACKAGES = [
|
|
|
11058
11094
|
"@seedcord/eslint-config",
|
|
11059
11095
|
"@seedcord/tsconfig",
|
|
11060
11096
|
"@types/node",
|
|
11097
|
+
"jiti",
|
|
11061
11098
|
"prettier",
|
|
11062
11099
|
"seedcord",
|
|
11063
11100
|
"typescript@~6.0"
|