UnseenFaith/komada

client.funcs.log is not a function (but this is not in app.js)

Closed this issue · 5 comments

Version of Komada

0.19.0

Are core files modified?

functions/usage.js

Describe the problem

Attempting to run Komada results in a client.funcs.log is not a function error

Expected Behaviour

Komada boots and operates normally.

Actual Behaviour

Komada crashes with this error:
You have triggered an unhandledRejection, you may have forgotten to catch a Promise rejection:
TypeError: client.funcs.log is not a function
at Promise.all.catch.e (/root/discordjs/lovinibot/node_modules/komada/utils/loadFunctions.js:18:51)
Uncaught Promise Error:
TypeError: client.funcs.log is not a function
at Promise.all.catch.e (/root/discordjs/lovinibot/node_modules/komada/utils/loadFunctions.js:18:51)

Steps to Reproduce.

Looks like you have a function wrong, hace you updated the function usage from 0.19.0 or backported from 0.18.1?

Yes. What I did was I took the original usage.js code from the 0.19.0 version of functions/usage.js and ported my changes into it. The modification is as follows:

    case "user":
    case "mention":
      if ((/^<@!?\d+>$/.test(args[i]) || (/\d+/.test(args[i]) || args[i].length > 5)) {
		if (!client.users.has(/\d+/.exec(args[i])[0])) 
		{
		client.fetchUser(/\d+/.exec(args[i])[0])
		.then((theuser) => {
			args[i] = theuser;
			validateArgs(++i);
		})
		.catch((e) => {
		if (currentUsage.type === "optional" && !repeat) {
			args.splice(i, 0, undefined);
			validateArgs(++i);
		} else {
			args.splice(i, 1, null);
			return reject(client.funcs.newError(`${currentUsage.possibles[0].name} must be a mention or valid user id.`, 1, args));
		}
		});
	} else {
        args[i] = client.users.get(/\d+/.exec(args[i])[0]);
        validateArgs(++i);
	}
      } else if (currentUsage.type === "optional" && !repeat) {
        args.splice(i, 0, undefined);
        validateArgs(++i);
      } else {
        args.splice(i, 1, null);
        return reject(client.funcs.newError(`${currentUsage.possibles[0].name} must be a mention or valid user id.`, 1, args));
      }
      break;

Go to the line 18 from /utils/loadFunctions, and change client.funcs.log to console.error. Tell me what you get.

By the way, this issue is nuked on 0.20.0 (#indev)

Syntax error... missed a ). Fixed.

👌 Tell me if there's something else wrong.