From cc2545ebb2890175361830864cadd34b4be50db8 Mon Sep 17 00:00:00 2001 From: plus024 <112331452+plus024@users.noreply.github.com> Date: Wed, 31 Dec 2025 21:28:28 +1100 Subject: [PATCH] fix: use snowflake for message nonce --- src/core/commands/debug.ts | 2 +- src/core/commands/plugins.ts | 2 +- src/core/plugins/messagefix/index.ts | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/core/commands/debug.ts b/src/core/commands/debug.ts index b1975c6..6f005ed 100644 --- a/src/core/commands/debug.ts +++ b/src/core/commands/debug.ts @@ -28,7 +28,7 @@ export default () => { if (ephemeral?.value) { messageUtil.sendBotMessage(ctx.channel.id, content); } else { - const fixNonce = Date.now().toString(); + const fixNonce = (BigInt(Date.now() - 1420070400000) << 22n).toString(); messageUtil.sendMessage(ctx.channel.id, { content }, void 0, {nonce:fixNonce}); } } diff --git a/src/core/commands/plugins.ts b/src/core/commands/plugins.ts index 8933713..f6d5cfe 100644 --- a/src/core/commands/plugins.ts +++ b/src/core/commands/plugins.ts @@ -36,7 +36,7 @@ export default () => { if (ephemeral?.value) { messageUtil.sendBotMessage(ctx.channel.id, content); } else { - const fixNonce = Date.now().toString(); + const fixNonce = (BigInt(Date.now() - 1420070400000) << 22n).toString(); messageUtil.sendMessage(ctx.channel.id, { content }, void 0, {nonce:fixNonce}); } } diff --git a/src/core/plugins/messagefix/index.ts b/src/core/plugins/messagefix/index.ts index e77f0b9..bb57143 100644 --- a/src/core/plugins/messagefix/index.ts +++ b/src/core/plugins/messagefix/index.ts @@ -33,7 +33,7 @@ export default defineCorePlugin({ ) { // Ensure options exists and has a nonce options = options || {}; - options.nonce = options.nonce || Date.now().toString(); + options.nonce = options.nonce || (BigInt(Date.now() - 1420070400000) << 22n).toString(); // Call original with fixed parameters return originalSendMessage.call(