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