MD
MD
DIAdiscord.js - Imagine a bot
Created by MD on 8/5/2023 in #djs-questions
Bot posts randomly 1 - 3 welcome messages for the same member that already joined.
update to 14.13 didn't change anything for me
95 replies
DIAdiscord.js - Imagine a bot
Created by Lawrence on 10/1/2023 in #djs-questions
Bot send multiple message unpredictably
rest: {
timeout: 30_000,
retries: 0,
},
rest: {
timeout: 30_000,
retries: 0,
},
but if something will go wrong, bot will not post message at all, so it should be considered only as temporary solution
8 replies
DIAdiscord.js - Imagine a bot
Created by Lawrence on 10/1/2023 in #djs-questions
Bot send multiple message unpredictably
i have exactly the same problem https://discord.com/channels/222078108977594368/1137513755840872449 We found the reason, but nobody can find proper solution. Add this listener in your code, and check if retries value is greater than 0
<Client>.rest.on(RESTEvents.Response, console.dir);
<Client>.rest.on(RESTEvents.Response, console.dir);
I kinda fixed it by setting rest retries value to 0 in client settings
8 replies
DIAdiscord.js - Imagine a bot
Created by MD on 8/5/2023 in #djs-questions
Bot posts randomly 1 - 3 welcome messages for the same member that already joined.
After i set rest timeout to 30 seconds, i still get duplicated messages, but after that 30 seconds. Correct message immediately, 2nd after 30 seconds, and 3rd after 1 minute. Kinda fixed the problem when i set rest retries value to 0. It is not posting duplicated messages anymore, but if something will go wrong, it will not post message at all Thonkang
95 replies
DIAdiscord.js - Imagine a bot
Created by MD on 8/5/2023 in #djs-questions
Bot posts randomly 1 - 3 welcome messages for the same member that already joined.
message id is a snowflake, that means is unique, and there is now way it can be the same for 2 messages
95 replies
DIAdiscord.js - Imagine a bot
Created by MD on 8/5/2023 in #djs-questions
Bot posts randomly 1 - 3 welcome messages for the same member that already joined.
i also think it is Discord issue. On my server is the same https://discord.com/channels/222078108977594368/1137513755840872449/1146872636257861683 Default discord welcome messages are duplicated for so many people, and that also correlate with my bot duplicated messages. I checked timestamps of default Discord welcome messages, and 3 messages for the same person has exactly the same timestamp. It is not possible that one person 3 times within one second joined and left my server
95 replies
DIAdiscord.js - Imagine a bot
Created by .demonslayer on 9/1/2023 in #djs-questions
Duplicate Message Send
I created similar thread here: https://discord.com/channels/222078108977594368/1137513755840872449 try to add this to your code
<Client>.rest.on(RESTEvents.Response, console.dir);
<Client>.rest.on(RESTEvents.Response, console.dir);
if you get "retries" value not equal to 0 in duplicated message, probably you have the same issue
6 replies
DIAdiscord.js - Imagine a bot
Created by MD on 8/5/2023 in #djs-questions
Bot posts randomly 1 - 3 welcome messages for the same member that already joined.
it's also not consistent for me, in old messages when i compare timestamps can be even 18 seconds difference, in messages 2 days ago is 2 seconds difference... I also added bot to my other two servers and it works there fine, not that many people joins, but bot didn't post even one duplicated message so far. I dont know if it is related in any way, but i took a suggestion from this message https://discord.com/channels/222078108977594368/1137513755840872449/1146228888180101180 I have enabled onboarding on the server where bot posts multiple messages, and disabled on servers where bot works fine (so far) 🤔
95 replies
DIAdiscord.js - Imagine a bot
Created by MD on 8/5/2023 in #djs-questions
Bot posts randomly 1 - 3 welcome messages for the same member that already joined.
I increased rest timeout to 30 seconds, and it didn't change anything. My droplet network seems to be very stable. Also i don't see any ECONNRESET error in the logs. I set up cronjob, to ping my other server on Google Cloud every 5 minutes and check time in which response came back, the highest delay was 378ms, and average around 150ms. Bot still retries to post that messages
95 replies
DIAdiscord.js - Imagine a bot
Created by MD on 8/5/2023 in #djs-questions
Bot posts randomly 1 - 3 welcome messages for the same member that already joined.
Ping to discord from the droplet
PING discord.com (162.159.136.232) 56(84) bytes of data.
64 bytes from 162.159.136.232 (162.159.136.232): icmp_seq=1 ttl=58 time=1.71 ms
64 bytes from 162.159.136.232 (162.159.136.232): icmp_seq=2 ttl=58 time=1.28 ms
64 bytes from 162.159.136.232 (162.159.136.232): icmp_seq=3 ttl=58 time=1.22 ms
64 bytes from 162.159.136.232 (162.159.136.232): icmp_seq=4 ttl=58 time=1.10 ms
64 bytes from 162.159.136.232 (162.159.136.232): icmp_seq=5 ttl=58 time=1.11 ms
64 bytes from 162.159.136.232 (162.159.136.232): icmp_seq=6 ttl=58 time=1.13 ms
64 bytes from 162.159.136.232 (162.159.136.232): icmp_seq=7 ttl=58 time=1.09 ms
64 bytes from 162.159.136.232 (162.159.136.232): icmp_seq=8 ttl=58 time=1.08 ms
64 bytes from 162.159.136.232 (162.159.136.232): icmp_seq=9 ttl=58 time=1.13 ms
64 bytes from 162.159.136.232 (162.159.136.232): icmp_seq=10 ttl=58 time=1.28 ms
64 bytes from 162.159.136.232 (162.159.136.232): icmp_seq=11 ttl=58 time=1.10 ms
64 bytes from 162.159.136.232 (162.159.136.232): icmp_seq=12 ttl=58 time=1.12 ms
64 bytes from 162.159.136.232 (162.159.136.232): icmp_seq=13 ttl=58 time=1.11 ms
64 bytes from 162.159.136.232 (162.159.136.232): icmp_seq=14 ttl=58 time=1.09 ms
64 bytes from 162.159.136.232 (162.159.136.232): icmp_seq=15 ttl=58 time=1.09 ms
^C
--- discord.com ping statistics ---
15 packets transmitted, 15 received, 0% packet loss, time 14019ms
rtt min/avg/max/mdev = 1.077/1.175/1.711/0.156 ms
PING discord.com (162.159.136.232) 56(84) bytes of data.
64 bytes from 162.159.136.232 (162.159.136.232): icmp_seq=1 ttl=58 time=1.71 ms
64 bytes from 162.159.136.232 (162.159.136.232): icmp_seq=2 ttl=58 time=1.28 ms
64 bytes from 162.159.136.232 (162.159.136.232): icmp_seq=3 ttl=58 time=1.22 ms
64 bytes from 162.159.136.232 (162.159.136.232): icmp_seq=4 ttl=58 time=1.10 ms
64 bytes from 162.159.136.232 (162.159.136.232): icmp_seq=5 ttl=58 time=1.11 ms
64 bytes from 162.159.136.232 (162.159.136.232): icmp_seq=6 ttl=58 time=1.13 ms
64 bytes from 162.159.136.232 (162.159.136.232): icmp_seq=7 ttl=58 time=1.09 ms
64 bytes from 162.159.136.232 (162.159.136.232): icmp_seq=8 ttl=58 time=1.08 ms
64 bytes from 162.159.136.232 (162.159.136.232): icmp_seq=9 ttl=58 time=1.13 ms
64 bytes from 162.159.136.232 (162.159.136.232): icmp_seq=10 ttl=58 time=1.28 ms
64 bytes from 162.159.136.232 (162.159.136.232): icmp_seq=11 ttl=58 time=1.10 ms
64 bytes from 162.159.136.232 (162.159.136.232): icmp_seq=12 ttl=58 time=1.12 ms
64 bytes from 162.159.136.232 (162.159.136.232): icmp_seq=13 ttl=58 time=1.11 ms
64 bytes from 162.159.136.232 (162.159.136.232): icmp_seq=14 ttl=58 time=1.09 ms
64 bytes from 162.159.136.232 (162.159.136.232): icmp_seq=15 ttl=58 time=1.09 ms
^C
--- discord.com ping statistics ---
15 packets transmitted, 15 received, 0% packet loss, time 14019ms
rtt min/avg/max/mdev = 1.077/1.175/1.711/0.156 ms
95 replies
DIAdiscord.js - Imagine a bot
Created by MD on 8/5/2023 in #djs-questions
Bot posts randomly 1 - 3 welcome messages for the same member that already joined.
Me too, i host all of my bots on Digital Ocean, and only one bot has this issue. Problematic bot is on another droplet, but i created recently new droplet for this bot and problem still exists. From my experience Digital Ocean has really good network speed and ping, compare to other hosting services, better has only Google Cloud
95 replies
DIAdiscord.js - Imagine a bot
Created by MD on 8/5/2023 in #djs-questions
Bot posts randomly 1 - 3 welcome messages for the same member that already joined.
I have never changed any timeouts. I remember ECONNRESET error in the logs, but since i flushed the logs around a week ago, i don't see even one ECONNRESET error.
95 replies
DIAdiscord.js - Imagine a bot
Created by MD on 8/5/2023 in #djs-questions
Bot posts randomly 1 - 3 welcome messages for the same member that already joined.
i just used this function to check latency:
const pingServer = async (client, message) => {
const { ping } = client.ws;
const sent = await message.reply({ content: 'Pinging...' });
sent.edit(`Roundtrip latency: **${sent.createdTimestamp - message.createdTimestamp}ms**\nWebSocket latency: **${ping}ms**`);
};
const pingServer = async (client, message) => {
const { ping } = client.ws;
const sent = await message.reply({ content: 'Pinging...' });
sent.edit(`Roundtrip latency: **${sent.createdTimestamp - message.createdTimestamp}ms**\nWebSocket latency: **${ping}ms**`);
};
and Roundtrip latency is 347ms and ping 101 ms
95 replies
DIAdiscord.js - Imagine a bot
Created by MD on 8/5/2023 in #djs-questions
Bot posts randomly 1 - 3 welcome messages for the same member that already joined.
[email protected] /var/www/bots/bot
├── @discordjs/[email protected]
└─┬ @discordjs/[email protected]
└── @discordjs/[email protected] deduped
[email protected] /var/www/bots/bot
├── @discordjs/[email protected]
└─┬ @discordjs/[email protected]
└── @discordjs/[email protected] deduped
node.js 18.16.1
95 replies
DIAdiscord.js - Imagine a bot
Created by MD on 8/5/2023 in #djs-questions
Bot posts randomly 1 - 3 welcome messages for the same member that already joined.
idk if we can connect it with any API outages, but bot posted this 3 messages at <t:1693247160:f>
95 replies
DIAdiscord.js - Imagine a bot
Created by MD on 8/5/2023 in #djs-questions
Bot posts randomly 1 - 3 welcome messages for the same member that already joined.
All other welcome messages has retries value 0, and ofc were not posted multiple times.
95 replies
DIAdiscord.js - Imagine a bot
Created by MD on 8/5/2023 in #djs-questions
Bot posts randomly 1 - 3 welcome messages for the same member that already joined.
That is first log that showed something. Bot posted 3 messages for that person
{
method: 'POST',
path: '/channels/613140671175589893/messages',
route: '/channels/:id/messages',
options: {
body: FormData { [Symbol(state)]: [Array] },
headers: {
'User-Agent': 'DiscordBot (https://discord.js.org, 2.0.1) discord.js/14.13.0 Node.js/18.16.1',
Authorization: 'Bot token i deleted...'
},
method: 'POST',
dispatcher: undefined
},
data: {
body: {
content: 'Hello <@1144676812035719229> Welcome to the server!',
tts: false,
nonce: undefined,
embeds: undefined,
components: [Array],
username: undefined,
avatar_url: undefined,
allowed_mentions: undefined,
flags: undefined,
message_reference: undefined,
attachments: [Array],
sticker_ids: undefined,
thread_name: undefined
},
files: [ [Object] ],
auth: true,
signal: undefined
},
retries: 2
}
{
method: 'POST',
path: '/channels/613140671175589893/messages',
route: '/channels/:id/messages',
options: {
body: FormData { [Symbol(state)]: [Array] },
headers: {
'User-Agent': 'DiscordBot (https://discord.js.org, 2.0.1) discord.js/14.13.0 Node.js/18.16.1',
Authorization: 'Bot token i deleted...'
},
method: 'POST',
dispatcher: undefined
},
data: {
body: {
content: 'Hello <@1144676812035719229> Welcome to the server!',
tts: false,
nonce: undefined,
embeds: undefined,
components: [Array],
username: undefined,
avatar_url: undefined,
allowed_mentions: undefined,
flags: undefined,
message_reference: undefined,
attachments: [Array],
sticker_ids: undefined,
thread_name: undefined
},
files: [ [Object] ],
auth: true,
signal: undefined
},
retries: 2
}
95 replies
DIAdiscord.js - Imagine a bot
Created by MD on 8/5/2023 in #djs-questions
Bot posts randomly 1 - 3 welcome messages for the same member that already joined.
Yes, i updated discord.js to v14.13, and hoped that will fix the issue, but nothing changed. I always try to keep my bots up to date and update all libraries at least once a month. Hard to tell when exactly my bot started posting duplicated messages, because i deleted some of them, At the beginning it was very very rare, i remember i noticed it, but thought, maybe that member rejoined my server. First duplicated messages i can see around March 2023, so around discord.js v14.8, but it started to be really annoying 2 - 3 months ago when bot started posting almost every message 2 - 3 times. Around 2 months ago I even reverted one of the library updates commits, but it didn't fix it either. I will add <Client>.rest.on(RESTEvents.Response, console.dir) and come back with results.
95 replies