Untitled
unknown
plain_text
6 days ago
8.9 kB
24
No Index
const { Client, GatewayIntentBits, EmbedBuilder, ActionRowBuilder, ButtonBuilder, ButtonStyle } = require('discord.js'); const axios = require('axios'); const client = new Client({ intents: [ GatewayIntentBits.Guilds, GatewayIntentBits.GuildMessages, GatewayIntentBits.MessageContent ] }); const CONFIG = { TOKEN: '', CHANNEL_ID: '', RAGEMP_ENDPOINT: 'http://localhost:3000/link/' }; client.once('ready', () => { console.log(`Bot aktif: ${client.user.tag}`); console.log(`Dinlenen kanal: ${CONFIG.CHANNEL_ID}`); console.log(`RageMP endpoint: ${CONFIG.RAGEMP_ENDPOINT}`); }); client.on('messageCreate', async (message) => { if (message.author.bot || message.channel.id !== CONFIG.CHANNEL_ID) return; const content = message.content.trim().toUpperCase(); try { await message.delete(); } catch (error) { console.log('Mesaj silinemedi:', error.message); } if (content.match(/^LSNRP\d{6}$/)) { const authCode = content; const discordId = message.author.id; const discordUsername = message.author.username; let dmChannel; try { dmChannel = await message.author.createDM(); const loadingEmbed = new EmbedBuilder() .setColor('#FFFF00') .setTitle('İşleniyor...') .setDescription('Auth kodu kontrol ediliyor, lütfen bekleyin...') .setTimestamp(); const loadingMessage = await dmChannel.send({ embeds: [loadingEmbed] }); setTimeout(async () => { try { const response = await axios.post(CONFIG.RAGEMP_ENDPOINT, `code=${authCode}&discordId=${discordId}`, { headers: { 'Content-Type': 'application/x-www-form-urlencoded' }, timeout: 10000 } ); if (response.data.success) { const successEmbed = new EmbedBuilder() .setColor('#00FF00') .setTitle('Hesap Bağlantısı Başarılı!') .setDescription(`**${response.data.playerName}** oyuncu hesabınız Discord hesabınızla başarıyla bağlandı!`) .addFields( { name: 'Oyuncu Adı', value: response.data.playerName, inline: true }, { name: 'Discord', value: `<@${discordId}>`, inline: true }, { name: 'Auth Kodu', value: authCode, inline: true } ) .setFooter({ text: 'LSNRP - Discord Auth System' }) .setTimestamp(); await loadingMessage.edit({ embeds: [successEmbed] }); console.log(`Başarılı bağlantı: ${discordUsername} (${discordId}) -> ${response.data.playerName}`); } else { const errorEmbed = new EmbedBuilder() .setColor('#FF0000') .setTitle('Geçersiz Auth Kodu!') .setDescription('Girdiğiniz auth kodu geçersiz veya süresi dolmuş.') .addFields( { name: 'Girilen Kod', value: authCode, inline: true }, { name: 'Ne yapmalıyım?', value: 'Oyunda `/discord` komutu ile yeni bir kod alın.', inline: false } ) .setFooter({ text: 'LSNRP - Discord Auth System' }) .setTimestamp(); await loadingMessage.edit({ embeds: [errorEmbed] }); console.log(`Geçersiz kod: ${discordUsername} (${discordId}) -> ${authCode}`); } } catch (error) { const connectionErrorEmbed = new EmbedBuilder() .setColor('#FF6B6B') .setTitle('Bağlantı Hatası!') .setDescription('Sunucuya bağlanırken bir hata oluştu. Lütfen daha sonra tekrar deneyin.') .addFields( { name: 'Auth Kodu', value: authCode, inline: true }, { name: 'Durum', value: 'Sunucu geçici olarak erişilemez durumda', inline: false } ) .setFooter({ text: 'LSNRP - Sorun devam ederse yöneticilere başvurun.' }) .setTimestamp(); await loadingMessage.edit({ embeds: [connectionErrorEmbed] }); console.error(`Bağlantı hatası: ${error.message}`); } }, 1000); } catch (dmError) { console.log('DM gönderilemedi:', dmError.message); const dmErrorEmbed = new EmbedBuilder() .setColor('#FFA500') .setTitle('DM Kapalı!') .setDescription(`<@${discordId}> DM'leriniz kapalı! Lütfen DM'lerinizi açın ve tekrar deneyin.`) .setFooter({ text: 'Bu mesaj 10 saniye sonra silinecek.' }) .setTimestamp(); const dmErrorMessage = await message.channel.send({ embeds: [dmErrorEmbed] }); setTimeout(async () => { try { await dmErrorMessage.delete(); } catch (deleteError) { console.log('DM hata mesajı silinemedi:', deleteError.message); } }, 10000); } } else if (content.startsWith('LSNRP') && content.length !== 11) { try { const dmChannel = await message.author.createDM(); const formatErrorEmbed = new EmbedBuilder() .setColor('#FFA500') .setTitle('Yanlış Format!') .setDescription('Auth kodu formatı: **LSNRP** + **6 haneli sayı**') .addFields( { name: 'Yazdığınız', value: content, inline: true }, { name: 'Doğru Format', value: 'LSNRP123456', inline: true }, { name: 'Nasıl alırım?', value: 'Oyunda `/discord` komutunu kullanın.', inline: false } ) .setFooter({ text: 'LSNRP - Discord Auth System' }) .setTimestamp(); await dmChannel.send({ embeds: [formatErrorEmbed] }); } catch (dmError) { console.log('Format hatası DM gönderilemedi:', dmError.message); const formatErrorEmbed = new EmbedBuilder() .setColor('#FFA500') .setTitle('Yanlış Format!') .setDescription(`<@${message.author.id}> Auth kodu formatı yanlış! DM'lerinizi açın.`) .addFields( { name: 'Doğru Format', value: 'LSNRP123456', inline: true } ) .setFooter({ text: 'Bu mesaj 8 saniye sonra silinecek.' }) .setTimestamp(); const formatErrorMessage = await message.channel.send({ embeds: [formatErrorEmbed] }); setTimeout(async () => { try { await formatErrorMessage.delete(); } catch (deleteError) { console.log('Format hata mesajı silinemedi:', deleteError.message); } }, 8000); } } else { console.log(`Rastgele mesaj silindi: ${message.author.username} -> "${message.content}"`); } }); client.on('interactionCreate', async (interaction) => { if (!interaction.isChatInputCommand()) return; if (interaction.commandName === 'authinfo') { const infoEmbed = new EmbedBuilder() .setColor('#0099FF') .setTitle('🔗 LSNRP Discord Auth Sistemi') .setDescription('Discord hesabınızı oyun hesabınızla bağlamak için:') .addFields( { name: '1 Adım', value: 'Oyunda `/discord` komutunu kullanın', inline: false }, { name: '2 Adım', value: 'Size verilen LSNRP kodunu bu kanala yazın', inline: false }, { name: '3 Adım', value: 'Sistem otomatik olarak hesaplarınızı bağlayacak', inline: false }, { name: 'Format', value: '`LSNRP123456` (LSNRP + 6 haneli sayı)', inline: false } ) .setFooter({ text: 'LSNRP - Discord Auth System' }) .setTimestamp(); await interaction.reply({ embeds: [infoEmbed], ephemeral: true }); } }); client.on('error', error => { console.error('Discord client hatası:', error); }); process.on('unhandledRejection', error => { console.error('Yakalanmamış hata:', error); }); client.login(CONFIG.TOKEN);
Editor is loading...
Leave a Comment