簡體   English   中英

執行discord.js后刪除命令

[英]Delete Command After Execute discord.js

在執行此代碼后,如何使我的命令從聊天中刪除:

    const Discord = require("discord.js");

module.exports.run = async (client, message, args) => {
    if (message.author.id != process.env.OWNERID)
        return message.channel.send("Only my developer can use this command...");
    const msg = args.slice(0).join(" ");
    if (!msg) return message.reply("Send something!");
    message.channel.send(msg);
};

module.exports.help = {
    name: "send-message",
    description: "N/A",
    usage: "d!send-message [Message]",
    accessableby: "Bot Owners",
    aliases: []
};

就像我要做“d!send-message discord.js help

執行后如何讓機器人從 discord 聊天中刪除“d?send-message discord.js help”?

您可以使用.delete() function

這是給你的一個例子:

const Discord = require("discord.js");

module.exports.run = async (client, message, args) => {
    if (message.author.id != process.env.OWNERID)
        return message.channel.send("Only my developer can use this command...");
    const msg = args.slice(0).join(" ");
    if (!msg) return message.reply("Send something!");
    message.channel.send(msg);
    message.delete()  // ** NEW LINE
};

module.exports.help = {
    name: "send-message",
    description: "N/A",
    usage: "d!send-message [Message]",
    accessableby: "Bot Owners",
    aliases: []
};

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM