每当我使用
message.channel.send(lvlEmbed).then(msg => {msg.delete(1000)});
它不起作用。它只有在我没有时间的情况下才有效。我不确定发生了什么。它曾经工作过一次,却从未奏效!怎么了?
代码:
const Discord = require("discord.js");
let xp = require("../xp.json");
const ms = require("ms");
module.exports.run = async (bot, message, args) => {
if (!xp[message.author.id]) {
xp[message.author.id] = {
xp: 0,
level: 1
};
}
let curxp = xp[message.author.id].xp;
let curlvl = xp[message.author.id].level;
let nxtLvlXp = curlvl * 300;
let difference = nxtLvlXp - curxp;
let lvlEmbed = new Discord.RichEmbed()
.setAuthor(message.author.username)
.setColor("#e000f4")
.addField("Level", curlvl, true)
.addField("XP", curxp, true)
.setFooter(`${difference} XP til level up`, message.author.displayAvatarURL);
message.channel.send(lvlEmbed).then(msg => { msg.delete(5000) });
}
module.exports.help = {
name: "level"
}
答案 0 :(得分:0)
由于您说的是如果您不输入任何时间到删除功能都可以,那么暂时可以使用setTimeout来完成工作。
let p = function(msg){
msg.delete();
}
message.channel.send(lvlEmbed).then(msg => { setTimeout(p,5000,msg); });