Signed-off-by: ale <ale@manalejandro.com>
Este commit está contenido en:
ale
2025-07-20 12:08:38 +02:00
padre 752d5d3f6d
commit 99b1b147cf
Se han modificado 2 ficheros con 94 adiciones y 0 borrados

Ver fichero

@@ -10,6 +10,7 @@ A powerful Discord bot that can send messages and search for multimedia files on
- 📈 **Google Trends** - Show current trending topics by country with grouped articles
- ⬇️ **File Download** - Download and share multimedia files directly in Discord
- 🟠 **Bitcoin Monitor** - Real-time Bitcoin transaction monitoring
- 🚪 **Channel Access** - Join and send messages to specific Discord channels by ID
## Installation
@@ -93,6 +94,21 @@ Downloads and shares multimedia files directly in Discord.
- Automatically cleans up temporary files
- Shows file information in rich embeds
### 🚪 Join Channel
```
/join-channel channel-id:768329192131526686 message:Hello from bot!
```
Makes the bot access and send a message to a specific Discord channel.
- `channel-id`: Discord channel ID (optional, defaults to your specified channel)
- `message`: Custom message to send (optional)
**Join Channel Features:**
- Access channels by ID across different servers
- Automatic permission checking
- Rich embed with connection information
- Error handling for invalid channels or permissions
- Supports any text-based Discord channel
## Security Features
- ✅ Environment variables for token security

Ver fichero

@@ -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');