【JS】询问一下有无1.2新增的seal.createTempCtx(endpoint, msg)方法使用实例 #169
-
目的:想做一个群内某个人变量排行榜(例:好感排行)
此举在指令调用时,通过打桩测试了解到返回错误的语句正是标题提到的方法 |
Beta Was this translation helpful? Give feedback.
Answered by
Szzrain
Feb 28, 2024
Replies: 1 comment 1 reply
-
createTempCtx 可以主动创建 ctx 对象用于发送消息或者其他需要 ctx 对象的场景,以下代码是我在 function getCtxAndMsgById(epId, groupId, guildId, senderId, isPrivate) {
let eps = seal.getEndPoints();
for (let i = 0; i < eps.length; i++) {
if (eps[i].userId === epId) {
let msg = seal.newMessage();
if (isPrivate === true) {
msg.messageType = "private";
} else {
msg.messageType = "group";
msg.groupId = groupId;
}
msg.guildId = guildId;
msg.sender.userId = senderId;
return [seal.createTempCtx(eps[i], msg), msg];
}
}
return undefined;
} |
Beta Was this translation helpful? Give feedback.
1 reply
Answer selected by
Szzrain
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
createTempCtx 可以主动创建 ctx 对象用于发送消息或者其他需要 ctx 对象的场景,以下代码是我在
gamechat.js
中的一个用于创建 ctx 和 msg 的函数