我如何将我的功能变成承诺,以便可以在其中使用await?

编程入门 行业动态 更新时间:2024-10-09 16:26:38

我<a href=https://www.elefans.com/category/jswz/34/1771359.html style=如何将我的功能变成承诺,以便可以在其中使用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?

本文发布于:2024-05-07 20:55:43,感谢您对本站的认可!
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:如何将   功能   await

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!