Skip to content

Commit

Permalink
Change regex to match only numbers in dynamic arg IDs
Browse files Browse the repository at this point in the history
  • Loading branch information
exoRift committed Jul 28, 2020
1 parent 5a8bc28 commit e786cfa
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 6 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
-
### **New handling features**
- Tokens are now automatically prefixed with the required keyword that designates bot accounts (Phasing out of Eris in the future)
- The dynamic argument parser now specifically looks for numbers in IDs rather than any character

### **Bug fixes**
- Fixed an issue where a 401 error would occur on using the Agent's connect method
Expand Down
12 changes: 7 additions & 5 deletions lib/modules/command-handler/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -45,8 +45,8 @@ class CommandHandler extends BaseHandler {
this._regexes = {
escapables: /[.*+?^${}()|[\]\\]/g,
dynamics: {
user: /<@!?(.+?)>/,
channel: /<#(.+?)>/
user: /<@!?(\d+)>/,
channel: /<#(\d+)>/
}
}

Expand Down Expand Up @@ -398,9 +398,10 @@ class CommandHandler extends BaseHandler {

/**
* Parse a dynamic arg (Either a mention or name)
* @param {Eris.Guild} guild The guild the target is in
* @param {String} arg The argument
* @param {String} type The type of arg (user, channel)
* @private
* @param {Eris.Guild} guild The guild the target is in
* @param {String} arg The argument
* @param {String} type The type of arg (user, channel)
*/
_parseDynArg (guild, arg, type) {
const container = type === 'user' ? this._client.users : guild.channels
Expand Down Expand Up @@ -485,6 +486,7 @@ class CommandHandler extends BaseHandler {

/**
* Normalize a message's content
* @private
* @param {String} msg The subject message
* @returns {Normalized} The processed content
*/
Expand Down
3 changes: 2 additions & 1 deletion lib/modules/reaction-handler/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -227,7 +227,8 @@ class ReactionHandler extends BaseHandler {

/**
* Load a reaction command
* @param {ReactCommand} reactCommand The reaction command to load
* @private
* @param {ReactCommand} reactCommand The reaction command to load
*/
_loadReactCommand (reactCommand) {
if (!(reactCommand instanceof ReactCommand)) throw TypeError('Supplied react command not a ReactCommand instance:\n' + reactCommand)
Expand Down

0 comments on commit e786cfa

Please sign in to comment.