My issue is that I receive an error when trying to delete a message in Discord.
client.on('message', msg => {
if(msg.content.startsWith(".del ")) {
msg.delete(1000); //Supposed to delete message
}
});
I receive this error:
C:\Users\---\Desktop\Test\node_modules\discord.js\src\structures\Message.js:501
if (typeof options !== 'object') throw new TypeError('INVALID_TYPE', 'options', 'object', true);
^
TypeError [INVALID_TYPE]: Supplied options is not an object.
at Message.delete (C:\Users\---\Desktop\Test\node_modules\discord.js\src\structures\Message.js:501:44)
at Client.<anonymous> (C:\Users\---\Desktop\Test\index.js:51:17)
at Client.emit (events.js:310:20)
at MessageCreateAction.handle (C:\Users\---\Desktop\Test\node_modules\discord.js\src\client\actions\MessageCreate.js:31:14)
at Object.module.exports [as MESSAGE_CREATE] (C:\Users\---\Desktop\Test\node_modules\discord.js\src\client\websocket\handlers\MESSAGE_CREATE.js:4:32)
at WebSocketManager.handlePacket (C:\Users\---\Desktop\Test\node_modules\discord.js\src\client\websocket\WebSocketManager.js:386:31)
at WebSocketShard.onPacket (C:\Users\---\Desktop\Test\node_modules\discord.js\src\client\websocket\WebSocketShard.js:436:22)
at WebSocketShard.onMessage (C:\Users\---\Desktop\Test\node_modules\discord.js\src\client\websocket\WebSocketShard.js:293:10)
at WebSocket.onMessage (C:\Users\---\Desktop\Test\node_modules\ws\lib\event-target.js:120:16)
at WebSocket.emit (events.js:310:20) {
[Symbol(code)]: 'INVALID_TYPE'
}
I have also tried message.delete(1000)
, but I receive an error telling me that message is undefined.
The program works when I remove the code attempting to delete the message.