MCPcopy Create free account
hub / github.com/Botloader/botloader / testPrivateStandaloneThread

Function testPrivateStandaloneThread

integration-tests/threads.ts:47–92  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

45}
46
47async function testPrivateStandaloneThread() {
48 let channel = await Discord.createStandaloneThread({
49 // invitable: true,
50 channelId: threadsTestChannelId,
51 kind: "PrivateThread",
52 name: "int-test-private-thread",
53 autoArchiveDurationMinutes: 10080,
54 })
55
56 assertExpected("PrivateThread", channel.kind)
57 assertExpected(10080, channel.threadMetadata.autoArchiveDurationMinutes)
58 assertExpected("int-test-private-thread", channel.name)
59
60 // test guild list
61 const activeThreads = await Discord.getActiveThreads()
62 const foundThead = activeThreads.threads.find(v => v.id === channel.id)
63 assertExpected(true, Boolean(foundThead))
64
65 // test adding / removing members
66 await Discord.addThreadMember(channel.id, testMemberId)
67
68 let members = await Discord.getThreadMembers({
69 channelId: channel.id,
70 })
71 const foundMember = members.find(v => v.id === channel.id && v.userId === testMemberId)
72 assertExpected(true, Boolean(foundMember))
73
74 // try removing
75 await Discord.removeThreadMember(channel.id, testMemberId)
76
77 const activeThreadsPost = await Discord.getActiveThreads()
78 const foundMemberPost = activeThreadsPost.members.find(v => v.id === channel.id && v.userId === testMemberId)
79 assertExpected(false, Boolean(foundMemberPost))
80
81 // test archiving
82 channel = await channel.archive()
83 assertExpected(true, channel.threadMetadata.archived)
84
85 // test list archived threads
86 const archivedThreads = await Discord.getPrivateArchivedThreads({
87 channelId: threadsTestChannelId,
88 })
89
90 const archivedThread = archivedThreads.threads.some(v => v.id === channel.id)
91 assertExpected(true, archivedThread)
92}
93
94async function testMessageThread() {
95 const msg = await Discord.createMessage(threadsTestChannelId, { content: "thread should be created on this message" })

Callers 1

threads.tsFile · 0.85

Calls 2

assertExpectedFunction · 0.90

Tested by

no test coverage detected