| const { PermissionFlagsBits, ChannelType } = require('discord.js'); |
| const { stmts } = require('../database'); |
| const { successEmbed, errorEmbed } = require('../utils/embeds'); |
| const { Colors, Roles } = require('../config'); |
|
|
| module.exports = { |
| async execute(client, message) { |
| const guild = await client.guilds.fetch(process.env.GUILD_ID); |
| await guild.roles.fetch(); |
| await guild.channels.fetch(); |
|
|
| const log = []; |
|
|
| |
| const newRoles = ['@@ Server Manager', '@@ Moderator']; |
| for (const roleName of newRoles) { |
| const existing = guild.roles.cache.find(r => r.name === roleName); |
| if (existing) { |
| log.push(`βοΈ Role **${roleName}** already exists`); |
| continue; |
| } |
| const def = Roles.find(r => r.name === roleName); |
| if (!def) continue; |
|
|
| |
| const staffRole = guild.roles.cache.find(r => r.name === '@@ Staff'); |
| const pos = staffRole ? staffRole.position + 1 : 1; |
|
|
| await guild.roles.create({ |
| name: def.name, |
| color: def.color, |
| permissions: def.permissions, |
| hoist: def.hoist, |
| mentionable: def.mentionable, |
| position: pos, |
| }); |
| log.push(`β
Created role **${roleName}**`); |
| } |
|
|
| |
| const staffCategory = guild.channels.cache.find( |
| c => c.type === ChannelType.GuildCategory && c.name.includes('STAFF ONLY') |
| ); |
| const ownerChatExists = guild.channels.cache.find(c => c.name === 'πγ»owner-chat'); |
|
|
| if (ownerChatExists) { |
| log.push(`βοΈ Channel **πγ»owner-chat** already exists`); |
| } else if (!staffCategory) { |
| log.push(`β οΈ STAFF ONLY category not found β skipped owner-chat`); |
| } else { |
| |
| const everyoneRole = guild.roles.everyone; |
| const ownerRole = guild.roles.cache.find(r => r.name === '@@ Owner'); |
| const coOwnerRole = guild.roles.cache.find(r => r.name === '@@ Co-Owner'); |
| const svrMgrRole = guild.roles.cache.find(r => r.name === '@@ Server Manager'); |
|
|
| const overwrites = [ |
| { id: everyoneRole.id, deny: [PermissionFlagsBits.ViewChannel] }, |
| ]; |
| if (ownerRole) overwrites.push({ id: ownerRole.id, allow: [PermissionFlagsBits.ViewChannel, PermissionFlagsBits.SendMessages] }); |
| if (coOwnerRole) overwrites.push({ id: coOwnerRole.id, allow: [PermissionFlagsBits.ViewChannel, PermissionFlagsBits.SendMessages] }); |
| if (svrMgrRole) overwrites.push({ id: svrMgrRole.id, allow: [PermissionFlagsBits.ViewChannel, PermissionFlagsBits.SendMessages] }); |
|
|
| |
| const staffChat = guild.channels.cache.find(c => c.name === 'π‘οΈγ»staff-chat'); |
|
|
| const ownerChat = await guild.channels.create({ |
| name: 'πγ»owner-chat', |
| type: ChannelType.GuildText, |
| parent: staffCategory.id, |
| permissionOverwrites: overwrites, |
| }); |
|
|
| |
| if (staffChat) { |
| await ownerChat.setPosition(staffChat.position); |
| } |
|
|
| stmts.setState.run('channel_πγ»owner-chat', ownerChat.id); |
| log.push(`β
Created **πγ»owner-chat** (above staff-chat)`); |
| } |
|
|
| |
| const resourceChannels = ['πγ»resources', 'πγ»free-assets', 'πγ»scripts', 'πγ»drivers']; |
| const everyoneRole = guild.roles.everyone; |
| const ownerRole = guild.roles.cache.find(r => r.name === '@@ Owner'); |
| const verifiedRole = guild.roles.cache.find(r => r.name === '@@ Verified'); |
| const staffRole = guild.roles.cache.find(r => r.name === '@@ Staff'); |
| const boosterRole = guild.roles.cache.find(r => r.name === '@@ Booster'); |
|
|
| for (const chName of resourceChannels) { |
| const ch = guild.channels.cache.find(c => c.name === chName); |
| if (!ch) { |
| log.push(`β οΈ Channel **${chName}** not found β skipped`); |
| continue; |
| } |
|
|
| const overwrites = [ |
| { id: everyoneRole.id, deny: [PermissionFlagsBits.ViewChannel, PermissionFlagsBits.SendMessages] }, |
| ]; |
| if (verifiedRole) overwrites.push({ id: verifiedRole.id, allow: [PermissionFlagsBits.ViewChannel], deny: [PermissionFlagsBits.SendMessages, PermissionFlagsBits.AttachFiles] }); |
| if (boosterRole) overwrites.push({ id: boosterRole.id, allow: [PermissionFlagsBits.ViewChannel], deny: [PermissionFlagsBits.SendMessages, PermissionFlagsBits.AttachFiles] }); |
| if (staffRole) overwrites.push({ id: staffRole.id, allow: [PermissionFlagsBits.ViewChannel], deny: [PermissionFlagsBits.SendMessages, PermissionFlagsBits.AttachFiles] }); |
| if (ownerRole) overwrites.push({ id: ownerRole.id, allow: [PermissionFlagsBits.ViewChannel, PermissionFlagsBits.SendMessages, PermissionFlagsBits.AttachFiles] }); |
|
|
| await ch.permissionOverwrites.set(overwrites); |
| log.push(`π Locked **${chName}** β owner-only send`); |
| } |
|
|
| |
| const boosterRewards = guild.channels.cache.find(c => c.name === 'πγ»booster-rewards'); |
| if (boosterRewards) { |
| const overwrites = [ |
| { id: everyoneRole.id, deny: [PermissionFlagsBits.ViewChannel, PermissionFlagsBits.SendMessages] }, |
| ]; |
| if (boosterRole) overwrites.push({ id: boosterRole.id, allow: [PermissionFlagsBits.ViewChannel], deny: [PermissionFlagsBits.SendMessages, PermissionFlagsBits.AttachFiles] }); |
| if (staffRole) overwrites.push({ id: staffRole.id, allow: [PermissionFlagsBits.ViewChannel], deny: [PermissionFlagsBits.SendMessages, PermissionFlagsBits.AttachFiles] }); |
| if (ownerRole) overwrites.push({ id: ownerRole.id, allow: [PermissionFlagsBits.ViewChannel, PermissionFlagsBits.SendMessages, PermissionFlagsBits.AttachFiles] }); |
|
|
| await boosterRewards.permissionOverwrites.set(overwrites); |
| log.push(`π Locked **πγ»booster-rewards** β owner-only send`); |
| } else { |
| log.push(`β οΈ Channel **πγ»booster-rewards** not found β skipped`); |
| } |
|
|
| |
| await message.reply({ |
| embeds: [successEmbed('β
Updates Applied', log.join('\n'))], |
| }); |
| }, |
| }; |
|
|