自动清除不能很好地收集邮件

时间:2020-07-03 01:45:44

标签: javascript discord.js

您好,我正尝试对{strong>自动命令进行编程,以使用setInterval功能在 5分钟后自动清除邮件,但是提取消息的号码错误,这会导致漫游器无限循环进行自动清除。

Discord.js v12.2.0

命令 purge.js

let destination = client.channels.cache.get(config.request);
    try {
        await destination.messages.fetch({ limit: 20 }).then(async messages => {
            if (messages.size < 20) return console.log(messages.size, `No messages to delete.`); // this was to check the number received.
            await destination.bulkDelete(messages)
            await destination.send({
                embed: {
                    color: 0x35363B,
                    title: `Chat Automatically Deleted.`,
                    footer: {
                        text: `Next Delete after ${config.deleteTime / 1000 / 60} minute.`,
                    }
                }
            }).then(msg => msg.delete({ timeout: 2000 }))
        })     
    }
    catch (err) {
        console.log('Error while doing Bulk Delete');
        console.log(err);
    }
    finally {
        await destination.send({
            files: [
                `./Wallpapers/Colors.png`,
                `./Wallpapers/Commands.png`
            ],
        });
        await destination.send(`-    **Enjoy , <#7>**`);
    }

事件 message.js

let autoClear = require(`../commands/clear`);
const interval = setInterval(function () {
        autoClear.run()
    }, config.deleteTime);

0 个答案:

没有答案