如何将我的功能变成承诺,以便可以在其中使用await?"/>
我如何将我的功能变成承诺,以便可以在其中使用await?
我具有一个提示用户的功能,但是我需要做出一个承诺,以便在继续执行命令之前可以'等待'其完成。
这是Prompt.js
文件中的功能
const Discord = require('discord.js')
const ms = require('ms')
module.exports = async function Prompt(originalMessage, textOrEmbed, {embedColor = 'GREEN', yesNo = false, channel = originalMessage.channel, filterArray = [], time = '5m'} = {}) {
if (typeof originalMessage !== "object")
throw new Error(`The provided message was not a message object.`)
if (typeof textOrEmbed === "object") {
textOrEmbed = textOrEmbed;
} else if (typeof textOrEmbed === "string") {
let embed = new Discord.MessageEmbed()
.setTitle(`Plus Prompt`)
.setDescription(textOrEmbed)
.setImage('/i/plusEmbedBackground.gif')
.setColor(embedColor)
.setFooter(`Interactive message prompt: Lasts ${time}
更多推荐
我如何将我的功能变成承诺,以便可以在其中使用await?
发布评论