Errors

Whenever syntx.js detects a problem; a missing argument, a wrong type, a Discord API rejection, and so on; it throws a SyntxError instead of letting Node crash with a generic message. This page explains how to read those errors and what each code means so you can fix the problem quickly.

Reading an error

Every error appears in your console like this:

TEXT
✗ [syntx] MISSING_ARGUMENT (client.command)
  The "name" argument is required but was not provided.
  ↳ Hint: Pass a valid "name" value when calling client.command.

If the error involves a type mismatch, you also get an Expected / Received line:

TEXT
✗ [syntx] INVALID_TYPE (client.command)
  The "name" argument has the wrong type.
  Expected: string
  Received: number
  ↳ Hint: Pass a plain string for the command name.

And if the error was caused by something deeper, like a Discord API failure, you get a Caused by line pointing to the original:

TEXT
✗ [syntx] DISCORD_API_ERROR (client.ban)
  Failed to ban this member.
  ↳ Hint: This usually means missing permissions, an invalid ID, or a Discord-side error.
  ↳ Caused by: Missing Access

The parts are always in the same order: the code tells you the category of the problem; the source (in parentheses) tells you which function threw it; the message describes what happened; and the hint tells you what to check.

Error codes

MISSING_ARGUMENT

A required argument was not provided at all. This happens when you call a syntx.js function and leave out a field it needs to work.

TEXT
✗ [syntx] MISSING_ARGUMENT (client.slash)
  The "data" argument is required but was not provided.
  ↳ Hint: Pass a valid "data" value when calling client.slash.

What to do: look at the source name in the error and check the corresponding function call in your code. The message names the exact argument that is missing.


INVALID_TYPE

An argument was provided but has the wrong JavaScript type. The error always shows you what type was expected and what was actually passed.

TEXT
✗ [syntx] INVALID_TYPE (ERXClient)
  The "intents" argument has the wrong type.
  Expected: number | number[]
  Received: string
  ↳ Hint: Use the Intents helper or pass GatewayIntentBits values directly.

What to do: check the Expected line and adjust the value you are passing. A common case is passing a string where a number or array is expected, or vice versa.


INVALID_VALUE

The type is correct, but the value itself is not acceptable. This usually means the value is empty, blank, or outside the set of values that function accepts.

TEXT
✗ [syntx] INVALID_VALUE (embed.set)
  The "structureType" argument has an invalid value.
  Expected: 1 | 2
  Received: 5
  ↳ Hint: structureType must be 1 or 2.

What to do: check the Expected line for the list or range of acceptable values, and update what you are passing.


OUT_OF_RANGE

A numeric value falls outside the allowed bounds for that argument. Similar to INVALID_VALUE, but specifically for numbers with a defined minimum or maximum.

What to do: check the Expected line for the valid range and clamp or correct your value.


INVALID_USAGE

A function was called in a way that violates how it is meant to be used. This is different from passing a wrong value; it means the call itself doesn't make sense in context: calling methods in the wrong order, combining options that conflict with each other, and similar problems.

TEXT
✗ [syntx] INVALID_USAGE (client.registerSlashCommands)
  guildId is required when any registered command has scope "guild".
  ↳ Hint: Pass a guildId in the options object.

What to do: read the message carefully; it usually describes the contract that was broken. Check the relevant page in the docs for the correct call order or option combinations.


NOT_FOUND

syntx.js tried to fetch a Discord resource (a channel, a guild, a member, a role, a message) and got nothing back. This can happen because the ID is wrong, because the bot is not in that guild, or because the bot cannot see that resource.

TEXT
✗ [syntx] NOT_FOUND (channel.info)
  Channel 123456789012345678 could not be found.
  ↳ Hint: Double-check the ID and that the bot can actually see this resource.

What to do: verify that the ID is correct and that the bot is a member of the guild that contains the resource. If you are targeting a channel, also make sure the bot has the ViewChannel permission there.


MISSING_PERMISSIONS

The bot attempted an action but its role or the channel's permission overwrites prevent it. The message always names the action that was blocked.

TEXT
✗ [syntx] MISSING_PERMISSIONS (message.sendMessage)
  The bot does not have permission to send messages in this channel.
  ↳ Hint: Check the bot's role position and channel permission overwrites.

What to do: go to the Discord server settings, open the bot's role or the specific channel's permissions, and grant the permission the error names. For moderation actions like banning or timing out, the bot's role also needs to be positioned above the target member's highest role in the role hierarchy.


DISCORD_API_ERROR

The Discord API itself rejected the request. syntx.js sent a valid call, but Discord returned an error. The Caused by line shows the original API error message.

TEXT
✗ [syntx] DISCORD_API_ERROR (user.ban)
  Failed to ban this member.
  ↳ Hint: This usually means missing permissions, an invalid ID, or a Discord-side error.
  ↳ Caused by: Missing Access

What to do: read the Caused by message; it comes directly from Discord and usually points to the root cause. Common causes are permissions the bot is missing, IDs that no longer exist, or rate limits. If you are seeing Unknown Message or Unknown Channel, the resource was likely deleted between the moment your code fetched it and the moment it tried to act on it.


DATABASE_ERROR

A read or write operation through client.database failed. The Caused by line contains the original error from your database driver.

TEXT
✗ [syntx] DATABASE_ERROR (getUserSettings)
  Database operation failed while trying to fetch user settings.
  ↳ Caused by: connection refused

What to do: check the Caused by line for the underlying database error. Common causes are a database that is not running, incorrect connection credentials, or a query that targets a table or key that does not exist.


UNKNOWN

An error occurred that does not match any of the more specific codes. This is the fallback for truly unexpected failures, including unhandled promise rejections and uncaught exceptions if you have enabled global error capture.

What to do: look at the message and the stack trace in your log file for context. If the error comes from inside a discord.js event or a third-party library, the Caused by line may point to the original source.

Log file

Every error is also written to logs/syntx-errors.log in your project root. The file entries include the full stack trace, which is often more useful than the console output when debugging a problem that is hard to reproduce:

TEXT
──────────────────────────────────────────────────────────────────────
[2025-07-01T14:23:05.123Z]  SyntxError · MISSING_PERMISSIONS
Source  : user.ban
Message : The bot does not have permission to ban this member.
Hint    : Check the bot's role position and channel permission overwrites.
Caused by: Missing Access
Stack   :
    at Object.permissions (.../syntx.js/src/errors/index.js:68:11)
    at banUser (.../src/commands/ban.js:14:5)
    ...

The file rotates automatically when it reaches 5 MB; the previous file is kept as syntx-errors.log.old.