Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Deprecation when updating commands that require bot to update a message #252

@antiftw

Description

@antiftw

When updating a command so that the bot also needs to rewrite the command output, I get a deprecation message:

DeprecationWarning: Message#deleted is deprecated, see discordjs/discord.js#7091.

When looking a bit deeper I was able to get the stack trace, where I found what triggered it:

discord.js/src/structures/Message.js:362

and also the offending code, located at:

discord-akairo/src/struct/commands/CommandUtil.js:103, inside CommandUtil#send:

if (this.shouldEdit && (this.command ? this.command.editable : true) && !hasFiles && !this.lastResponse.deleted && !this.lastResponse.attachments.size) {

The actual problem being this.lastResponse.deleted.

I have read the discord.js issue, and since it is already merged this will need to get fixed before upgrading to discord.js v14. The issue also mentions a counterpart to the deprecated function: Message#detelable, and if I look into the code they actually do the same check (of course deletable returns the opposite from deleted):

get deleted():

return deletedMessages.has(this);

get deletable():

if (deletedMessages.has(this)) {
    return false;
}

PR with required changes: #253

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions