Error

[ERROR] Encountered error on event listener "CorePreMessageCommandRun" for event "preMessageCommandRun" at path "C:\Users\cmart\Desktop\Discord Bots\Sapphire\node_modules\@sapphire\framework\dist\optional-listeners\message-command-listeners\CorePreMessageCommandRun.js" TypeError: result.isErr is not a function
at Object.messageSequential (C:\Users\cmart\Desktop\Discord Bots\Sapphire\node_modules\@sapphire\framework\dist\lib\utils\preconditions\conditions\PreconditionConditionAnd.js:10:18)
at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
at async CoreListener.run (C:\Users\cmart\Desktop\Discord Bots\Sapphire\node_modules\@sapphire\framework\dist\optional-listeners\message-command-listeners\CorePreMessageCommandRun.js:19:25)
at async Object.fromAsync (C:\Users\cmart\Desktop\Discord Bots\Sapphire\node_modules\@sapphire\result\dist\index.js:613:22)
at async CoreListener._run (C:\Users\cmart\Desktop\Discord Bots\Sapphire\node_modules\@sapphire\framework\dist\lib\structures\Listener.js:48:22)
[ERROR] Encountered error on event listener "CorePreMessageCommandRun" for event "preMessageCommandRun" at path "C:\Users\cmart\Desktop\Discord Bots\Sapphire\node_modules\@sapphire\framework\dist\optional-listeners\message-command-listeners\CorePreMessageCommandRun.js" TypeError: result.isErr is not a function
at Object.messageSequential (C:\Users\cmart\Desktop\Discord Bots\Sapphire\node_modules\@sapphire\framework\dist\lib\utils\preconditions\conditions\PreconditionConditionAnd.js:10:18)
at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
at async CoreListener.run (C:\Users\cmart\Desktop\Discord Bots\Sapphire\node_modules\@sapphire\framework\dist\optional-listeners\message-command-listeners\CorePreMessageCommandRun.js:19:25)
at async Object.fromAsync (C:\Users\cmart\Desktop\Discord Bots\Sapphire\node_modules\@sapphire\result\dist\index.js:613:22)
at async CoreListener._run (C:\Users\cmart\Desktop\Discord Bots\Sapphire\node_modules\@sapphire\framework\dist\lib\structures\Listener.js:48:22)
This error is logged to the console once a member gets their message deleted because they don't have enough permissions to run the command, I have no idea what is this error about
25 Replies
ararou!
ararou!•16mo ago
Show code
-Carlosđź‘‘
-Carlos👑OP•16mo ago
wtf ararou
ararou!
ararou!•16mo ago
oh wait what
-Carlosđź‘‘
-Carlos👑OP•16mo ago
what code
ararou!
ararou!•16mo ago
thats an internal one uh i have never seen that before
-Carlosđź‘‘
-Carlos👑OP•16mo ago
it's weird because the precondition works as intended
ararou!
ararou!•16mo ago
ya idk what thats about never have seen an error inside the internal listeners before show the precondition
-Carlosđź‘‘
-Carlos👑OP•16mo ago
const { Precondition } = require("@sapphire/framework");

class OwnerPrecondition extends Precondition {
messageRun(message) {
if (message.author.id === this.container.config.client.owner) {
return this.ok();
} else {
return message.delete().catch(() => null);
}
}
}

module.exports = {
OwnerPrecondition,
};
const { Precondition } = require("@sapphire/framework");

class OwnerPrecondition extends Precondition {
messageRun(message) {
if (message.author.id === this.container.config.client.owner) {
return this.ok();
} else {
return message.delete().catch(() => null);
}
}
}

module.exports = {
OwnerPrecondition,
};
ararou!
ararou!•16mo ago
. Yeah that'll do it Lemme show you one of mine
b1nzee
b1nzee•16mo ago
It's probably to do with you not returning this.error()
ararou!
ararou!•16mo ago
No description
ararou!
ararou!•16mo ago
yeah
b1nzee
b1nzee•16mo ago
Really, you should be handling the message deleting within the CommandDenied listener or whatever it's called
ararou!
ararou!•16mo ago
sapphire will throw a fit with preconditions if you dont include that yeah denied
b1nzee
b1nzee•16mo ago
Could do
return this.error({
message: null
});
return this.error({
message: null
});
Then check in your CommandDenied listener if the message is null, delete the message otherwise send the message Or just simply an empty this.error() if that works Cause message will be undefined anyway
-Carlosđź‘‘
-Carlos👑OP•16mo ago
Something like this?
if (message.author.id === this.container.config.client.owner) {
return this.ok();
} else {
message.delete().catch(() => null);
return this.error();
}
if (message.author.id === this.container.config.client.owner) {
return this.ok();
} else {
message.delete().catch(() => null);
return this.error();
}
kyra
kyra•16mo ago
Yes
-Carlosđź‘‘
-Carlos👑OP•16mo ago
rawError: { message: 'Cannot send an empty message', code: 50006 },
b1nzee
b1nzee•16mo ago
Is that still coming from the precondition file?
-Carlosđź‘‘
-Carlos👑OP•16mo ago
looks like it's from messageCommandDenied it's probably because there i'm trying to send the error message
b1nzee
b1nzee•16mo ago
That's exactly why
-Carlosđź‘‘
-Carlos👑OP•16mo ago
do i simply delete the file or
b1nzee
b1nzee•16mo ago
No, just add a check if message isn't undefined
-Carlosđź‘‘
-Carlos👑OP•16mo ago
worked perfectly, ty
b1nzee
b1nzee•16mo ago
No problem
Want results from more Discord servers?
Add your server