diff --git a/js/client-chat.js b/js/client-chat.js index f519ef4ae..96c46cdf0 100644 --- a/js/client-chat.js +++ b/js/client-chat.js @@ -923,8 +923,12 @@ case 'avatar': var parts = target.split(','); var avatar = parts[0].toLowerCase().replace(/[^a-z0-9-]+/g, ''); + // Replace avatar number with name before sending it to the server, only the client knows what to do with the numbers + if (window.BattleAvatarNumbers && Object.prototype.hasOwnProperty.call(window.BattleAvatarNumbers, avatar)) { + avatar = window.BattleAvatarNumbers[avatar]; + } Dex.prefs('avatar', avatar); - return text; // Send the /avatar command through to the server. + return '/avatar ' + avatar; // Send the command through to the server. case 'afd': var cleanedTarget = toID(target); diff --git a/js/client-topbar.js b/js/client-topbar.js index 85328e5a4..cee6be293 100644 --- a/js/client-topbar.js +++ b/js/client-topbar.js @@ -670,10 +670,14 @@ buf += '
'; this.$el.html(buf).css('max-width', 780); }, - setAvatar: function (i) { - app.send('/avatar ' + i); + setAvatar: function (avatar) { + // Replace avatar number with name before sending it to the server, only the client knows what to do with the numbers + if (window.BattleAvatarNumbers && Object.prototype.hasOwnProperty.call(window.BattleAvatarNumbers, avatar)) { + avatar = window.BattleAvatarNumbers[avatar]; + } + app.send('/avatar ' + avatar); app.send('/cmd userdetails ' + app.user.get('userid')); - Dex.prefs('avatar', i); + Dex.prefs('avatar', avatar); this.close(); } });