discord.io icon indicating copy to clipboard operation
discord.io copied to clipboard

Can't delete messages...

Open ActuallyVines opened this issue 7 years ago • 3 comments

I couldn't find any link to join the Discord server, and the documentation ain't helping me here. I tried everything i could but i keep getting errors while trying to make my bot delete messages.

So this is what i am using:

` if (message.startsWith(".clean")) {

    let number = parseInt(message.split(' ')[1])
    bot.getMessages({ "channelID": channelID, "before": message.id, "limit": number })

    bot.sendMessage({
        to: channelID,
        message: number
    });
}`

Everything works afaik. The bot gets the number (And sends a message of it to confirm), then SUPPOSEDLY gets all messages before the command, and the limit is the number i said. What i can't do is to actually delete the messages. I tried bot.getMessages({ "channelID": channelID, "before": message.id, "limit": number } .forEach(r => bot.deleteMessages({ channelID: channelID, messageIDs: r }))) But it doesn't work, and neither does bot.deleteMessages({"channelID": channelID , "messageIDs": ???? }); Bcs well... I just don't know the IDs...

ActuallyVines avatar Dec 29 '17 05:12 ActuallyVines

Yeah because getMessages will give you an array of message objects and not IDs. You can't just pass message objects to messageIDs, because as the name suggests, it takes an array of IDs.

LunaSquee avatar Dec 30 '17 17:12 LunaSquee

So what am i supposed to do then. Btw is the server still up?

ActuallyVines avatar Dec 31 '17 07:12 ActuallyVines

Invite Here: https://discord.gg/0MvHMfHcTKVVmIGP ask in discord.io channel

Also by the looks of your code, you're calling forEach on the object your handing in Foreach also runs on each element so your calling deleteMessages on a single element

CheweyZ avatar Jan 04 '18 01:01 CheweyZ