messageCommandDenied preventing bot from booting

Hello, I'm using the basic messageCommandDenied code provided in the sapphire docs and it has been working up until today but upon booting up one of my bots I get the following error:
src/listeners/messageCommandDenied.ts:15:27 - error TS2339: Property 'send' does not exist on type 'DMChannel | PartialDMChannel | PartialGroupDMChannel | NewsChannel | StageChannel | TextChannel | PublicThreadChannel<...> | PrivateThreadChannel | VoiceChannel'.
Property 'send' does not exist on type 'PartialGroupDMChannel'.

15 return message.channel.send(error.message);
~~~~


Found 1 error in src/listeners/messageCommandDenied.ts:15
src/listeners/messageCommandDenied.ts:15:27 - error TS2339: Property 'send' does not exist on type 'DMChannel | PartialDMChannel | PartialGroupDMChannel | NewsChannel | StageChannel | TextChannel | PublicThreadChannel<...> | PrivateThreadChannel | VoiceChannel'.
Property 'send' does not exist on type 'PartialGroupDMChannel'.

15 return message.channel.send(error.message);
~~~~


Found 1 error in src/listeners/messageCommandDenied.ts:15
The code I use for this event is directly ripped from the docs here: https://www.sapphirejs.dev/docs/Guide/preconditions/reporting-precondition-failure
import {
Events,
Listener,
type MessageCommandDeniedPayload,
type UserError,
} from "@sapphire/framework";

export class MessageCommandDenied extends Listener<
typeof Events.MessageCommandDenied
> {
public run(error: UserError, { message }: MessageCommandDeniedPayload) {
return message.channel.send(error.message);
}
}
import {
Events,
Listener,
type MessageCommandDeniedPayload,
type UserError,
} from "@sapphire/framework";

export class MessageCommandDenied extends Listener<
typeof Events.MessageCommandDenied
> {
public run(error: UserError, { message }: MessageCommandDeniedPayload) {
return message.channel.send(error.message);
}
}
Sapphire Framework
Reporting precondition failure | Sapphire
When a precondition fails, it's usually important for the user to know why. For example, if they hit a cooldown or lack
6 Replies
Favna
Favna3mo ago
This is due to an update in discordjs 14.16.1. add a typeguard in your code for it. Sapphire code and docs havent been update yet. Simply do something like (message.channel as Exclude<Message['channel'], PartialGroupDMChannel>).send Could you make a GH issue to the sapphiredev/website repository remarking this so I have a reminder on GitHub? In the sapphire update that'll come in the coming weeks we'll provide an updated isTextBasedChannel utility function (through @sapphire/discord.js-utilities which is a transient dep of sapphire framework) that checks for this. https://github.com/sapphiredev/utilities/blob/fc35dd867f60ffe3298a9f7fdf790d84c3e353fa/packages/discord.js-utilities/src/lib/type-guards.ts#L158-L170
moosee
mooseeOP3mo ago
Praise be the isTextBasedChannel utility function, savior of all my bots in the future!! Yeah I can make a GH issue, uno momento
moosee
mooseeOP3mo ago
GitHub
request: Update the reporting precondition failure page · Issue #27...
Is there an existing issue or pull request for this? I have searched the existing issues and pull requests Feature description https://www.sapphirejs.dev/docs/Guide/preconditions/reporting-precondi...
moosee
mooseeOP3mo ago
It works now, marking as solved, thanks!
Favna
Favna3mo ago
Thanks!
Baylem
Baylem2mo ago
sorry for typing on a solved post, but this would also need to be updated in the Typescript starter example as the example ping command would need this update
Want results from more Discord servers?
Add your server