From ba7ae876ed3517c1877427b904859c57db91acee Mon Sep 17 00:00:00 2001 From: marzavec Date: Mon, 8 Jan 2024 11:09:59 -0800 Subject: [PATCH] added missing warning id props --- commands/admin/addmod.js | 6 +- commands/admin/listusers.js | 2 +- commands/admin/reload.js | 2 +- commands/admin/removemod.js | 6 +- commands/admin/saveconfig.js | 8 ++- commands/admin/shout.js | 2 +- commands/channels/claimchannel.js | 23 ++++--- commands/channels/makeprivate.js | 15 ++--- commands/channels/makepublic.js | 21 ++++--- commands/channels/renewclaim.js | 27 ++++++--- commands/channels/setlevel.js | 23 ++++--- commands/channels/setmotd.js | 12 ++-- commands/channels/unclaimchannel.js | 15 +++-- commands/core/changecolor.js | 10 ++- commands/core/changenick.js | 24 +++++--- commands/core/chat.js | 11 +++- commands/core/emote.js | 10 ++- commands/core/help.js | 6 +- commands/core/join.js | 8 +-- commands/core/morestats.js | 2 +- commands/core/stats.js | 2 +- commands/core/whisper.js | 9 ++- commands/internal/socketreply.js | 6 ++ commands/mod/ban.js | 4 +- commands/mod/disablecaptcha.js | 4 +- commands/mod/dumb.js | 5 +- commands/mod/enablecaptcha.js | 7 ++- commands/mod/forcecolor.js | 5 +- commands/mod/kick.js | 4 +- commands/mod/lockroom.js | 10 +-- commands/mod/speak.js | 12 ++-- commands/mod/unban.js | 10 ++- commands/mod/unbanall.js | 4 +- commands/mod/unlockroom.js | 4 +- commands/utility/_Constants.js | 94 +++++++++++++++++++++++++++-- scripts/config.js | 4 +- 36 files changed, 296 insertions(+), 121 deletions(-) diff --git a/commands/admin/addmod.js b/commands/admin/addmod.js index 547f994..dfee669 100644 --- a/commands/admin/addmod.js +++ b/commands/admin/addmod.js @@ -50,7 +50,7 @@ export async function run({ // inform new mod server.send({ - cmd: 'info', + cmd: 'info', // @todo Add numeric info code as `id` text: 'You are now a mod.', channel: newMod[i].channel, // @todo Multichannel }, newMod[i]); @@ -67,14 +67,14 @@ export async function run({ // return success message server.reply({ - cmd: 'info', + cmd: 'info', // @todo Add numeric info code as `id` text: `Added mod trip: ${payload.trip}, remember to run 'saveconfig' to make it permanent`, channel: socket.channel, // @todo Multichannel }, socket); // notify all mods server.broadcast({ - cmd: 'info', + cmd: 'info', // @todo Add numeric info code as `id` text: `Added mod: ${payload.trip}`, channel: false, // @todo Multichannel, false for global info }, { level: isModerator }); diff --git a/commands/admin/listusers.js b/commands/admin/listusers.js index 9a5ad73..759733b 100644 --- a/commands/admin/listusers.js +++ b/commands/admin/listusers.js @@ -51,7 +51,7 @@ export async function run({ server, socket }) { // send reply server.reply({ - cmd: 'info', + cmd: 'info', // @todo Add numeric info code as `id` text: lines.join('\n'), channel: socket.channel, // @todo Multichannel }, socket); diff --git a/commands/admin/reload.js b/commands/admin/reload.js index a5f3aa7..fc535a8 100644 --- a/commands/admin/reload.js +++ b/commands/admin/reload.js @@ -45,7 +45,7 @@ export async function run({ // send results to moderators (which the user using this command is higher than) server.broadcast({ - cmd: 'info', + cmd: 'info', // @todo Add numeric info code as `id` text: loadResult, channel: false, // @todo Multichannel, false for global }, { level: isModerator }); diff --git a/commands/admin/removemod.js b/commands/admin/removemod.js index b2e820c..85b876a 100644 --- a/commands/admin/removemod.js +++ b/commands/admin/removemod.js @@ -53,7 +53,7 @@ export async function run({ // inform ex-mod server.send({ - cmd: 'info', + cmd: 'info', // @todo Add numeric info code as `id` text: 'You are now a user.', channel: targetMod[i].channel, // @todo Multichannel }, targetMod[i]); @@ -70,7 +70,7 @@ export async function run({ // return success message server.reply({ - cmd: 'info', + cmd: 'info', // @todo Add numeric info code as `id` text: `Removed mod trip: ${ payload.trip }, remember to run 'saveconfig' to make it permanent`, @@ -79,7 +79,7 @@ export async function run({ // notify all mods server.broadcast({ - cmd: 'info', + cmd: 'info', // @todo Add numeric info code as `id` text: `Removed mod: ${payload.trip}`, channel: false, // @todo Multichannel, false for global }, { level: isModerator }); diff --git a/commands/admin/saveconfig.js b/commands/admin/saveconfig.js index 9c8ea3b..b7e3df5 100644 --- a/commands/admin/saveconfig.js +++ b/commands/admin/saveconfig.js @@ -10,6 +10,9 @@ import { isAdmin, isModerator, } from '../utility/_UAC.js'; +import { + Errors, +} from '../utility/_Constants.js'; /** * Executes when invoked by a remote client @@ -28,15 +31,16 @@ export async function run({ core, server, socket }) { await core.appConfig.write(); } catch (err) { return server.reply({ - cmd: 'warn', // @todo Add numeric error code as `id` + cmd: 'warn', text: 'Failed to save config, check logs.', + id: Errors.SaveConfig.GENERAL_FAILURE, channel: socket.channel, // @todo Multichannel }, socket); } // return success message to moderators and admins server.broadcast({ - cmd: 'info', + cmd: 'info', // @todo Add numeric info code as `id` text: 'Config saved!', channel: false, // @todo Multichannel }, { level: isModerator }); diff --git a/commands/admin/shout.js b/commands/admin/shout.js index 0c958fd..6c6dbf3 100644 --- a/commands/admin/shout.js +++ b/commands/admin/shout.js @@ -24,7 +24,7 @@ export async function run({ server, socket, payload }) { // send text to all channels server.broadcast({ - cmd: 'info', + cmd: 'info', // @todo Add numeric info code as `id` text: `Server Notice: ${payload.text}`, channel: false, // @todo Multichannel, false for global }, {}); diff --git a/commands/channels/claimchannel.js b/commands/channels/claimchannel.js index 6dc2454..c2d74a5 100644 --- a/commands/channels/claimchannel.js +++ b/commands/channels/claimchannel.js @@ -13,7 +13,7 @@ import { levels, } from '../utility/_UAC.js'; import { - // Errors, + Errors, ClaimExpirationDays, } from '../utility/_Constants.js'; import { @@ -37,16 +37,18 @@ export async function run({ if (!socket.trip) { return server.reply({ - cmd: 'warn', // @todo Add numeric error code as `id` - text: 'Failed to take ownership: Missing trip code.', + cmd: 'warn', + text: 'Failed to run command: Missing trip code.', + id: Errors.Global.MISSING_TRIPCODE, channel: socket.channel, // @todo Multichannel }, socket); } if (isModerator(socket.level)) { return server.reply({ - cmd: 'info', // @todo Add numeric error code as `id` + cmd: 'warn', text: "Failed to take ownership: You're already a global moderator; it's free real estate. . .", + id: Errors.ClaimChannel.MODS_CANT, channel: socket.channel, // @todo Multichannel }, socket); } @@ -55,8 +57,11 @@ export async function run({ if (channelSettings.owned) { return server.reply({ - cmd: 'warn', // @todo Add numeric error code as `id` + cmd: 'warn', text: `Failed to take ownership: This channel is already owned by the trip "${channelSettings.ownerTrip}", until ${channelSettings.claimExpires}`, + ownerTrip: channelSettings.ownerTrip, + claimExpires: channelSettings.claimExpires, + id: Errors.ClaimChannel.ALREADY_OWNED, channel: socket.channel, // @todo Multichannel }, socket); } @@ -68,6 +73,7 @@ export async function run({ server.reply({ cmd: 'warn', text: 'Enter the following to take ownership (case-sensitive):', + id: Errors.Captcha.MUST_SOLVE, channel: socket.channel, // @todo Multichannel }, socket); @@ -111,8 +117,11 @@ export function chatHook({ if (channelSettings.owned) { return server.reply({ - cmd: 'warn', // @todo Add numeric error code as `id` + cmd: 'warn', text: `Failed to take ownership: This channel is already owned by the trip "${channelSettings.ownerTrip}", until ${channelSettings.claimExpires}`, + ownerTrip: channelSettings.ownerTrip, + claimExpires: channelSettings.claimExpires, + id: Errors.ClaimChannel.ALREADY_OWNED, channel: socket.channel, // @todo Multichannel }, socket); } @@ -126,7 +135,7 @@ export function chatHook({ updateChannelSettings(core.appConfig.data, socket.channel, channelSettings); server.broadcast({ - cmd: 'info', + cmd: 'info', // @todo Add numeric info code as `id` text: `Channel now owned by "${socket.trip}", until ${channelSettings.claimExpires}`, channel: socket.channel, }, { channel: socket.channel }); diff --git a/commands/channels/makeprivate.js b/commands/channels/makeprivate.js index fe5df0d..e366d11 100644 --- a/commands/channels/makeprivate.js +++ b/commands/channels/makeprivate.js @@ -9,11 +9,9 @@ import { isChannelOwner, } from '../utility/_UAC.js'; -/* import { Errors, } from '../utility/_Constants.js'; -*/ /** * Executes when invoked by a remote client @@ -31,16 +29,18 @@ export async function run({ if (!socket.trip) { return server.reply({ - cmd: 'warn', // @todo Add numeric error code as `id` - text: 'Failed to make channel private: Missing trip code.', + cmd: 'warn', + text: 'Failed to run command: Missing trip code.', + id: Errors.Global.MISSING_TRIPCODE, channel: socket.channel, // @todo Multichannel }, socket); } if (!isChannelOwner(socket.level)) { return server.reply({ - cmd: 'info', // @todo Add numeric error code as `id` + cmd: 'warn', text: 'Failed to make channel private: You may not do that', + id: Errors.MakePrivate.MISSING_PERMS, channel: socket.channel, // @todo Multichannel }, socket); } @@ -49,8 +49,9 @@ export async function run({ if (listingIndex === -1) { return server.reply({ - cmd: 'warn', // @todo Add numeric error code as `id` + cmd: 'warn', text: 'Failed to make channel private: This channel is already private', + id: Errors.MakePrivate.ALREADY_PRIVATE, channel: socket.channel, // @todo Multichannel }, socket); } @@ -58,7 +59,7 @@ export async function run({ core.appConfig.data.publicChannels.splice(listingIndex, 1); server.reply({ - cmd: 'info', // @todo Add numeric error code as `id` + cmd: 'info', // @todo Add numeric info code as `id` text: 'This channel has been removed from the list of public channels', channel: socket.channel, // @todo Multichannel }, socket); diff --git a/commands/channels/makepublic.js b/commands/channels/makepublic.js index ec3e639..02bafd4 100644 --- a/commands/channels/makepublic.js +++ b/commands/channels/makepublic.js @@ -11,11 +11,9 @@ import { isChannelOwner, isModerator, } from '../utility/_UAC.js'; -/* import { Errors, } from '../utility/_Constants.js'; -*/ import { getChannelSettings, } from '../utility/_Channels.js'; @@ -36,16 +34,18 @@ export async function run({ if (!socket.trip) { return server.reply({ - cmd: 'warn', // @todo Add numeric error code as `id` - text: 'Failed to make channel public: Missing trip code.', + cmd: 'warn', + text: 'Failed to run command: Missing trip code.', + id: Errors.Global.MISSING_TRIPCODE, channel: socket.channel, // @todo Multichannel }, socket); } if (isModerator(socket.level) || !isChannelOwner(socket.level)) { return server.reply({ - cmd: 'info', // @todo Add numeric error code as `id` + cmd: 'warn', text: 'Failed to make channel public: You may not do that', + id: Errors.MakePublic.MISSING_PERMS, channel: socket.channel, // @todo Multichannel }, socket); } @@ -57,6 +57,7 @@ export async function run({ server.reply({ cmd: 'warn', text: 'Enter the following to make channel public (case-sensitive):', + id: Errors.Captcha.MUST_SOLVE, channel: socket.channel, // @todo Multichannel }, socket); @@ -100,16 +101,18 @@ export function chatHook({ if (channelSettings.owned === false || socket.trip !== channelSettings.ownerTrip) { return server.reply({ - cmd: 'warn', // @todo Add numeric error code as `id` + cmd: 'warn', text: 'Failed to make channel public: You may not do that', + id: Errors.MakePublic.MISSING_PERMS, channel: socket.channel, // @todo Multichannel }, socket); } if (core.appConfig.data.publicChannels.indexOf(socket.channel) !== -1) { return server.reply({ - cmd: 'warn', // @todo Add numeric error code as `id` + cmd: 'warn', text: 'Failed to make channel public: This channel is already public', + id: Errors.MakePublic.ALREADY_PUBLIC, channel: socket.channel, // @todo Multichannel }, socket); } @@ -117,13 +120,13 @@ export function chatHook({ core.appConfig.data.publicChannels.push(socket.channel); server.broadcast({ - cmd: 'info', + cmd: 'info', // @todo Add numeric info code as `id` text: `A new channel has been made public: ?${socket.channel}`, channel: socket.channel, // @todo Multichannel }, { level: (level) => isModerator(level) }); server.reply({ - cmd: 'info', // @todo Add numeric error code as `id` + cmd: 'info', // @todo Add numeric info code as `id` text: 'This channel has been added to the list of public channels', channel: socket.channel, // @todo Multichannel }, socket); diff --git a/commands/channels/renewclaim.js b/commands/channels/renewclaim.js index 88ca671..f6a0747 100644 --- a/commands/channels/renewclaim.js +++ b/commands/channels/renewclaim.js @@ -11,7 +11,7 @@ import { isModerator, } from '../utility/_UAC.js'; import { - // Errors, + Errors, ClaimExpirationDays, } from '../utility/_Constants.js'; import { @@ -35,16 +35,18 @@ export async function run({ if (!socket.trip) { return server.reply({ - cmd: 'warn', // @todo Add numeric error code as `id` - text: 'Failed to renew ownership: Missing trip code.', + cmd: 'warn', + text: 'Failed to run command: Missing trip code.', + id: Errors.Global.MISSING_TRIPCODE, channel: socket.channel, // @todo Multichannel }, socket); } if (isModerator(socket.level)) { return server.reply({ - cmd: 'info', // @todo Add numeric error code as `id` + cmd: 'warn', text: "Failed to renew ownership: You're already a global moderator; it's free real estate. . .", + id: Errors.RenewClaim.MODS_CANT, channel: socket.channel, // @todo Multichannel }, socket); } @@ -53,8 +55,9 @@ export async function run({ if (channelSettings.owned === false || socket.trip !== channelSettings.ownerTrip) { return server.reply({ - cmd: 'warn', // @todo Add numeric error code as `id` + cmd: 'warn', text: 'Failed to renew ownership: You may not do that', + id: Errors.RenewClaim.NOT_OWNER, channel: socket.channel, // @todo Multichannel }, socket); } @@ -62,9 +65,13 @@ export async function run({ const hoursLeft = Math.abs(channelSettings.claimExpires - new Date()) / (60 * 60 * 1000); if (hoursLeft > 24) { + const timeLeft = hoursLeft - 24; + return server.reply({ - cmd: 'warn', // @todo Add numeric error code as `id` - text: `Failed to renew ownership: You must wait. Hours until renewable: ${hoursLeft - 24}`, + cmd: 'warn', + text: `Failed to renew ownership: You must wait. Hours until renewable: ${timeLeft}`, + timeLeft, + id: Errors.RenewClaim.TOO_SOON, channel: socket.channel, // @todo Multichannel }, socket); } @@ -76,6 +83,7 @@ export async function run({ server.reply({ cmd: 'warn', text: 'Enter the following to renew ownership (case-sensitive):', + id: Errors.Captcha.MUST_SOLVE, channel: socket.channel, // @todo Multichannel }, socket); @@ -119,8 +127,9 @@ export function chatHook({ if (channelSettings.owned === false || socket.trip !== channelSettings.ownerTrip) { return server.reply({ - cmd: 'warn', // @todo Add numeric error code as `id` + cmd: 'warn', text: 'Failed to renew ownership: You may not do that', + id: Errors.RenewClaim.NOT_OWNER, channel: socket.channel, // @todo Multichannel }, socket); } @@ -132,7 +141,7 @@ export function chatHook({ updateChannelSettings(core.appConfig.data, socket.channel, channelSettings); server.reply({ - cmd: 'info', // @todo Add numeric error code as `id` + cmd: 'info', // @todo Add numeric info code as `id` text: `Your claim has been renewed until ${expirationDate}`, channel: socket.channel, // @todo Multichannel }, socket); diff --git a/commands/channels/setlevel.js b/commands/channels/setlevel.js index 999249c..44a7381 100644 --- a/commands/channels/setlevel.js +++ b/commands/channels/setlevel.js @@ -14,6 +14,9 @@ import { import { setChannelTripLevel, } from '../utility/_Channels.js'; +import { + Errors, +} from '../utility/_Constants.js'; /** * Automatically executes once after server is ready @@ -41,16 +44,18 @@ export async function run({ if (typeof payload.trip !== 'string' || payload.trip.length !== 6) { return server.reply({ - cmd: 'warn', // @todo Add numeric error code as `id` + cmd: 'warn', text: 'Failed to set level: Invalid trip. Refer to `/help setlevel` for instructions on how to use this command.', + id: Errors.SetLevel.BAD_TRIP, channel: socket.channel, // @todo Multichannel }, socket); } if (typeof payload.level !== 'string' || core.levelLabels.indexOf(payload.level) === -1) { return server.reply({ - cmd: 'warn', // @todo Add numeric error code as `id` + cmd: 'warn', text: `Failed to set level: Invalid level label; choices are case sensitive: ${core.levelLabels.join(', ')}`, + id: Errors.SetLevel.BAD_LABEL, channel: socket.channel, // @todo Multichannel }, socket); } @@ -59,8 +64,9 @@ export async function run({ if (newLevel >= socket.level) { return server.reply({ - cmd: 'warn', // @todo Add numeric error code as `id` + cmd: 'warn', text: 'Failed to set level: New level may not be the same or greater than your own.', + id: Errors.SetLevel.BAD_LEVEL, channel: socket.channel, // @todo Multichannel }, socket); } @@ -69,8 +75,9 @@ export async function run({ if (setError !== '') { return server.reply({ - cmd: 'warn', // @todo Add numeric error code as `id` + cmd: 'warn', text: `Failed to set level: ${setError}`, + id: Errors.SetLevel.APPLY_ERROR, channel: socket.channel, // @todo Multichannel }, socket); } @@ -93,7 +100,7 @@ export async function run({ } server.broadcast({ - cmd: 'info', // @todo Add numeric error code as `id` + cmd: 'info', // @todo Add numeric info code as `id` text: `Changed permission level of "${payload.trip}" to "${payload.level}"`, channel: socket.channel, // @todo Multichannel }, { channel: socket.channel }); @@ -132,8 +139,9 @@ export function setlevelCheck({ // If there is no trip parameter if (!input[1]) { server.reply({ - cmd: 'warn', // @todo Add numeric error code as `id` + cmd: 'warn', text: 'Failed to set level: Missing trip. Refer to `/help setlevel` for instructions on how to use this command.', + id: Errors.SetLevel.BAD_TRIP, channel: socket.channel, // @todo Multichannel }, socket); @@ -143,8 +151,9 @@ export function setlevelCheck({ // If there is no level parameter if (!input[2]) { server.reply({ - cmd: 'warn', // @todo Add numeric error code as `id` + cmd: 'warn', text: 'Failed to set level: Missing level label. Refer to `/help setlevel` for instructions on how to use this command.', + id: Errors.SetLevel.BAD_LABEL, channel: socket.channel, // @todo Multichannel }, socket); diff --git a/commands/channels/setmotd.js b/commands/channels/setmotd.js index 606ec52..e70912f 100644 --- a/commands/channels/setmotd.js +++ b/commands/channels/setmotd.js @@ -14,6 +14,7 @@ import { updateChannelSettings, } from '../utility/_Channels.js'; import { + Errors, MaxMOTDLength, } from '../utility/_Constants.js'; @@ -28,8 +29,9 @@ export async function run({ }) { if (server.police.frisk(socket, 6)) { return server.reply({ - cmd: 'warn', // @todo Add numeric error code as `id` + cmd: 'warn', text: 'Issuing commands too quickly. Wait a moment before trying again.', + id: Errors.Global.RATELIMIT, channel: socket.channel, // @todo Multichannel }, socket); } @@ -41,8 +43,10 @@ export async function run({ if (typeof payload.motd !== 'string' || payload.motd.length >= MaxMOTDLength) { return server.reply({ - cmd: 'warn', // @todo Add numeric error code as `id` + cmd: 'warn', text: `Failed to set motd: Invalid motd, max length: ${MaxMOTDLength}`, + MaxLength: MaxMOTDLength, + id: Errors.SetMOTD.TOO_LONG, channel: socket.channel, // @todo Multichannel }, socket); } @@ -54,13 +58,13 @@ export async function run({ updateChannelSettings(core.appConfig.data, socket.channel, channelSettings); server.broadcast({ - cmd: 'info', // @todo Add numeric error code as `id` + cmd: 'info', // @todo Add numeric info code as `id` text: `MOTD changed by [${socket.trip}]${socket.nick}, new motd:`, channel: socket.channel, // @todo Multichannel }, { channel: socket.channel }); server.broadcast({ - cmd: 'info', // @todo Add numeric error code as `id` + cmd: 'info', // @todo Add numeric info code as `id` text: channelSettings.motd, channel: socket.channel, // @todo Multichannel }, { channel: socket.channel }); diff --git a/commands/channels/unclaimchannel.js b/commands/channels/unclaimchannel.js index 4e2c0f8..854eb09 100644 --- a/commands/channels/unclaimchannel.js +++ b/commands/channels/unclaimchannel.js @@ -12,7 +12,7 @@ import { levels, } from '../utility/_UAC.js'; import { - // Errors, + Errors, DefaultChannelSettings, } from '../utility/_Constants.js'; import { @@ -36,8 +36,9 @@ export async function run({ if (!socket.trip) { return server.reply({ - cmd: 'warn', // @todo Add numeric error code as `id` - text: 'Failed to release ownership: Missing trip code.', + cmd: 'warn', + text: 'Failed to run command: Missing trip code.', + id: Errors.Global.MISSING_TRIPCODE, channel: socket.channel, // @todo Multichannel }, socket); } @@ -46,16 +47,18 @@ export async function run({ if (channelSettings.owned === false) { return server.reply({ - cmd: 'info', // @todo Add numeric error code as `id` + cmd: 'warn', text: 'Failed to release ownership: That which is not owned may not be unowned, and with strange aeons. . .', + id: Errors.UnclaimChannel.NOT_OWNED, channel: socket.channel, // @todo Multichannel }, socket); } if (channelSettings.ownerTrip !== socket.trip && !isModerator(socket.level)) { return server.reply({ - cmd: 'warn', // @todo Add numeric error code as `id` + cmd: 'warn', text: 'Failed to release ownership: Wrong trip code.', + id: Errors.UnclaimChannel.FAKE_OWNER, channel: socket.channel, // @todo Multichannel }, socket); } @@ -63,7 +66,7 @@ export async function run({ updateChannelSettings(core.appConfig.data, socket.channel, DefaultChannelSettings); server.broadcast({ - cmd: 'info', + cmd: 'info', // @todo Add numeric info code as `id` text: 'Channel ownership has been removed and the channel settings have been reset', channel: socket.channel, }, { channel: socket.channel }); diff --git a/commands/core/changecolor.js b/commands/core/changecolor.js index 3099a44..dc7be32 100644 --- a/commands/core/changecolor.js +++ b/commands/core/changecolor.js @@ -9,6 +9,9 @@ import { getUserDetails, } from '../utility/_UAC.js'; +import { + Errors, +} from '../utility/_Constants.js'; /** * Validate a string as a valid hex color string @@ -32,8 +35,9 @@ export async function run({ if (server.police.frisk(socket, 1)) { return server.reply({ - cmd: 'warn', // @todo Add numeric error code as `id` + cmd: 'warn', text: 'You are changing colors too fast. Wait a moment before trying again.', + id: Errors.Global.RATELIMIT, channel, // @todo Multichannel }, socket); } @@ -49,6 +53,7 @@ export async function run({ return server.reply({ cmd: 'warn', text: 'Invalid color! Color must be in hex value', + id: Errors.ChangeColor.INVALID_COLOR, channel, // @todo Multichannel }, socket); } @@ -107,7 +112,8 @@ export function colorCheck({ if (input[1] === undefined) { server.reply({ cmd: 'warn', - text: 'Refer to `/help changecolor` for instructions on how to use this command.', + text: 'Invalid color! Color must be in hex value', + id: Errors.ChangeColor.INVALID_COLOR, channel: socket.channel, // @todo Multichannel }, socket); diff --git a/commands/core/changenick.js b/commands/core/changenick.js index 6932b3e..a622b6b 100644 --- a/commands/core/changenick.js +++ b/commands/core/changenick.js @@ -12,6 +12,9 @@ import { verifyNickname, getUserDetails, } from '../utility/_UAC.js'; +import { + Errors, +} from '../utility/_Constants.js'; /** * Executes when invoked by a remote client @@ -26,8 +29,9 @@ export async function run({ if (server.police.frisk(socket, 6)) { return server.reply({ - cmd: 'warn', // @todo Add numeric error code as `id` + cmd: 'warn', text: 'You are changing nicknames too fast. Wait a moment before trying again.', + id: Errors.Global.RATELIMIT, channel, // @todo Multichannel }, socket); } @@ -43,16 +47,18 @@ export async function run({ const newNick = payload.nick.trim(); if (!verifyNickname(newNick)) { return server.reply({ - cmd: 'warn', // @todo Add numeric error code as `id` + cmd: 'warn', text: 'Nickname must consist of up to 24 letters, numbers, and underscores', + id: Errors.Join.INVALID_NICK, channel, // @todo Multichannel }, socket); } if (newNick == previousNick) { return server.reply({ - cmd: 'warn', // @todo Add numeric error code as `id` - text: 'You already have that name', + cmd: 'warn', + text: 'Nickname taken', + id: Errors.Join.NAME_TAKEN, channel, // @todo Multichannel }, socket); } @@ -69,8 +75,9 @@ export async function run({ if (userExists.length > 0) { // That nickname is already in that channel return server.reply({ - cmd: 'warn', // @todo Add numeric error code as `id` + cmd: 'warn', text: 'Nickname taken', + id: Errors.Join.NAME_TAKEN, channel, // @todo Multichannel }, socket); } @@ -118,7 +125,7 @@ export async function run({ // notify channel that the user has changed their name server.broadcast({ - cmd: 'info', + cmd: 'info', // @todo Add numeric info code as `id` text: `${socket.nick} is now ${newNick}`, channel, // @todo Multichannel }, { channel }); @@ -160,8 +167,9 @@ export function nickCheck({ // If there is no nickname target parameter if (!input[1]) { server.reply({ - cmd: 'warn', // @todo Add numeric error code as `id` - text: 'Refer to `/help nick` for instructions on how to use this command.', + cmd: 'warn', + text: 'Nickname must consist of up to 24 letters, numbers, and underscores', + id: Errors.Join.INVALID_NICK, channel: socket.channel, // @todo Multichannel }, socket); diff --git a/commands/core/chat.js b/commands/core/chat.js index 4ed9b8d..5fc579a 100644 --- a/commands/core/chat.js +++ b/commands/core/chat.js @@ -13,6 +13,9 @@ import { isAdmin, isModerator, } from '../utility/_UAC.js'; +import { + Errors, +} from '../utility/_Constants.js'; /** * Maximum length of the customId property @@ -95,8 +98,9 @@ export async function run({ const score = text.length / 83 / 4; if (server.police.frisk(socket, score)) { return server.reply({ - cmd: 'warn', // @todo Add numeric error code as `id` + cmd: 'warn', text: 'You are sending too much text. Wait a moment and try again.\nPress the up arrow key to restore your last message.', + id: Errors.Global.RATELIMIT, channel: socket.channel, // @todo Multichannel }, socket); } @@ -172,7 +176,7 @@ export function commandCheckIn({ server, socket, payload }) { if (payload.text.startsWith('/myhash')) { server.reply({ - cmd: 'info', + cmd: 'info', // @todo Add numeric info code as `id` text: `Your hash: ${socket.hash}`, channel: socket.channel, // @todo Multichannel }, socket); @@ -208,8 +212,9 @@ export function finalCmdCheck({ server, socket, payload }) { } server.reply({ - cmd: 'warn', // @todo Add numeric error code as `id` + cmd: 'warn', text: `Unknown command: ${payload.text}`, + id: Errors.Global.UNKNOWN_CMD, channel: socket.channel, // @todo Multichannel }, socket); diff --git a/commands/core/emote.js b/commands/core/emote.js index 5f4d214..2e6c7a5 100644 --- a/commands/core/emote.js +++ b/commands/core/emote.js @@ -6,6 +6,10 @@ * @module emote */ +import { + Errors, +} from '../utility/_Constants.js'; + /** * Check and trim string provided by remote client * @param {string} text - Subject string @@ -48,8 +52,9 @@ export async function run({ server, socket, payload }) { const score = text.length / 83 / 4; if (server.police.frisk(socket, score)) { return server.reply({ - cmd: 'warn', // @todo Add numeric error code as `id` + cmd: 'warn', text: 'You are sending too much text. Wait a moment and try again.\nPress the up arrow key to restore your last message.', + id: Errors.Global.RATELIMIT, channel: socket.channel, // @todo Multichannel }, socket); } @@ -108,8 +113,9 @@ export function emoteCheck({ // If there is no emote target parameter if (input[1] === undefined) { server.reply({ - cmd: 'warn', // @todo Add numeric error code as `id` + cmd: 'warn', text: 'Refer to `/help emote` for instructions on how to use this command.', + id: Errors.Emote.MISSING_TEXT, channel: socket.channel, // @todo Multichannel }, socket); diff --git a/commands/core/help.js b/commands/core/help.js index 64de931..c99b8bd 100644 --- a/commands/core/help.js +++ b/commands/core/help.js @@ -8,6 +8,7 @@ import { CodebaseVersion, + Errors, } from '../utility/_Constants.js'; /** @@ -22,8 +23,9 @@ export async function run({ // check for spam if (server.police.frisk(socket, 2)) { return server.reply({ - cmd: 'warn', // @todo Add numeric error code as `id` + cmd: 'warn', text: 'You are sending too much text. Wait a moment and try again.\nPress the up arrow key to restore your last message.', + id: Errors.Global.RATELIMIT, channel: socket.channel, // @todo Multichannel }, socket); } @@ -68,7 +70,7 @@ export async function run({ // output reply server.reply({ - cmd: 'info', + cmd: 'info', // @todo Add numeric info code as `id` text: reply, channel: socket.channel, // @todo Multichannel }, socket); diff --git a/commands/core/join.js b/commands/core/join.js index ca9d042..ded6c8f 100644 --- a/commands/core/join.js +++ b/commands/core/join.js @@ -74,7 +74,7 @@ export async function run({ // @todo multichannel update, will remove if (typeof socket.channel !== 'undefined') { return server.reply({ - cmd: 'warn', // @todo Remove this + cmd: 'warn', text: 'Joining more than one channel is not currently supported', id: Errors.Join.ALREADY_JOINED, channel: false, // @todo Multichannel, false for global event @@ -101,7 +101,7 @@ export async function run({ return server.reply({ cmd: 'warn', text: 'You may not join that channel.', - // id: Errors.Join., // @todo Add numeric error code as `id` + id: Errors.Join.CHANNEL_LOCKED, channel: false, // @todo Multichannel, false for global event }, socket); } @@ -181,13 +181,13 @@ export async function run({ channel, // @todo Multichannel (?) }, socket); - var motd = channelSettings.motd; + let { motd } = channelSettings; if (motd === '') { motd = SystemMOTDs[Math.floor(Math.random() * SystemMOTDs.length)]; } server.reply({ - cmd: 'info', + cmd: 'info', // @todo Add numeric info code as `id` text: motd, channel, }, socket); diff --git a/commands/core/morestats.js b/commands/core/morestats.js index 28bd7bc..c68e1b8 100644 --- a/commands/core/morestats.js +++ b/commands/core/morestats.js @@ -74,7 +74,7 @@ export async function run({ core, server, socket }) { // dispatch info server.reply({ - cmd: 'info', + cmd: 'info', // @todo Add numeric info code as `id` users: uniqueClientCount, chans: uniqueChannels, joins, diff --git a/commands/core/stats.js b/commands/core/stats.js index ec1cfe5..c0a0657 100644 --- a/commands/core/stats.js +++ b/commands/core/stats.js @@ -32,7 +32,7 @@ export async function run({ core, server, socket }) { // dispatch info server.reply({ - cmd: 'info', + cmd: 'info', // @todo Add numeric info code as `id` text: `${uniqueClientCount} unique IPs in ${uniqueChannels} channels`, channel: socket.channel, // @todo Multichannel }, socket); diff --git a/commands/core/whisper.js b/commands/core/whisper.js index 9f80a39..00052f4 100644 --- a/commands/core/whisper.js +++ b/commands/core/whisper.js @@ -66,8 +66,9 @@ export async function run({ server, socket, payload }) { const score = text.length / 83 / 4; if (server.police.frisk(socket, score)) { return server.reply({ - cmd: 'warn', // @todo Add numeric error code as `id` + cmd: 'warn', text: 'You are sending too much text. Wait a moment and try again.\nPress the up arrow key to restore your last message.', + id: Errors.Global.RATELIMIT, channel: socket.channel, // @todo Multichannel }, socket); } @@ -141,8 +142,9 @@ export function whisperCheck({ // If there is no nickname target parameter if (!input[1]) { server.reply({ - cmd: 'warn', // @todo Add numeric error code as `id` + cmd: 'warn', text: 'Refer to `/help whisper` for instructions on how to use this command.', + id: Errors.Whisper.MISSING_NICK, channel: socket.channel, // @todo Multichannel }, socket); @@ -171,8 +173,9 @@ export function whisperCheck({ if (payload.text.startsWith('/reply ') || payload.text.startsWith('/r ')) { if (typeof socket.whisperReply === 'undefined') { server.reply({ - cmd: 'warn', // @todo Add numeric error code as `id` + cmd: 'warn', text: 'Cannot reply to nobody', + id: Errors.Whisper.NO_REPLY, channel: socket.channel, // @todo Multichannel }, socket); diff --git a/commands/internal/socketreply.js b/commands/internal/socketreply.js index 1a03ec9..a29d924 100644 --- a/commands/internal/socketreply.js +++ b/commands/internal/socketreply.js @@ -7,6 +7,10 @@ * @module socketreply */ +import { + Errors, +} from '../utility/_Constants.js'; + /** * Executes when invoked by a remote client * @param {Object} env - Environment object with references to core, server, socket & payload @@ -23,6 +27,8 @@ export async function run({ server, socket, payload }) { return server.reply({ cmd: 'warn', text: payload.text, + id: Errors.Global.INTERNAL_ERROR, + channel: false, }, socket); } diff --git a/commands/mod/ban.js b/commands/mod/ban.js index d43593b..4bd5ac2 100644 --- a/commands/mod/ban.js +++ b/commands/mod/ban.js @@ -71,7 +71,7 @@ export async function run({ // notify normal users server.broadcast({ - cmd: 'info', + cmd: 'info', // @todo Add numeric info code as `id` text: `Banned ${targetNick}`, user: getUserDetails(targetUser), channel: socket.channel, // @todo Multichannel @@ -79,7 +79,7 @@ export async function run({ // notify mods server.broadcast({ - cmd: 'info', + cmd: 'info', // @todo Add numeric info code as `id` text: `${socket.nick}#${socket.trip} banned ${targetNick} in ${payload.channel}, userhash: ${targetUser.hash}`, channel: socket.channel, // @todo Multichannel inChannel: payload.channel, diff --git a/commands/mod/disablecaptcha.js b/commands/mod/disablecaptcha.js index bc60e43..49a95b0 100644 --- a/commands/mod/disablecaptcha.js +++ b/commands/mod/disablecaptcha.js @@ -51,7 +51,7 @@ export async function run({ if (!core.captchas[targetChannel]) { return server.reply({ - cmd: 'info', + cmd: 'info', // @todo Add numeric info code as `id` text: 'Captcha is not enabled.', channel: socket.channel, // @todo Multichannel }, socket); @@ -60,7 +60,7 @@ export async function run({ core.captchas[targetChannel] = false; server.broadcast({ - cmd: 'info', + cmd: 'info', // @todo Add numeric info code as `id` text: `Captcha disabled on: ${targetChannel}`, channel: false, // @todo Multichannel, false for global info }, { channel: targetChannel, level: isModerator }); diff --git a/commands/mod/dumb.js b/commands/mod/dumb.js index fbcb328..00f8306 100644 --- a/commands/mod/dumb.js +++ b/commands/mod/dumb.js @@ -130,7 +130,7 @@ export async function run({ // notify mods server.broadcast({ - cmd: 'info', + cmd: 'info', // @todo Add numeric info code as `id` text: `${socket.nick}#${socket.trip} muzzled ${targetUser.nick} in ${payload.channel}, userhash: ${targetUser.hash}`, channel: false, // @todo Multichannel, false for global }, { level: isModerator }); @@ -315,8 +315,9 @@ export function whisperCheck({ const score = text.length / 83 / 4; if (server.police.frisk(socket, score)) { return server.reply({ - cmd: 'warn', // @todo Add numeric error code as `id` + cmd: 'warn', text: 'You are sending too much text. Wait a moment and try again.\nPress the up arrow key to restore your last message.', + id: Errors.Global.RATELIMIT, channel: socket.channel, // @todo Multichannel }, socket); } diff --git a/commands/mod/enablecaptcha.js b/commands/mod/enablecaptcha.js index 84f8ecd..a3ac3fd 100644 --- a/commands/mod/enablecaptcha.js +++ b/commands/mod/enablecaptcha.js @@ -68,7 +68,7 @@ export async function run({ if (core.captchas[targetChannel]) { return server.reply({ - cmd: 'info', + cmd: 'info', // @todo Add numeric info code as `id` text: 'Captcha is already enabled.', channel: socket.channel, // @todo Multichannel }, socket); @@ -77,7 +77,7 @@ export async function run({ core.captchas[targetChannel] = true; server.broadcast({ - cmd: 'info', + cmd: 'info', // @todo Add numeric info code as `id` text: `Captcha enabled on: ${targetChannel}`, channel: socket.channel, // @todo Multichannel, false for global info }, { channel: socket.channel, level: isModerator }); @@ -192,7 +192,7 @@ export function joinCheck({ // @todo multichannel update, will remove if (typeof socket.channel !== 'undefined') { return server.reply({ - cmd: 'warn', // @todo Remove this + cmd: 'warn', text: 'Joining more than one channel is not currently supported', id: Errors.Join.ALREADY_JOINED, channel: false, // @todo Multichannel, false for global event @@ -240,6 +240,7 @@ export function joinCheck({ server.reply({ cmd: 'warn', text: 'Enter the following to join (case-sensitive):', + id: Errors.Captcha.MUST_SOLVE, channel: payload.channel, // @todo Multichannel }, socket); diff --git a/commands/mod/forcecolor.js b/commands/mod/forcecolor.js index d2d70dd..75671de 100644 --- a/commands/mod/forcecolor.js +++ b/commands/mod/forcecolor.js @@ -60,6 +60,7 @@ export async function run({ return server.reply({ cmd: 'warn', text: 'Invalid color! Color must be in hex value', + id: Errors.ChangeColor.INVALID_COLOR, channel, // @todo Multichannel }, socket); } @@ -137,6 +138,7 @@ export function colorCheck({ server.reply({ cmd: 'warn', text: 'Refer to `/help forcecolor` for instructions on how to use this command.', + id: Errors.ForceColor.MISSING_NICK, channel: socket.channel, // @todo Multichannel }, socket); @@ -146,7 +148,8 @@ export function colorCheck({ if (input[2] === undefined) { server.reply({ cmd: 'warn', - text: 'Refer to `/help forcecolor` for instructions on how to use this command.', + text: 'Invalid color! Color must be in hex value', + id: Errors.ChangeColor.INVALID_COLOR, channel: socket.channel, // @todo Multichannel }, socket); diff --git a/commands/mod/kick.js b/commands/mod/kick.js index 17e459b..c1dc0b9 100644 --- a/commands/mod/kick.js +++ b/commands/mod/kick.js @@ -102,7 +102,7 @@ export async function run({ kicked[i].channel = destChannel; server.broadcast({ - cmd: 'info', + cmd: 'info', // @todo Add numeric info code as `id` text: `${kicked[i].nick} was banished to ?${destChannel}`, channel: socket.channel, // @todo Multichannel }, { channel: socket.channel, level: isModerator }); @@ -122,7 +122,7 @@ export async function run({ // publicly broadcast kick event server.broadcast({ - cmd: 'info', + cmd: 'info', // @todo Add numeric info code as `id` text: `Kicked ${kicked.map((k) => k.nick).join(', ')}`, channel: socket.channel, // @todo Multichannel }, { channel: socket.channel, level: (level) => isModerator(level) }); diff --git a/commands/mod/lockroom.js b/commands/mod/lockroom.js index 4421e84..600eb57 100644 --- a/commands/mod/lockroom.js +++ b/commands/mod/lockroom.js @@ -88,7 +88,7 @@ export async function run({ if (core.locked[targetChannel]) { return server.reply({ - cmd: 'info', + cmd: 'info', // @todo Add numeric info code as `id` text: 'Channel is already locked.', channel: socket.channel, // @todo Multichannel }, socket); @@ -99,7 +99,7 @@ export async function run({ // inform mods server.broadcast({ - cmd: 'info', + cmd: 'info', // @todo Add numeric info code as `id` text: `Channel: ?${targetChannel} lock enabled by [${socket.trip}]${socket.nick}`, channel: false, // @todo Multichannel, false for global info }, { level: isModerator }); @@ -243,7 +243,7 @@ export function joinCheck({ // @todo multichannel update, will remove if (typeof socket.channel !== 'undefined') { return server.reply({ - cmd: 'warn', // @todo Remove this + cmd: 'warn', text: 'Joining more than one channel is not currently supported', id: Errors.Join.ALREADY_JOINED, channel: false, // @todo Multichannel, false for global event @@ -296,14 +296,14 @@ export function joinCheck({ setTimeout(() => { server.reply({ - cmd: 'info', + cmd: 'info', // @todo Add numeric info code as `id` text: danteQuotes[Math.floor(Math.random() * danteQuotes.length)], channel: 'purgatory', // @todo Multichannel }, socket); }, 100); server.broadcast({ - cmd: 'info', + cmd: 'info', // @todo Add numeric info code as `id` text: `${payload.nick} is: ${origNick}\ntrip: ${userInfo.trip || 'none'}\ntried to join: ?${origChannel}\nhash: ${userInfo.hash}`, channel: 'purgatory', // @todo Multichannel, false for global info }, { channel: 'purgatory', level: isModerator }); diff --git a/commands/mod/speak.js b/commands/mod/speak.js index 392ebc4..9803c54 100644 --- a/commands/mod/speak.js +++ b/commands/mod/speak.js @@ -11,6 +11,9 @@ import { isModerator, } from '../utility/_UAC.js'; +import { + Errors, +} from '../utility/_Constants.js'; /** * Automatically executes once after server is ready @@ -41,8 +44,9 @@ export async function run({ // check user input if (typeof payload.ip !== 'string' && typeof payload.hash !== 'string') { return server.reply({ - cmd: 'warn', // @todo Add numeric error code as `id` + cmd: 'warn', text: "hash:'targethash' or ip:'1.2.3.4' is required", + id: Errors.Users.BAD_HASH_OR_IP, channel: socket.channel, // @todo Multichannel }, socket); } @@ -52,7 +56,7 @@ export async function run({ core.muzzledHashes = {}; return server.broadcast({ - cmd: 'info', + cmd: 'info', // @todo Add numeric info code as `id` text: `${socket.nick} unmuzzled all users`, channel: false, // @todo Multichannel, false for global }, { level: isModerator }); @@ -61,7 +65,7 @@ export async function run({ core.muzzledHashes = {}; return server.broadcast({ - cmd: 'info', + cmd: 'info', // @todo Add numeric info code as `id` text: `${socket.nick} unmuzzled all users`, channel: false, // @todo Multichannel, false for global }, { level: isModerator }); @@ -79,7 +83,7 @@ export async function run({ // notify mods server.broadcast({ - cmd: 'info', + cmd: 'info', // @todo Add numeric info code as `id` text: `${socket.nick}#${socket.trip} unmuzzled : ${target}`, channel: false, // @todo Multichannel, false for global }, { level: isModerator }); diff --git a/commands/mod/unban.js b/commands/mod/unban.js index 2256cfa..9679e71 100644 --- a/commands/mod/unban.js +++ b/commands/mod/unban.js @@ -9,6 +9,9 @@ import { isModerator, } from '../utility/_UAC.js'; +import { + Errors, +} from '../utility/_Constants.js'; /** * Executes when invoked by a remote client @@ -27,8 +30,9 @@ export async function run({ // check user input if (typeof payload.ip !== 'string' && typeof payload.hash !== 'string') { return server.reply({ - cmd: 'warn', // @todo Add numeric error code as `id` + cmd: 'warn', text: "hash:'targethash' or ip:'1.2.3.4' is required", + id: Errors.Users.BAD_HASH_OR_IP, channel: socket.channel, // @todo Multichannel }, socket); } @@ -55,14 +59,14 @@ export async function run({ // reply with success server.reply({ - cmd: 'info', + cmd: 'info', // @todo Add numeric info code as `id` text: `Unbanned ${target}`, channel: socket.channel, // @todo Multichannel }, socket); // notify mods server.broadcast({ - cmd: 'info', + cmd: 'info', // @todo Add numeric info code as `id` text: `${socket.nick}#${socket.trip} unbanned: ${target}`, channel: false, // @todo Multichannel, false for global }, { level: isModerator }); diff --git a/commands/mod/unbanall.js b/commands/mod/unbanall.js index d18537e..4856437 100644 --- a/commands/mod/unbanall.js +++ b/commands/mod/unbanall.js @@ -31,14 +31,14 @@ export async function run({ core, server, socket }) { // reply with success server.reply({ - cmd: 'info', + cmd: 'info', // @todo Add numeric info code as `id` text: 'Unbanned all ip addresses', channel: socket.channel, // @todo Multichannel }, socket); // notify mods server.broadcast({ - cmd: 'info', + cmd: 'info', // @todo Add numeric info code as `id` text: `${socket.nick}#${socket.trip} unbanned all ip addresses`, channel: false, // @todo Multichannel, false for global }, { level: isModerator }); diff --git a/commands/mod/unlockroom.js b/commands/mod/unlockroom.js index 387a8bb..fa2843b 100644 --- a/commands/mod/unlockroom.js +++ b/commands/mod/unlockroom.js @@ -52,7 +52,7 @@ export async function run({ if (!core.locked[targetChannel]) { return server.reply({ - cmd: 'info', + cmd: 'info', // @todo Add numeric info code as `id` text: 'Channel is not locked.', channel: socket.channel, // @todo Multichannel }, socket); @@ -61,7 +61,7 @@ export async function run({ core.locked[targetChannel] = false; server.broadcast({ - cmd: 'info', + cmd: 'info', // @todo Add numeric info code as `id` text: `Channel: ?${targetChannel} unlocked by [${socket.trip}]${socket.nick}`, channel: targetChannel, // @todo Multichannel, false for global info }, { channel: targetChannel, level: isModerator }); diff --git a/commands/utility/_Constants.js b/commands/utility/_Constants.js index d1c435c..b5852e4 100644 --- a/commands/utility/_Constants.js +++ b/commands/utility/_Constants.js @@ -10,14 +10,28 @@ * Internal version, used mainly for debugging * @typedef {object} CodebaseVersion */ -export const CodebaseVersion = '2.2.23b'; +export const CodebaseVersion = '2.2.24b'; /* Base error ranges */ const GlobalErrors = 10; -const JoinErrors = 20; -const ChannelErrors = 30; -const InviteErrors = 40; -const SessionErrors = 50; +const CaptchaNotif = GlobalErrors + 10; +const JoinErrors = CaptchaNotif + 10; +const ChannelErrors = JoinErrors + 10; +const InviteErrors = ChannelErrors + 10; +const SessionErrors = InviteErrors + 10; +const SaveConfigErrors = SessionErrors + 10; +const ClaimChannelErrors = SaveConfigErrors + 10; +const MakePrivateErrors = ClaimChannelErrors + 10; +const MakePublicErrors = MakePrivateErrors + 10; +const RenewClaimErrors = MakePublicErrors + 10; +const SetLevelErrors = RenewClaimErrors + 10; +const SetMOTDErrors = SetLevelErrors + 10; +const UnclaimChannelErrors = SetMOTDErrors + 10; +const ChangeColorErrors = UnclaimChannelErrors + 10; +const EmoteErrors = ChangeColorErrors + 10; +const WhisperErrors = EmoteErrors + 10; +const ForceColorErrors = WhisperErrors + 10; +const UsersErrors = ForceColorErrors + 10; /** * Holds the numeric id values for each error type @@ -28,6 +42,13 @@ export const Errors = { RATELIMIT: GlobalErrors + 1, UNKNOWN_USER: GlobalErrors + 2, PERMISSION: GlobalErrors + 3, + INTERNAL_ERROR: GlobalErrors + 4, + MISSING_TRIPCODE: GlobalErrors + 5, + UNKNOWN_CMD: GlobalErrors + 6, + }, + + Captcha: { + MUST_SOLVE: CaptchaNotif + 1, }, Join: { @@ -35,6 +56,7 @@ export const Errors = { INVALID_NICK: JoinErrors + 2, ALREADY_JOINED: JoinErrors + 3, NAME_TAKEN: JoinErrors + 4, + CHANNEL_LOCKED: JoinErrors + 5, }, Channel: { @@ -50,6 +72,68 @@ export const Errors = { Session: { BAD_SESSION: SessionErrors + 1, }, + + SaveConfig: { + GENERAL_FAILURE: SaveConfigErrors + 1, + }, + + ClaimChannel: { + MODS_CANT: ClaimChannelErrors + 1, + ALREADY_OWNED: ClaimChannelErrors + 2, + }, + + MakePrivate: { + MISSING_PERMS: MakePrivateErrors + 1, + ALREADY_PRIVATE: MakePrivateErrors + 2, + }, + + MakePublic: { + MISSING_PERMS: MakePublicErrors + 1, + ALREADY_PUBLIC: MakePublicErrors + 2, + }, + + RenewClaim: { + MODS_CANT: RenewClaimErrors + 1, + NOT_OWNER: RenewClaimErrors + 2, + TOO_SOON: RenewClaimErrors + 3, + }, + + SetLevel: { + BAD_TRIP: SetLevelErrors + 1, + BAD_LABEL: SetLevelErrors + 2, + BAD_LEVEL: SetLevelErrors + 3, + APPLY_ERROR: SetLevelErrors + 4, + }, + + SetMOTD: { + TOO_LONG: SetMOTDErrors + 1, + }, + + UnclaimChannel: { + NOT_OWNED: UnclaimChannelErrors + 1, + FAKE_OWNER: UnclaimChannelErrors + 2, + }, + + ChangeColor: { + INVALID_COLOR: ChangeColorErrors + 1, + }, + + Emote: { + MISSING_TEXT: EmoteErrors + 1, + }, + + Whisper: { + MISSING_NICK: WhisperErrors + 1, + NO_REPLY: WhisperErrors + 2, + }, + + ForceColor: { + MISSING_NICK: ForceColorErrors + 1, + }, + + Users: { + BAD_HASH_OR_IP: UsersErrors + 1, + }, }; /** diff --git a/scripts/config.js b/scripts/config.js index d78370e..df0435c 100644 --- a/scripts/config.js +++ b/scripts/config.js @@ -184,8 +184,8 @@ const setupChannels = async () => { ownerTrip: 'Admin', lastAccessed: now, claimExpires: expirationDate, - } - } + }, + }; for (let i = 0, j = config.data.publicChannels.length; i < j; i += 1) { const channelHash = getChannelHash(config.data.publicChannels[i]);