Closed ghost closed 1 year ago
so its related to https://github.com/discordjs/discord.js/blob/7dec892218f7b470a5f8e78732a524a53da24d26/packages/discord.js/src/structures/DMChannel.js#L33 which is undefined
We are unable to reproduce this issue.
If you can still reproduce this, it would be interesting if you could add console.log(data);
on line 31 here and report back your payload:
Also, are you using a modified version of discord.js? Can you provide a code sample you are using to reproduce this (to ensure no mutations are happening)?
Will do. and I didn't modify any part of DJS.
We are unable to reproduce this issue.
If you can still reproduce this, it would be interesting if you could add
console.log(data);
on line 31 here and report back your payload:Also, are you using a modified version of discord.js? Can you provide a code sample you are using to reproduce this (to ensure no mutations are happening)?
{
id: 'redacted',
guild_id: undefined,
recipients: [
{
avatar: 'redacted',
avatar_decoration: null,
bot: true,
discriminator: '6738',
id: 'redacted',
public_flags: 65536,
username: 'redacted'
}
]
}
And I think I figured out the reason. This issue only happens when the sender is bot itself. (Bot to User)
So reproducible code would be a code that send DM to a user.
Just a question, how consistently can you reproduce this? I cannot seem to reproduce this when a bot initiates a direct message or when it receives a direct message, both in the scenario of initiating a direct message for the first time and using an existing direct message channel.
Just a question, how consistently can you reproduce this? I cannot seem to reproduce this when a bot initiates a DM or when it receives a DM, both in the scenario of initiating a DM for the first time and using an existing DM.
I'm afraid that I can't give exact answer, but my bot sends DM to the server owner when they add it. So I think it's 'whenever a user adds the bot to their server'
Can you not provide a code sample? It should be easy if you're able to reproduce that frequently?
Can you not provide a code sample? It should be easy if you're able to reproduce that frequently?
const { Client, Partials, GatewayIntentBits } = require('discord.js');
const client = new Client({
partials: [Partials.Channel],
intents: [GatewayIntentBits.Guild],
});
client.on('guildCreate', async (guild) => {
const owner = await guild.fetchOwner();
await owner.send('thx for adding my bot').catch(() => null);
});
client.login('token');
Do you use sharding?
Do you use sharding?
Yes, I'm using it.
We managed to get a reproduction.
Turns out this is a minimal reproducible sample:
// Need DIRECT_MESSAGES intent
// Need Channel partial
const channel = await client.users.createDM("id", { cache: false });
await channel.send("Hello!");
This kind of mimics the behaviour with sharding:
MESSAGE_CREATE
payload on shard 0 (direct messages are sent to shard 0 always). This means the channel is uncachedrecipient
:We managed to get a reproduction.
Turns out this is a minimal reproducible sample:
// Need DIRECT_MESSAGES intent // Need Channel partial const channel = await client.users.createDM("id", { cache: false }); await channel.send("Hello!");
This kind of mimics the behaviour with sharding:
- A direct message is received on a shard that is not shard 0
- We receive a
MESSAGE_CREATE
payload on shard 0 (direct messages are sent to shard 0 always). This means the channel is uncached- We grab the bot's message and use the bot as the
recipient
:
Nice, Thanks for your hard work <3
Which package is this bug report for?
discord.js
Issue description
Code sample
No response
Package version
14.7.2-dev.1672747445-7dec892.0
Node.js version
18.12.1
Operating system
No response
Priority this issue should have
Medium (should be fixed soon)
Which partials do you have configured?
Channel
Which gateway intents are you subscribing to?
Guilds, GuildMembers, GuildPresences, GuildMessages, DirectMessages, MessageContent
I have tested this issue on a development release
7dec892