WIP: feature: threads'n'forums #74
1 changed files with 3 additions and 2 deletions
|
|
@ -84,13 +84,14 @@ async function handleForums(event) {
|
|||
if (event.content.body === "/thread") return false; //Let the help be shown normally
|
||||
|
||||
const row = from("channel_room").where({room_id: event.room_id}).select("channel_id").get()
|
||||
/** @type {string}*/ //@ts-ignore the possibility that it's undefined: get() will return back an undefined if it's fed one (so that's undefined-safe), and createThreadWithoutMessage() won't be reached because "undefined" is neither DiscordTypes.ChannelType.GuildMedia nor DiscordTypes.ChannelType.GuildForum, so the guard clause kicks in.
|
||||
/** @type {string}*/ //@ts-ignore the possibility that it's undefined - get() will return back an undefined if it's fed one (so that's undefined-safe), and createThreadWithoutMessage() won't be reached because "undefined" is neither DiscordTypes.ChannelType.GuildMedia nor DiscordTypes.ChannelType.GuildForum, so the guard clause kicks in.
|
||||
let channelID = row?.channel_id
|
||||
const type = discord.channels.get(channelID)?.type
|
||||
if (type != DiscordTypes.ChannelType.GuildForum && type != DiscordTypes.ChannelType.GuildMedia) return false
|
||||
|
||||
const name = computeName(event)
|
||||
await discord.snow.channel.createThreadWithoutMessage(channelID, {name: name.name, type:11})
|
||||
//@ts-ignore the presence of message:{} and the absence of type:11 - that's intended for threads in Forum channels (*and no, createThreadWithMessage wouldn't work here, either - that one takes an ALREADY EXISTING message ID, whereas this needs a new message)
|
||||
await discord.snow.channel.createThreadWithoutMessage(channelID, {name: name.name, message:{content:"heyy~"}})
|
||||
if (!name.truncated) api.redactEvent(event.room_id, event.event_id) //Don't destroy people's texts - only remove if no truncation is guaranteed.
|
||||
return true
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue