Moved all error strings to src/errors/messages and a few other things (#1695)

* Added missing error messages
As well as `Guild#setRolePosition` and `Guild#setChannelPosition`'s first arg validation
And fixed a typo in `Guild#setChannelPosition`
`roles` -> `channels`

* Reverted collection and Util constructors

* Removed leftover messages
Should have been in the second commit.

* It's a single invalid permission and removed unused flag error

* Fix INVALID_TOKEN -> TOKEN_INVALID as of #1703
This commit is contained in:
SpaceEEC
2017-07-21 02:27:19 +02:00
committed by Crawl
parent 7a27b12b2b
commit 11556c0b3b
11 changed files with 49 additions and 28 deletions

View File

@@ -13,8 +13,7 @@ const Messages = {
WS_CONNECTION_EXISTS: 'There is already an existing WebSocket connection.',
WS_NOT_OPEN: (data = 'data') => `Websocket not open to send ${data}`,
PERMISSIONS_INVALID: 'Invalid permission string or number.',
PERMISSIONS_INVALID_FLAG: 'Invalid bitfield flag string or number',
PERMISSION_INVALID: 'Invalid permission string or number.',
RATELIMIT_INVALID_METHOD: 'Unknown rate limiting method.',
@@ -26,6 +25,8 @@ const Messages = {
SHARDING_IN_PROCESS: 'Shards are still being spawned',
SHARDING_ALREADY_SPAWNED: count => `Already spawned ${count} shards`,
SHARD_MESSAGE_FAILED: 'Failed to send message to master process.',
COLOR_RANGE: 'Color must be within the range 0 - 16777215 (0xFFFFFF).',
COLOR_CONVERT: 'Unable to convert color to a number.',
@@ -39,7 +40,8 @@ const Messages = {
FILE_NOT_FOUND: file => `File could not be found: ${file}`,
USER_STATUS: 'User status must be a string',
SHARD_MESSAGE_FAILED: 'Failed to send message to master process.',
USER_NOT_CACHED: 'User is not cached. Use Client.fetchUser first.',
USER_NO_DMCHANNEL: 'No DM Channel exists!',
VOICE_INVALID_HEARTBEAT: 'Tried to set voice heartbeat but no valid interval was specified.',
VOICE_USER_MISSING: 'Couldn\'t resolve the user to create stream.',
@@ -50,6 +52,7 @@ const Messages = {
VOICE_TOKEN_ABSENT: 'Token not provided from voice server packet.',
VOICE_SESSION_ABSENT: 'Session ID not supplied.',
VOICE_INVALID_ENDPOINT: 'Invalid endpoint received.',
VOICE_NO_BROWSER: 'Voice connections are not available in browsers.',
OPUS_ENGINE_MISSING: 'Couldn\'t find an Opus engine.',
@@ -71,7 +74,7 @@ const Messages = {
SPLIT_MAX_LEN: 'Message exceeds the max length and contains no split characters.',
BAN_RESOLVE_ID: 'Couldn\'t resolve the user ID to unban.',
BAN_RESOLVE_ID: (ban = false) => `Couldn't resolve the user ID to ${ban ? 'ban' : 'unban'}.`,
PRUNE_DAYS_TYPE: 'Days must be a number',
@@ -80,8 +83,18 @@ const Messages = {
MESSAGE_SPLIT_MISSING: 'Message exceeds the max length and contains no split characters.',
GUILD_CHANNEL_RESOLVE: 'Could not resolve channel to a guild channel.',
GUILD_OWNED: 'Guild is owned by the client.',
GUILD_RESTRICTED: (state = false) => `Guild is ${state ? 'already' : 'not'} restricted.`,
GUILD_MEMBERS_TIMEOUT: 'Members didn\'t arrive in time.',
INVALID_TYPE: (name, expected, an = false) => `Supplied ${name} is not a${an ? 'n' : ''} ${expected}.`,
WEBHOOK_MESSAGE: 'The message was not sent by a webhook.',
EMOJI_TYPE: 'Emoji must be a string or Emoji/ReactionEmoji',
REACTION_RESOLVE_USER: 'Couldn\'t resolve the user ID to remove from the reaction.',
};
for (const [name, message] of Object.entries(Messages)) register(name, message);