78
index.js
78
index.js
@@ -164,6 +164,24 @@ client.on(Events.ClientReady, async readyClient => {
|
||||
]
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
name: 'join-channel',
|
||||
description: 'Make the bot access a specific Discord channel',
|
||||
options: [
|
||||
{
|
||||
name: 'channel-id',
|
||||
type: 3, // STRING type
|
||||
description: 'Discord channel ID (e.g., 768329192131526686)',
|
||||
required: false
|
||||
},
|
||||
{
|
||||
name: 'message',
|
||||
type: 3, // STRING type
|
||||
description: 'Message to send to the channel',
|
||||
required: false
|
||||
}
|
||||
]
|
||||
}
|
||||
];
|
||||
|
||||
@@ -1045,6 +1063,66 @@ client.on(Events.InteractionCreate, async interaction => {
|
||||
}
|
||||
break;
|
||||
|
||||
case 'join-channel':
|
||||
await interaction.deferReply({ ephemeral: true });
|
||||
const channelId = interaction.options.getString('channel-id') || '768329192131526686'; // Default to your channel
|
||||
const channelMessage = interaction.options.getString('message') || '🤖 ¡Hola! El bot ahora tiene acceso a este canal.';
|
||||
|
||||
try {
|
||||
// Try to fetch the channel by ID
|
||||
const targetChannel = await client.channels.fetch(channelId);
|
||||
|
||||
if (!targetChannel) {
|
||||
await interaction.editReply('❌ No se pudo encontrar el canal. Verifica que el ID sea correcto y que el bot tenga acceso al servidor.');
|
||||
return;
|
||||
}
|
||||
|
||||
if (!targetChannel.isTextBased()) {
|
||||
await interaction.editReply('❌ El canal especificado no es un canal de texto.');
|
||||
return;
|
||||
}
|
||||
|
||||
// Check if bot has permission to send messages in that channel
|
||||
if (!targetChannel.permissionsFor(client.user).has('SendMessages')) {
|
||||
await interaction.editReply('❌ El bot no tiene permisos para enviar mensajes en ese canal.');
|
||||
return;
|
||||
}
|
||||
|
||||
// Send message to the target channel
|
||||
const embed = new EmbedBuilder()
|
||||
.setTitle('🤖 Bot Conectado')
|
||||
.setDescription(channelMessage)
|
||||
.addFields(
|
||||
{ name: '📍 Canal', value: `${targetChannel.name} (${targetChannel.id})`, inline: true },
|
||||
{ name: '🏠 Servidor', value: targetChannel.guild.name, inline: true },
|
||||
{ name: '⏰ Conectado', value: `<t:${Math.floor(Date.now() / 1000)}:R>`, inline: true }
|
||||
)
|
||||
.setColor(0x00FF00)
|
||||
.setTimestamp()
|
||||
.setFooter({ text: 'Bot Discord Multimedia' });
|
||||
|
||||
await targetChannel.send({ embeds: [embed] });
|
||||
|
||||
await interaction.editReply(`✅ ¡Éxito! El bot ha accedido al canal **${targetChannel.name}** en el servidor **${targetChannel.guild.name}** y ha enviado un mensaje.`);
|
||||
|
||||
} catch (error) {
|
||||
console.error('Error accessing channel:', error);
|
||||
let errorMessage = '❌ Error al acceder al canal: ';
|
||||
|
||||
if (error.code === 10003) {
|
||||
errorMessage += 'Canal no encontrado. Verifica que el ID sea correcto.';
|
||||
} else if (error.code === 50001) {
|
||||
errorMessage += 'El bot no tiene acceso a este canal o servidor.';
|
||||
} else if (error.code === 50013) {
|
||||
errorMessage += 'El bot no tiene permisos suficientes.';
|
||||
} else {
|
||||
errorMessage += error.message;
|
||||
}
|
||||
|
||||
await interaction.editReply(errorMessage);
|
||||
}
|
||||
break;
|
||||
|
||||
case 'btc-monitor':
|
||||
const action = interaction.options.getString('action');
|
||||
const channel = interaction.options.getChannel('channel');
|
||||
|
||||
Referencia en una nueva incidencia
Block a user