forked from Xeio/IdleCodeRedeemer
-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathsetup.ts
More file actions
69 lines (62 loc) · 2.32 KB
/
setup.ts
File metadata and controls
69 lines (62 loc) · 2.32 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
import {
SlashCommandBuilder,
ChatInputCommandInteraction,
EmbedBuilder,
MessageFlags,
} from 'discord.js';
import { userManager } from '../database/userManager';
import { auditManager } from '../database/auditManager';
export const data = new SlashCommandBuilder()
.setName('setup')
.setDescription('Save your Idle Champions credentials securely')
.addStringOption((option) =>
option.setName('user_id').setDescription('Your Idle Champions User ID').setRequired(true)
)
.addStringOption((option) =>
option.setName('user_hash').setDescription('Your Idle Champions User Hash').setRequired(true)
);
export async function execute(interaction: ChatInputCommandInteraction) {
try {
console.log('[SETUP] Deferring reply...');
await interaction.deferReply({ flags: MessageFlags.Ephemeral });
console.log('[SETUP] Reply deferred');
const userId = interaction.options.getString('user_id', true);
const userHash = interaction.options.getString('user_hash', true);
console.log('[SETUP] Got credentials from options:', { userId, userHash });
// Save credentials
console.log('[SETUP] Saving credentials...');
await userManager.saveCredentials({
discordId: interaction.user.id,
userId,
userHash,
});
console.log('[SETUP] Credentials saved');
// Log action
await auditManager.logAction(interaction.user.id, 'USER_SETUP', { userId });
const embed = new EmbedBuilder()
.setColor(0x00ff00)
.setTitle('✅ Credentials Saved')
.setDescription('Your Idle Champions credentials have been saved securely.')
.addFields(
{
name: 'User ID',
value: userId.substring(0, 4) + '***' + userId.substring(userId.length - 4),
inline: true,
},
{
name: 'Hash',
value: userHash.substring(0, 4) + '***' + userHash.substring(userHash.length - 4),
inline: true,
}
)
.setFooter({ text: 'Your credentials are stored securely in our database.' });
console.log('[SETUP] Sending reply...');
await interaction.editReply({ embeds: [embed] });
console.log('[SETUP] Reply sent');
} catch (error) {
console.error('[SETUP COMMAND] Error:', error);
await interaction.editReply({
content: '❌ An error occurred while saving your credentials.',
});
}
}