izy521 / discord.io

A small, single-file library for creating DiscordApp clients from Node.js or the browser
https://discord.gg/0MvHMfHcTKVVmIGP
MIT License
535 stars 155 forks source link

Purge Messages #312

Open LexusSpeed03 opened 5 years ago

LexusSpeed03 commented 5 years ago

Is it possible with discord io to purge like 10-20 messages? I am trying to clear a channel before it sends messages but the documentation is very scarce on this.

cloudrac3r commented 5 years ago

.deleteMessages({channelID: "123", messageIDs: ["456", "789"]})

It's in the docs.

LexusSpeed03 commented 5 years ago

.deleteMessages({channelID: "123", messageIDs: ["456", "789"]})

It's in the docs.

By chance have a link maybe I am looking at the wrong thing? I am trying to have a command where it deletes last like 100 messages in a channel.

SagnikPradhan commented 5 years ago

@LexusSpeed03

Discord.io doesn't have a builtin option to delete the last 100 messages.

What you can instead do is use bot.getMessages() and get last 100 messages. Then make an array of their ids and then use bot.deleteMessages() to delete all of them.

Reference:

  1. bot.getMessages()
  2. bot.deleteMessages()