eduardo-olivares1 / Narwhal

A discord bot designed to alert users of important cryptocurrency movements and events.
MIT License
2 stars 1 forks source link

Empty argument breaks ping #6

Closed fredtsun closed 3 years ago

fredtsun commented 3 years ago

im not sure if this is just me but when i set this up locally and tested it empty arguments to ping seemed to break.

I'm seeing this exception:

/Users/fredsun/Code/Narwhal/commands/ping.js:8
        if (args[0].toLowerCase() === "coingecko"){
                    ^

TypeError: Cannot read property 'toLowerCase' of undefined
    at Object.execute (/Users/fredsun/Code/Narwhal/commands/ping.js:8:21)
    at DiscordCommandHandler._processCommand (/Users/fredsun/Code/Narwhal/services/discord_command_handler.js:47:20)
    at Client.emit (events.js:311:20)
    at MessageCreateAction.handle (/Users/fredsun/Code/Narwhal/node_modules/discord.js/src/client/actions/MessageCreate.js:31:14)
    at Object.module.exports [as MESSAGE_CREATE] (/Users/fredsun/Code/Narwhal/node_modules/discord.js/src/client/websocket/handlers/MESSAGE_CREATE.js:4:32)
    at WebSocketManager.handlePacket (/Users/fredsun/Code/Narwhal/node_modules/discord.js/src/client/websocket/WebSocketManager.js:384:31)
    at WebSocketShard.onPacket (/Users/fredsun/Code/Narwhal/node_modules/discord.js/src/client/websocket/WebSocketShard.js:444:22)
    at WebSocketShard.onMessage (/Users/fredsun/Code/Narwhal/node_modules/discord.js/src/client/websocket/WebSocketShard.js:301:10)
    at WebSocket.onMessage (/Users/fredsun/Code/Narwhal/node_modules/ws/lib/event-target.js:132:16)

Repro steps:

  1. message "$ping" in a discord channel.

I think the fix here is to just check for an empty arg list for now and return if it's empty.

eduardo-olivares1 commented 3 years ago

Fixed by pull request #7