Repository: discordjs/discord.js

Issue #455: Setting a channel topic a 2nd time throws server error.
Created: 2016-07-05T22:04:18Z
I'm trying to have my bot set a channel topic as a regular task with some information and it has been crashing, so I wrote a test command to trigger it manually, and it continues to crash.  Oddly, the first time I tell the bot to set the channel topic it runs flawlessly.  However if I have the bot set a channel topic a 2nd time I get this:
2016-07-05T21:48:11.389Z WARN Channel Topic Set Error
2016-07-05T21:48:11.425Z WARN
{ message: 'Internal Server Error',
  stack: 'Error: Internal Server Error\n
  at Request.callback (/home/discordbot/node_modules/discord.js/node_modules/superagent/lib/node/index.js:698:17)\n    
  at IncomingMessage.<anonymous> (/home/discordbot/node_modules/discord.js/node_modules/superagent/lib/node/index.js:922:12)\n
  at emitNone (events.js:72:20)\n
  at IncomingMessage.emit (events.js:166:7)\n    
  at endReadableNT (_stream_readable.js:913:12)\n    
  at nextTickCallbackWith2Args (node.js:442:9)\n    
  at process._tickCallback (node.js:35617)',
  original: null,
  response:
   Response {
     domain: null,
     _events: {},
     _eventsCount: 0,
     _maxListeners: undefined,
     res: [Object],
     request: [Object],
     req: [Object],
     links: {},
     text: '{"code": 0, "message": "int() argument must be a string or a number, not \'NoneType\'"}',
     body: [Object],
     files: {},
     buffered: true,
     headers: [Object],
     header: [Object],
     statusCode: 500,
     status: 500,
     statusType: 5,
     info: false,
     ok: false,
     redirect: false,
     clientError: false,
     serverError: true,
     error: [Object],
     accepted: false,
     noContent: false,
     badRequest: false,
     unauthorized: false,
     notAcceptable: false,
     forbidden: false,
     notFound: false,
     type: 'application/json',
     setEncoding: [Function: bound ],
     redirects: [] },
  status: 500 }

This is my code:
            var checkChan = null;
            var chanList = this.bot.channels;
            if ((opts !== undefined) && (opts !== null)) {
                var jopts = config.tryJSON(opts);  // makes sure is valid json
                if (jopts !== false) {
                    checkChan = chanList.get("name", jopts.name);

                    this.bot.setChannelTopic(checkChan.id, jopts.msg, function(error) {
                        if ((error !== undefined) && (error !== null))  {
                            logger.warn("Channel Topic Set Error");
                            logger.warn(error);
                        }
                        else {
                            logger.info("setChannelTopic: " + checkChan.id + " " + jopts.msg);
                        }
                    });
                }
                else {
                    logger.warn("setChannelTopic options are not valid JSON");
                }
            }
            else {
                logger.warn("setChannelTopic failed to execute, did you do it right?");
            }

Even if I sent the bot an invalid channel or topic message (which i'm not doing), it should still fail gracefully should it not?  Instead the bot crashes, and I really can't make sense of that error trace.  Any suggestions or is this a possible bug?

Duplicate issue #467: client.UpdateChannel(); updates only once.
Created: 2016-07-15T02:09:33Z
So yeah here is my code :
if (input.startsWith("TOPIC")) {
text = message.content.split(" ")[1];
bot.UpdateChannel(message, {topic: text});
}
(input is message.content.toUpperCase();)
and when I use the command it updates once then can't update anymore.

Closing comment (2016-07-18T19:19:49Z): Dupe of #455