久久久久久久av_日韩在线中文_看一级毛片视频_日本精品二区_成人深夜福利视频_武道仙尊动漫在线观看

批量刪除如何工作?

How does bulkDelete work?(批量刪除如何工作?)
本文介紹了批量刪除如何工作?的處理方法,對大家解決問題具有一定的參考價值,需要的朋友們下面隨著小編來一起學(xué)習(xí)吧!

問題描述

我嘗試使用 bulkDelete 讓我的機(jī)器人刪除它的消息,但我收到此錯誤:

I tried using bulkDelete to make my bot delete its message but I get this error:

(node:5724) UnhandledPromiseRejectionWarning: Unhandled promise rejection (rejection id: 1): Error: Bad Request
(node:5724) DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.

這是我的代碼:

const Discord = require('discord.js');
const bot = new Discord.Client();
const config = require("./config.json");

bot.on('ready', () =>{
    console.log('I am ready!');
});

//var cleanarr=[];

bot.on("message", message =>{
    if (message.author.bot) return;
var cleanarr=[];
        let command = message.content.split(" ")[0];
command = command.slice(config.prefix.length);

        let args = message.content.split(" ").slice(1);
if (message.content == 'lol'){
    message.channel.sendMessage('LUL');
    cleanarr.unshift(`${message.channel.lastMessageID}`);
    }
if (command == "clean") {
    message.channel.sendMessage('Cleaning...');
    message.channel.bulkDelete(cleanarr);
    var cleanarr = [];

bulkDelete 需要什么?是消息ID還是其他什么?

What does the bulkDelete need? Is it the message id or something else?

我不知道我這樣做是否正確(顯然我不是),因為我開始編碼時對 javascript 或任何相關(guān)知識的了解為零.

I have no idea if I doing this right (obviously I am not) since I started coding with zero knowledge of javascript or anything related.

推薦答案

從頻道中刪除 x 消息的最簡單方法是提供 2 - 100 的整數(shù)作為 <TextChannel>.bulkDelete 的參數(shù) 方法.

The easiest way to delete x messages from a channel is to provide an integer from 2 - 100 as parameters to the <TextChannel>.bulkDelete method.

例子:

message.channel.bulkDelete(100).then(() => {
  message.channel.send("Deleted 100 messages.").then(msg => msg.delete(3000));
});

這篇關(guān)于批量刪除如何工作?的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網(wǎng)!

【網(wǎng)站聲明】本站部分內(nèi)容來源于互聯(lián)網(wǎng),旨在幫助大家更快的解決問題,如果有圖片或者內(nèi)容侵犯了您的權(quán)益,請聯(lián)系我們刪除處理,感謝您的支持!

相關(guān)文檔推薦

discord.js v12: How do I await for messages in a DM channel?(discord.js v12:我如何等待 DM 頻道中的消息?)
how to make my bot mention the person who gave that bot command(如何讓我的機(jī)器人提及發(fā)出該機(jī)器人命令的人)
How to fix Must use import to load ES Module discord.js(如何修復(fù)必須使用導(dǎo)入來加載 ES 模塊 discord.js)
How to list all members from a specific server?(如何列出來自特定服務(wù)器的所有成員?)
Discord bot: Fix ‘FFMPEG not found’(Discord bot:修復(fù)“找不到 FFMPEG)
Welcome message when joining discord Server using discord.js(使用 discord.js 加入 discord 服務(wù)器時的歡迎消息)
主站蜘蛛池模板: 亚洲欧美激情精品一区二区 | 最近中文字幕在线视频1 | 精品视频一区二区三区在线观看 | 亚洲成人中文字幕 | 一区二区三区精品视频 | 黑人成人网 | 日韩一区二区三区精品 | 色黄爽| 羞羞的视频在线 | 一区在线播放 | 国产日韩欧美中文 | 亚洲免费影院 | 成人影院一区二区三区 | 在线视频91 | 欧美日韩在线免费 | 91日b| 亚洲精品一区二区三区蜜桃久 | 精品一区在线 | 久久精品国产精品青草 | 成人网在线观看 | 亚洲综合无码一区二区 | 黄网站色大毛片 | 91电影 | 91精品在线看 | 欧美男人天堂 | 在线观看亚洲 | 亚洲在线| 99亚洲国产精品 | 中国大陆高清aⅴ毛片 | 九九国产在线观看 | 亚洲一区二区在线免费观看 | 女女爱爱视频 | 国产午夜精品一区二区三区四区 | 国产精品一区二区电影 | a久久久久久 | 欧美一级在线观看 | www.日韩| 另类a v| 人人爽日日躁夜夜躁尤物 | 亚洲日韩中文字幕一区 | 亚洲啊v在线|