#messageCommandDenied preventing bot from booting

1 messages · Page 1 of 1 (latest)

civic olive
#

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:

  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);
    }
}
safe stag
#

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?

civic olive
#

Praise be the isTextBasedChannel utility function, savior of all my bots in the future!! Yeah I can make a GH issue, uno momento

#

It works now, marking as solved, thanks!

safe stag
#

Thanks!