Skip to content

Webhooks cannot add users to private threads via ping #7786

@puppy0cam

Description

@puppy0cam

Description

In public threads, webhooks are able to add users as members of the thread by way of pinging that user in a message.
However, in private threads, pinging a user via a webhook does not add them as a member of the thread.

I discussed the problem in the discord developer server, and others were able to reproduce the problem. Conversation link: https://discord.com/channels/613425648685547541/1130595287078015027/1410133456578547712

Steps to Reproduce

import { ChannelType, Client } from "discord.js";

const GUILD_ID = "";
// channel of type text (ID 0 in channel type enum)
const TEXT_CHANNEL_ID = "";
const BOT_TOKEN = "";
const YOUR_USER_ID = "";

console.log("This test case assumes the bot is both a member of the configured server, and has administrator permissions.");

const client = new Client({
  intents: ["Guilds", "GuildMessages", "GuildIntegrations", "GuildWebhooks"],
});

await client.login(BOT_TOKEN);
const guild = await client.guilds.fetch(GUILD_ID);
const channel = await guild.channels.fetch(TEXT_CHANNEL_ID);
if (channel?.type !== ChannelType.GuildText) {
  // typescript moment
  throw new Error("That's not a text channel silly :)");
}
const publicThread = await channel.threads.create({
  type: ChannelType.PublicThread,
  name: "Public thread",
});
const privateThread = await channel.threads.create({
  type: ChannelType.PrivateThread,
  name: "Private thread",
});
const webhook = await channel.createWebhook({
  name: "test",
});
await webhook.send({
  threadId: publicThread.id,
  content: `<@${YOUR_USER_ID}> You should have been added to this ***public*** thread which is expected behaviour. This case seems to be working correctly. Check the member list in <#${privateThread.id}> to see if you are in it.`,
});
await webhook.send({
  threadId: privateThread.id,
  content: `<@${YOUR_USER_ID}> You should have been added to this ***private*** thread which is expected behaviour. This case ***does not*** seem to be working correctly. Check the member list for this thread. If you aren't in it, then there's something wrong.`,
});
await channel.send({
  content: `Test case set up. Check the threads:\n- Public: <#${publicThread.id}>\n- Private: <#${privateThread.id}>`,
});
await client.destroy();

Expected Behavior

Users are added to the private thread and the public thread by the webhook

Current Behavior

Users are only added to the public thread by the webhook, not the private thread

Screenshots/Videos

Image Image

Client and System Information

stable 437114 (e17ce18) Host 1.0.9204 x64 (67946) Build Override: N/A Windows 10 64-bit (10.0.19045)

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugsyncedSynced to internal tracker

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions