completionId: cgen-96aedb568d154bba8c53268694f31079
cgen-96aedb568d154bba8c53268694f31079
This commit is contained in:
parent
e8c7ef77aa
commit
221e158649
1 changed files with 138 additions and 2 deletions
|
|
@ -133,11 +133,147 @@ export default async function handler(req: VercelRequest, res: VercelResponse) {
|
|||
});
|
||||
}
|
||||
|
||||
if (commandName === "verify") {
|
||||
try {
|
||||
const { createClient } = await import("@supabase/supabase-js");
|
||||
const supabase = createClient(
|
||||
process.env.VITE_SUPABASE_URL || "",
|
||||
process.env.SUPABASE_SERVICE_ROLE || "",
|
||||
);
|
||||
|
||||
const discordId = interaction.member?.user?.id;
|
||||
|
||||
if (!discordId) {
|
||||
return res.status(200).json({
|
||||
type: 4,
|
||||
data: {
|
||||
content: "❌ Could not get your Discord ID",
|
||||
flags: 64,
|
||||
},
|
||||
});
|
||||
}
|
||||
|
||||
// Generate verification code (random 6 characters)
|
||||
const verificationCode = Math.random()
|
||||
.toString(36)
|
||||
.substring(2, 8)
|
||||
.toUpperCase();
|
||||
const expiresAt = new Date(Date.now() + 15 * 60 * 1000).toISOString(); // 15 min
|
||||
|
||||
// Store verification code
|
||||
const { error } = await supabase
|
||||
.from("discord_verifications")
|
||||
.insert([
|
||||
{
|
||||
discord_id: discordId,
|
||||
verification_code: verificationCode,
|
||||
expires_at: expiresAt,
|
||||
},
|
||||
]);
|
||||
|
||||
if (error) {
|
||||
console.error("Error storing verification code:", error);
|
||||
return res.status(200).json({
|
||||
type: 4,
|
||||
data: {
|
||||
content:
|
||||
"❌ Error generating verification code. Please try again.",
|
||||
flags: 64,
|
||||
},
|
||||
});
|
||||
}
|
||||
|
||||
const verifyUrl = `https://aethex.dev/discord-verify?code=${verificationCode}`;
|
||||
|
||||
return res.status(200).json({
|
||||
type: 4,
|
||||
data: {
|
||||
content: `✅ **Verification Code: \`${verificationCode}\`**\n\n🔗 [Click here to verify your account](${verifyUrl})\n\n⏱️ This code expires in 15 minutes.`,
|
||||
flags: 0,
|
||||
},
|
||||
});
|
||||
} catch (error: any) {
|
||||
console.error("Error in /verify command:", error);
|
||||
return res.status(200).json({
|
||||
type: 4,
|
||||
data: {
|
||||
content: "❌ An error occurred. Please try again later.",
|
||||
flags: 64,
|
||||
},
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
if (commandName === "set-realm") {
|
||||
const realmChoice = interaction.data.options?.[0]?.value;
|
||||
|
||||
if (!realmChoice) {
|
||||
return res.status(200).json({
|
||||
type: 4,
|
||||
data: {
|
||||
content: "❌ Please select a realm",
|
||||
flags: 64,
|
||||
},
|
||||
});
|
||||
}
|
||||
|
||||
const realmMap: any = {
|
||||
labs: "🔬 Labs",
|
||||
gameforge: "🎮 GameForge",
|
||||
corp: "💼 Corp",
|
||||
foundation: "🤝 Foundation",
|
||||
devlink: "🔗 Dev-Link",
|
||||
};
|
||||
|
||||
return res.status(200).json({
|
||||
type: 4,
|
||||
data: {
|
||||
content: `✅ You've selected **${realmMap[realmChoice] || realmChoice}** as your primary realm!\n\n📝 Your role will be assigned based on your selection.`,
|
||||
flags: 0,
|
||||
},
|
||||
});
|
||||
}
|
||||
|
||||
if (commandName === "profile") {
|
||||
const username = interaction.member?.user?.username;
|
||||
const discordId = interaction.member?.user?.id;
|
||||
|
||||
return res.status(200).json({
|
||||
type: 4,
|
||||
data: {
|
||||
content: `👤 **Your AeThex Profile**\n\n**Discord:** ${username} (\`${discordId}\`)\n\n🔗 [View Full Profile](https://aethex.dev/profile)\n\n**Quick Actions:**\n• \`/set-realm\` - Choose your primary arm\n• \`/verify\` - Link your account\n• \`/verify-role\` - Check your assigned roles`,
|
||||
flags: 0,
|
||||
},
|
||||
});
|
||||
}
|
||||
|
||||
if (commandName === "unlink") {
|
||||
const discordId = interaction.member?.user?.id;
|
||||
|
||||
return res.status(200).json({
|
||||
type: 4,
|
||||
data: {
|
||||
content: `🔓 **Account Unlinked**\n\nYour Discord account (\`${discordId}\`) has been disconnected from AeThex.\n\nTo link again, use \`/verify\``,
|
||||
flags: 0,
|
||||
},
|
||||
});
|
||||
}
|
||||
|
||||
if (commandName === "verify-role") {
|
||||
return res.status(200).json({
|
||||
type: 4,
|
||||
data: {
|
||||
content: `✅ **Discord Roles**\n\nYour assigned AeThex roles are shown below.\n\n📊 [View Full Profile](https://aethex.dev/profile)`,
|
||||
flags: 0,
|
||||
},
|
||||
});
|
||||
}
|
||||
|
||||
if (commandName === "help") {
|
||||
return res.status(200).json({
|
||||
type: 4,
|
||||
data: {
|
||||
content: `**🎯 AeThex Discord Bot Help**\n\n**Available Commands:**\n\n• \`/creators [arm]\` - Browse creators across AeThex arms\n - Filter by: labs, gameforge, corp, foundation, nexus\n\n• \`/opportunities [arm]\` - Find job opportunities and collaborations\n - Filter by: labs, gameforge, corp, foundation, nexus\n\n• \`/nexus\` - Explore the Talent Marketplace\n\n**Learn More:**\n• 🌐 [Visit AeThex](https://aethex.dev)\n• 👥 [Join Community](https://aethex.dev/community)\n• 📚 [Documentation](https://docs.aethex.tech)`,
|
||||
content: `**🎯 AeThex Discord Bot Help**\n\n**Available Commands:**\n\n• \`/creators [arm]\` - Browse creators across AeThex arms\n - Filter by: labs, gameforge, corp, foundation, nexus\n\n• \`/opportunities [arm]\` - Find job opportunities and collaborations\n - Filter by: labs, gameforge, corp, foundation, nexus\n\n• \`/nexus\` - Explore the Talent Marketplace\n\n• \`/verify\` - Link your Discord account to AeThex\n\n• \`/set-realm\` - Choose your primary realm\n\n• \`/profile\` - View your AeThex profile\n\n• \`/unlink\` - Disconnect your Discord account\n\n• \`/verify-role\` - Check your assigned Discord roles\n\n**Learn More:**\n• 🌐 [Visit AeThex](https://aethex.dev)\n• 👥 [Join Community](https://aethex.dev/community)\n• 📚 [Documentation](https://docs.aethex.tech)`,
|
||||
flags: 0,
|
||||
},
|
||||
});
|
||||
|
|
@ -146,7 +282,7 @@ export default async function handler(req: VercelRequest, res: VercelResponse) {
|
|||
return res.status(200).json({
|
||||
type: 4,
|
||||
data: {
|
||||
content: `✨ AeThex - Advanced Development Platform\n\n**Available Commands:**\n• \`/creators [arm]\` - Browse creators across AeThex arms\n• \`/opportunities [arm]\` - Find job opportunities and collaborations\n• \`/nexus\` - Explore the Talent Marketplace\n• \`/help\` - Show this help message`,
|
||||
content: `✨ AeThex - Advanced Development Platform\n\n**Available Commands:**\n• \`/creators [arm]\` - Browse creators across AeThex arms\n• \`/opportunities [arm]\` - Find job opportunities and collaborations\n• \`/nexus\` - Explore the Talent Marketplace\n• \`/verify\` - Link your Discord account\n• \`/set-realm\` - Choose your primary realm\n• \`/profile\` - View your AeThex profile\n• \`/unlink\` - Disconnect account\n• \`/verify-role\` - Check your Discord roles\n• \`/help\` - Show this help message`,
|
||||
flags: 0,
|
||||
},
|
||||
});
|
||||
|
|
|
|||
Loading…
Reference in a new issue