Skip to content

Commit

Permalink
fix max channels per archive
Browse files Browse the repository at this point in the history
  • Loading branch information
BodomBeach committed May 16, 2024
1 parent abcaad2 commit 9a9fdb2
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/utils/archive.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,15 @@ export const allowedCategories = ['🪂 SORTIES', '🏃Sorties pas rapente', '

export async function archive(channel) {
const archiveCategories = channel.guild.channels.cache.filter(channel => channel.type === 4 && channel.name.slice(0,11).toLowerCase() === '📁archives_');
let available_archive = archiveCategories.find(cat => cat.children.cache.size < 3)
let available_archive = archiveCategories.find(cat => cat.children.cache.size < 50)

if (available_archive) {
channel.setParent(available_archive)
} else {
// creating a new archive category
const count = Math.max(...archiveCategories.map(cat => parseInt(cat.name.split('_')[1])))
available_archive = await channel.guild.channels.create({
name: `📁archives_${count + 1}`,
name: `📁ARCHIVES_${count + 1}`,
type: 4,
})
console.log('Created new archive category');
Expand Down

0 comments on commit 9a9fdb2

Please sign in to comment.