@friendlyrobot/discord-pi-agent 0.9.2 → 0.9.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.js +10 -21
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -975,27 +975,16 @@ var typingIntervals = new Map;
|
|
|
975
975
|
async function sendTypingSafe(channel, channelKey) {
|
|
976
976
|
logger5.info({ channelKey }, "[TYPING] calling sendTyping()");
|
|
977
977
|
try {
|
|
978
|
-
const
|
|
979
|
-
|
|
980
|
-
|
|
981
|
-
|
|
982
|
-
|
|
983
|
-
|
|
984
|
-
|
|
985
|
-
|
|
986
|
-
|
|
987
|
-
|
|
988
|
-
const result = await Promise.race([
|
|
989
|
-
channel.sendTyping().then(() => "ok"),
|
|
990
|
-
rawFetchPromise,
|
|
991
|
-
new Promise((resolve) => setTimeout(() => resolve("timeout"), 5000))
|
|
992
|
-
]);
|
|
993
|
-
if (result === "timeout") {
|
|
994
|
-
logger5.warn({ channelKey }, "[TYPING] BOTH calls TIMEOUT after 5s");
|
|
995
|
-
} else if (result === "raw-ok") {
|
|
996
|
-
logger5.info({ channelKey }, "[TYPING] raw fetch OK, discord.js STUCK");
|
|
997
|
-
} else {
|
|
998
|
-
logger5.info({ channelKey }, "[TYPING] sendTyping() OK");
|
|
978
|
+
const token = channel.client.token;
|
|
979
|
+
const url = `https://discord.com/api/v10/channels/${channel.id}/typing`;
|
|
980
|
+
const res = await fetch(url, {
|
|
981
|
+
method: "POST",
|
|
982
|
+
headers: { Authorization: `Bot ${token}` }
|
|
983
|
+
});
|
|
984
|
+
const body = await res.text();
|
|
985
|
+
logger5.info({ channelKey, status: res.status, headers: Object.fromEntries(res.headers.entries()), body }, "[TYPING] raw fetch response");
|
|
986
|
+
if (res.ok) {
|
|
987
|
+
logger5.info({ channelKey }, "[TYPING] raw fetch OK — Discord accepted typing");
|
|
999
988
|
}
|
|
1000
989
|
} catch (error) {
|
|
1001
990
|
logger5.warn({ channelKey, error }, "[TYPING] sendTyping() FAILED");
|