我目前正在學習Node.js/JavaScript,以便使用Discordie庫編寫Discord bot。鏈接承諾執行兩個操作
我有兩個單獨的操作,一個創建一個邀請到服務器,另一個踢用戶併發送消息,如果他們在其中一條消息中使用了連線。
e.message.author.openDM().then(dm => dm.sendMessage(`You have been kicked from the **${e.message.guild.name}** server for using a slur. Please consider this a probation. When you feel that you are ready to not use that sort of language, feel free to rejoin us.`));
e.message.author.memberOf(e.message.guild).kick();
是我用來引導用戶的消息,然後踢他們的方法。我有生成邀請,並從所接收的JSON拉動邀請碼單獨的命令(!invite
):
var generateInvite = e.message.channel.createInvite({"temporary": false, "xkcdpass": false});
generateInvite.then(function(res) { e.message.channel.sendMessage("https://discord.gg/" +res.code); });
我想能夠生成以發送一個直接消息碼的內部的邀請踢用戶邀請回來,如果他們能夠避免再次使用那種語言,但我想不出如何正確連鎖我公司承諾:
generateInvite.then(function(res) { return res.code }).then(e.message.author.openDM().then(function(dm){ dm.sendMessage(`You have been kicked from the **${e.message.guild.name}** server for using a slur. Please consider this a probation. When you feel that you are ready to not use that sort of language, feel free to rejoin us by following this link: https://discord.gg/` + res.code)}));
我在哪裏有這個諾言鏈回事?
_「我在哪裏出錯了這個承諾鏈?」_不應該包括'('at'.openMD()'來引用函數'openDM',而不是立即調用函數,或者在'e .message.author.openDM()'應該從一個匿名函數返回;目前看起來是一個語法錯誤? – guest271314
請縮進你的代碼,這很難在一行上讀取 – Tdy