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
awawarou
awawarou•2y ago
Show code
-Carlosđź‘‘
-Carlos👑OP•2y ago
wtf ararou
awawarou
awawarou•2y ago
oh wait what
-Carlosđź‘‘
-Carlos👑OP•2y ago
what code
awawarou
awawarou•2y ago
thats an internal one uh i have never seen that before
-Carlosđź‘‘
-Carlos👑OP•2y ago
it's weird because the precondition works as intended
awawarou
awawarou•2y ago
ya idk what thats about never have seen an error inside the internal listeners before show the precondition
-Carlosđź‘‘
-Carlos👑OP•2y 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,
};
awawarou
awawarou•2y ago
. Yeah that'll do it Lemme show you one of mine
b1nzee
b1nzee•2y ago
It's probably to do with you not returning this.error()
awawarou
awawarou•2y ago
No description
awawarou
awawarou•2y ago
yeah
b1nzee
b1nzee•2y ago
Really, you should be handling the message deleting within the CommandDenied listener or whatever it's called
awawarou
awawarou•2y ago
sapphire will throw a fit with preconditions if you dont include that yeah denied
b1nzee
b1nzee•2y 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•2y 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•2y ago
Yes
-Carlosđź‘‘
-Carlos👑OP•2y ago
rawError: { message: 'Cannot send an empty message', code: 50006 },
b1nzee
b1nzee•2y ago
Is that still coming from the precondition file?
-Carlosđź‘‘
-Carlos👑OP•2y ago
looks like it's from messageCommandDenied it's probably because there i'm trying to send the error message
b1nzee
b1nzee•2y ago
That's exactly why
-Carlosđź‘‘
-Carlos👑OP•2y ago
do i simply delete the file or
b1nzee
b1nzee•2y ago
No, just add a check if message isn't undefined
-Carlosđź‘‘
-Carlos👑OP•2y ago
worked perfectly, ty
b1nzee
b1nzee•2y ago
No problem

Did you find this page helpful?