Brozy123 commited on
Commit
da554af
·
verified ·
1 Parent(s): 9267975

Update index.js

Browse files
Files changed (1) hide show
  1. index.js +21 -29
index.js CHANGED
@@ -6,6 +6,7 @@ const networkFix = require('./network_fix');
6
  const server = require('./server');
7
  const { UI } = require('./NewBotStyle');
8
  const { createLineupAttachment } = require('./lineupRenderer');
 
9
 
10
  // Apply network fixes early
11
  networkFix.applyAdvancedFixes();
@@ -70,6 +71,7 @@ const commandsData = [
70
  { name: 'lineupimage', description: 'Generate a high-quality visual representation of the lineup' },
71
  { name: 'sendlink', description: 'Send a match link publicly', options: [{ name: 'link', type: 3, description: 'The link to send', required: true }] },
72
  { name: 'profile', description: 'Generate a custom profile card', options: [{ name: 'user', type: 6, description: 'The user to check', required: false }] },
 
73
  { name: 'giverole', description: 'Give a role to members (Admin)', options: [{ name: 'role', type: 8, description: 'The role', required: true }] },
74
  { name: 'uptime', description: 'Show how long the bot has been online' },
75
  { name: 'motm', description: 'Award Man of the Match to a player', options: [{ name: 'player', type: 6, description: 'The player to award', required: true }] }
@@ -188,7 +190,7 @@ client.on('messageCreate', async (message) => {
188
  const args = message.content.slice(prefix.length).trim().split(/ +/);
189
  const commandName = args.shift().toLowerCase();
190
 
191
- const allCommands = [...commandsData.map(c => c.name), 'sync', 'sync_cmds', 'reboot', 'grantservers', 'servers', 'help', 'motm'];
192
  if (allCommands.includes(commandName)) {
193
  logTransaction(client, commandName, message.author, message.guild, message.member);
194
  }
@@ -457,22 +459,17 @@ client.on('messageCreate', async (message) => {
457
  }
458
  }
459
 
460
- if (commandName === 'profile') {
461
  const target = message.mentions.users.first() || message.author;
462
  const stats = storage.data.stats[target.id] || { matches: 0, goals: 0, mvps: 0 };
463
-
464
- const embed = new EmbedBuilder()
465
- .setTitle(`🎴 PLAYER PROFILE — ${target.username.toUpperCase()}`)
466
- .setThumbnail(target.displayAvatarURL({ dynamic: true }))
467
- .addFields(
468
- { name: '🏟️ Matches', value: `\`${stats.matches || 0}\``, inline: true },
469
- { name: '⚽ Goals', value: `\`${stats.goals || 0}\``, inline: true },
470
- { name: '🌟 MOTM Awards', value: `\`${stats.mvps || 0}\``, inline: true }
471
- )
472
- .setColor(UI.colors.primary)
473
- .setFooter({ text: 'FriendlyBot Pro Stats' });
474
-
475
- await message.reply({ embeds: [embed] });
476
  }
477
 
478
  if (commandName === 'giverole') {
@@ -726,22 +723,17 @@ client.on('interactionCreate', async (interaction) => {
726
  }
727
  }
728
 
729
- if (interaction.commandName === 'profile') {
 
730
  const target = interaction.options.getUser('user') || interaction.user;
731
  const stats = storage.data.stats[target.id] || { matches: 0, goals: 0, mvps: 0 };
732
-
733
- const embed = new EmbedBuilder()
734
- .setTitle(`🎴 PLAYER PROFILE — ${target.username.toUpperCase()}`)
735
- .setThumbnail(target.displayAvatarURL({ dynamic: true }))
736
- .addFields(
737
- { name: '🏟️ Matches', value: `\`${stats.matches || 0}\``, inline: true },
738
- { name: '⚽ Goals', value: `\`${stats.goals || 0}\``, inline: true },
739
- { name: '🌟 MOTM Awards', value: `\`${stats.mvps || 0}\``, inline: true }
740
- )
741
- .setColor(UI.colors.primary)
742
- .setFooter({ text: 'FriendlyBot Pro Stats' });
743
-
744
- await interaction.reply({ embeds: [embed] });
745
  }
746
 
747
  if (interaction.commandName === 'giverole') {
 
6
  const server = require('./server');
7
  const { UI } = require('./NewBotStyle');
8
  const { createLineupAttachment } = require('./lineupRenderer');
9
+ const { createProfileAttachment } = require('./profileRenderer');
10
 
11
  // Apply network fixes early
12
  networkFix.applyAdvancedFixes();
 
71
  { name: 'lineupimage', description: 'Generate a high-quality visual representation of the lineup' },
72
  { name: 'sendlink', description: 'Send a match link publicly', options: [{ name: 'link', type: 3, description: 'The link to send', required: true }] },
73
  { name: 'profile', description: 'Generate a custom profile card', options: [{ name: 'user', type: 6, description: 'The user to check', required: false }] },
74
+ { name: 'profileimage', description: 'Generate a high-quality visual profile card', options: [{ name: 'user', type: 6, description: 'The user to check', required: false }] },
75
  { name: 'giverole', description: 'Give a role to members (Admin)', options: [{ name: 'role', type: 8, description: 'The role', required: true }] },
76
  { name: 'uptime', description: 'Show how long the bot has been online' },
77
  { name: 'motm', description: 'Award Man of the Match to a player', options: [{ name: 'player', type: 6, description: 'The player to award', required: true }] }
 
190
  const args = message.content.slice(prefix.length).trim().split(/ +/);
191
  const commandName = args.shift().toLowerCase();
192
 
193
+ const allCommands = [...commandsData.map(c => c.name), 'sync', 'sync_cmds', 'reboot', 'grantservers', 'servers', 'help', 'motm', 'profileimage'];
194
  if (allCommands.includes(commandName)) {
195
  logTransaction(client, commandName, message.author, message.guild, message.member);
196
  }
 
459
  }
460
  }
461
 
462
+ if (commandName === 'profileimage') {
463
  const target = message.mentions.users.first() || message.author;
464
  const stats = storage.data.stats[target.id] || { matches: 0, goals: 0, mvps: 0 };
465
+ const waitMsg = await message.reply('⏳ **Generating profile card...**');
466
+ try {
467
+ const attachment = await createProfileAttachment(target, stats);
468
+ await waitMsg.edit({ content: null, files: [attachment] });
469
+ } catch (e) {
470
+ console.error('Profile image error:', e);
471
+ await waitMsg.edit('❌ Failed to generate profile image.');
472
+ }
 
 
 
 
 
473
  }
474
 
475
  if (commandName === 'giverole') {
 
723
  }
724
  }
725
 
726
+ if (interaction.commandName === 'profileimage') {
727
+ await interaction.deferReply();
728
  const target = interaction.options.getUser('user') || interaction.user;
729
  const stats = storage.data.stats[target.id] || { matches: 0, goals: 0, mvps: 0 };
730
+ try {
731
+ const attachment = await createProfileAttachment(target, stats);
732
+ await interaction.editReply({ files: [attachment] });
733
+ } catch (e) {
734
+ console.error('Profile image error:', e);
735
+ await interaction.editReply('❌ Failed to generate profile image.');
736
+ }
 
 
 
 
 
 
737
  }
738
 
739
  if (interaction.commandName === 'giverole') {