mirror of
https://github.com/ZeppelinBot/Zeppelin.git
synced 2025-06-08 00:05:01 +00:00
50 lines
1 KiB
TypeScript
50 lines
1 KiB
TypeScript
import { CategoryChannel, Channel } from "discord.js";
|
|
import { isDmChannel } from "./isDmChannel.js";
|
|
import { isGuildChannel } from "./isGuildChannel.js";
|
|
import { isThreadChannel } from "./isThreadChannel.js";
|
|
|
|
type ResolvedChannelIds = {
|
|
category: string | null;
|
|
channel: string | null;
|
|
thread: string | null;
|
|
};
|
|
|
|
export function resolveChannelIds(channel: Channel): ResolvedChannelIds {
|
|
if (isDmChannel(channel)) {
|
|
return {
|
|
category: null,
|
|
channel: channel.id,
|
|
thread: null,
|
|
};
|
|
}
|
|
|
|
if (isThreadChannel(channel)) {
|
|
return {
|
|
category: channel.parent?.parentId || null,
|
|
channel: channel.parentId,
|
|
thread: channel.id,
|
|
};
|
|
}
|
|
|
|
if (channel instanceof CategoryChannel) {
|
|
return {
|
|
category: channel.id,
|
|
channel: null,
|
|
thread: null,
|
|
};
|
|
}
|
|
|
|
if (isGuildChannel(channel)) {
|
|
return {
|
|
category: channel.parentId,
|
|
channel: channel.id,
|
|
thread: null,
|
|
};
|
|
}
|
|
|
|
return {
|
|
category: null,
|
|
channel: channel.id,
|
|
thread: null,
|
|
};
|
|
}
|