| const { PermissionFlagsBits } = require('discord.js'); |
| const { createEmbed } = require('../utils/embeds'); |
| const { Colors } = require('../config'); |
|
|
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| module.exports = { |
| async execute(client, message) { |
| const guild = client.guilds.cache.first(); |
| if (!guild) return message.reply({ content: 'β No guild found.' }); |
|
|
| const statusMsg = await message.reply({ |
| embeds: [createEmbed({ |
| title: 'π§ Creating Co-Owner Role', |
| description: 'Setting up limited management role...', |
| color: Colors.INFO |
| })] |
| }); |
|
|
| try { |
| |
| const existing = guild.roles.cache.find(r => r.name === 'π Co-Owner'); |
| if (existing) { |
| return statusMsg.edit({ |
| embeds: [createEmbed({ |
| title: 'β οΈ Role Already Exists', |
| description: `The role ${existing} already exists. Delete it manually first if you want to recreate it.`, |
| color: Colors.WARNING |
| })] |
| }); |
| } |
|
|
| |
| const ownerRole = guild.roles.cache.find(r => r.name === '@@ Owner'); |
| const position = ownerRole ? ownerRole.position - 1 : guild.roles.cache.size - 2; |
|
|
| |
| const coOwnerRole = await guild.roles.create({ |
| name: 'π Co-Owner', |
| color: '#e74c3c', |
| hoist: true, |
| mentionable: false, |
| permissions: [ |
| |
| PermissionFlagsBits.ManageGuild, |
| PermissionFlagsBits.ManageChannels, |
| PermissionFlagsBits.ManageEmojisAndStickers, |
| PermissionFlagsBits.ManageWebhooks, |
|
|
| |
| PermissionFlagsBits.ManageMessages, |
| PermissionFlagsBits.ManageNicknames, |
| PermissionFlagsBits.ManageEvents, |
|
|
| |
| PermissionFlagsBits.MuteMembers, |
| PermissionFlagsBits.DeafenMembers, |
| PermissionFlagsBits.MoveMembers, |
|
|
| |
| PermissionFlagsBits.ViewChannel, |
| PermissionFlagsBits.SendMessages, |
| PermissionFlagsBits.EmbedLinks, |
| PermissionFlagsBits.AttachFiles, |
| PermissionFlagsBits.AddReactions, |
| PermissionFlagsBits.UseExternalEmojis, |
| PermissionFlagsBits.ViewAuditLog, |
| PermissionFlagsBits.ReadMessageHistory, |
|
|
| |
| PermissionFlagsBits.Connect, |
| PermissionFlagsBits.Speak, |
|
|
| |
| ], |
| reason: 'Co-Owner role created via coownerrole command' |
| }); |
|
|
| |
| await coOwnerRole.setPosition(position).catch(() => { }); |
|
|
| |
| const announcementChannel = guild.channels.cache.find( |
| c => c.name.toLowerCase().includes('announcement') || c.name.toLowerCase().includes('π’') |
| ); |
|
|
| let announcementNote = ''; |
|
|
| |
| const ticketChannels = guild.channels.cache.filter( |
| c => c.name.toLowerCase().includes('ticket') || |
| c.name.toLowerCase().includes('π«') |
| ); |
|
|
| let ticketCount = 0; |
| for (const [, ch] of ticketChannels) { |
| await ch.permissionOverwrites.edit(coOwnerRole, { |
| ViewChannel: false, |
| SendMessages: false, |
| }).catch(() => { }); |
| ticketCount++; |
| } |
|
|
| if (ticketCount > 0) { |
| announcementNote += `\nπ **Blocked from ${ticketCount} ticket channel(s)**`; |
| } |
|
|
| await statusMsg.edit({ |
| embeds: [createEmbed({ |
| title: 'β
Co-Owner Role Created!', |
| description: [ |
| `**Role:** ${coOwnerRole}`, |
| `**Position:** Below Owner`, |
| `**Color:** Red (#e74c3c)`, |
| '', |
| '**β
CAN:**', |
| '> Send messages in all channels', |
| '> Manage server, channels, emojis', |
| '> Manage messages, nicknames, events', |
| '> Mute/deafen/move in voice', |
| '> View audit log', |
| '', |
| '**β CANNOT:**', |
| '> Assign/manage roles', |
| '> Ban or kick members', |
| '> Access ticket channels', |
| '> Use Administrator', |
| '> Override Owner permissions', |
| '', |
| announcementNote, |
| '', |
| '> Assign this role to your co-owner manually.', |
| ].join('\n'), |
| color: Colors.SUCCESS |
| })] |
| }); |
|
|
| } catch (err) { |
| console.error('[CoOwnerRole Error]', err); |
| await statusMsg.edit({ |
| embeds: [createEmbed({ |
| title: 'β Failed', |
| description: `Error: ${err.message}`, |
| color: Colors.ACCENT |
| })] |
| }); |
| } |
| } |
| }; |
|
|