Files
bot.js
config.json
gpuClassifier.js
package.json
Code
4 702
bot.js
const { Client, GatewayIntentBits, EmbedBuilder } = require('discord.js');
const { classifyGPU, getOptimizationRecommendations } = require('./gpuClassifier');
require('dotenv').config();
const client = new Client({
intents: [
GatewayIntentBits.Guilds,
GatewayIntentBits.GuildMessages,
GatewayIntentBits.MessageContent
]
});
client.once('ready', () => {
console.log(`✅ Bot is ready! Logged in as ${client.user.tag}`);
console.log(`📊 Serving ${client.guilds.cache.size} server(s)`);
});
client.on('messageCreate', async (message) => {
if (message.author.bot) return;
const content = message.content.trim();
if (content.startsWith('!gpu')) {
const gpuInput = content.slice(4).trim();
if (!gpuInput) {
const helpEmbed = new EmbedBuilder()
.setColor('#5865F2')
.setTitle('🎮 GPU Advisor Bot - Help')
.setDescription('Get gaming optimization recommendations based on your GPU!')
.addFields(
{
name: '📝 Usage',
value: '`!gpu <your GPU info>`'
},
{
name: '✅ Accepted Input Formats',
value: '**Exact Model:**\n• `!gpu GTX 1650`\n• `!gpu RTX 3060`\n• `!gpu Intel UHD 620`\n\n**GPU Family:**\n• `!gpu Intel graphics`\n• `!gpu Radeon graphics`\n• `!gpu NVIDIA 2GB`\n\n**VRAM Only:**\n• `!gpu 2GB`\n• `!gpu 512MB`\n• `!gpu 4GB`'
},
{
name: '💡 Examples',
value: '`!gpu RTX 3070`\n`!gpu Intel UHD`\n`!gpu 1GB`'
}
)
.setFooter({ text: 'Tip: More specific GPU info = better recommendations!' })
.setTimestamp();
return message.reply({ embeds: [helpEmbed] });
}
try {
const classification = classifyGPU(gpuInput);
const recommendations = getOptimizationRecommendations(classification);
const tierColors = {
'Very Low': '#FF0000',
'Low': '#FF6B00',
'Medium': '#FFD700',
'High': '#00FF00',
'Very High': '#00FFFF',
'Ultra': '#FF00FF'
};
const resultEmbed = new EmbedBuilder()
.setColor(tierColors[classification.tier] || '#5865F2')
.setTitle('🎮 GPU Analysis Results')
.setDescription(`**Detected GPU:** ${classification.detectedName}`)
.addFields(
{
name: '📊 Performance Tier',
value: `**${classification.tier}**`,
inline: true
},
{
name: '🎯 GPU Type',
value: classification.type,
inline: true
},
{
name: '💾 VRAM Info',
value: classification.vramInfo || 'Not specified',
inline: true
},
{
name: '🎨 Graphics Settings',
value: recommendations.graphicsSettings
},
{
name: '🖥️ Resolution Recommendations',
value: recommendations.resolution
},
{
name: '🎯 Game Recommendations',
value: recommendations.gameRecommendations
},
{
name: '⚙️ Optimization Tips',
value: recommendations.optimizationTips
}
)
.setFooter({ text: classification.confidence })
.setTimestamp();
await message.reply({ embeds: [resultEmbed] });
console.log(`✅ Processed GPU request: "${gpuInput}" -> ${classification.tier}`);
} catch (error) {
console.error('Error processing GPU request:', error);
const errorEmbed = new EmbedBuilder()
.setColor('#FF0000')
.setTitle('❌ Error')
.setDescription('Sorry, I encountered an error processing your request. Please try again with a different format.')
.addFields(
{
name: 'Examples',
value: '`!gpu GTX 1650`\n`!gpu Intel UHD`\n`!gpu 2GB`'
}
)
.setTimestamp();
await message.reply({ embeds: [errorEmbed] });
}
}
if (content === '!ping') {
const ping = Date.now() - message.createdTimestamp;
await message.reply(`🏓 Pong! Latency: ${ping}ms`);
}
});
client.on('error', error => {
console.error('Discord client error:', error);
});
process.on('unhandledRejection', error => {
console.error('Unhandled promise rejection:', error);
});
client.login(process.env.DISCORD_TOKEN);