more convenient test code
This commit is contained in:
@@ -24,23 +24,31 @@ if (category?.type !== ChannelType.GuildCategory) {
|
|||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
for (const [, channel] of category.children.cache) {
|
let index = 0
|
||||||
await channel.delete()
|
|
||||||
}
|
|
||||||
|
|
||||||
let prefix = 0
|
|
||||||
const createTest = async (
|
const createTest = async (
|
||||||
name: string,
|
name: string,
|
||||||
description: string,
|
description: string,
|
||||||
block: (channel: TextChannel) => void | Promise<unknown>,
|
block: (channel: TextChannel) => void | Promise<unknown>,
|
||||||
) => {
|
) => {
|
||||||
prefix += 1
|
const channelName = `${String(index).padStart(3, "0")}-${kebabCase(name)}`
|
||||||
const channel = await category.children.create({
|
|
||||||
type: ChannelType.GuildText,
|
let channel = category.children.cache.find((ch) => ch.name === channelName)
|
||||||
name: `${String(prefix).padStart(3, "0")}-${kebabCase(name)}`,
|
if (channel instanceof TextChannel) {
|
||||||
})
|
for (const [, msg] of await channel.messages.fetch()) {
|
||||||
await channel.edit({ topic: description })
|
await msg.delete()
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
await channel?.delete()
|
||||||
|
channel = await category.children.create({
|
||||||
|
type: ChannelType.GuildText,
|
||||||
|
name: channelName,
|
||||||
|
topic: description,
|
||||||
|
position: index,
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
await block(channel)
|
await block(channel)
|
||||||
|
index += 1
|
||||||
}
|
}
|
||||||
|
|
||||||
await createTest(
|
await createTest(
|
||||||
|
|||||||
Reference in New Issue
Block a user