Replaced `.single()` with `.maybeSingle()` in multiple command files to handle cases where no record is found, and added a new /pricing route and navigation links to the UI. Replit-Commit-Author: Agent Replit-Commit-Session-Id: aed2e46d-25bb-4b73-81a1-bb9e8437c261 Replit-Commit-Checkpoint-Type: intermediate_checkpoint Replit-Commit-Event-Id: e91d020a-35a6-4add-9945-887dd3ecae9f Replit-Commit-Screenshot-Url: https://storage.googleapis.com/screenshot-production-us-central1/3bdfff67-975a-46ad-9845-fbb6b4a4c4b5/aed2e46d-25bb-4b73-81a1-bb9e8437c261/tdDjujk Replit-Helium-Checkpoint-Created: true
100 lines
3.1 KiB
JavaScript
100 lines
3.1 KiB
JavaScript
const { SlashCommandBuilder, EmbedBuilder } = require("discord.js");
|
|
|
|
module.exports = {
|
|
data: new SlashCommandBuilder()
|
|
.setName("verify-role")
|
|
.setDescription("Check your AeThex-assigned Discord roles"),
|
|
|
|
async execute(interaction, supabase) {
|
|
if (!supabase) {
|
|
return interaction.reply({ content: "This feature requires Supabase to be configured.", ephemeral: true });
|
|
}
|
|
await interaction.deferReply({ ephemeral: true });
|
|
|
|
try {
|
|
const { data: link } = await supabase
|
|
.from("discord_links")
|
|
.select("user_id, primary_arm")
|
|
.eq("discord_id", interaction.user.id)
|
|
.maybeSingle();
|
|
|
|
if (!link) {
|
|
const embed = new EmbedBuilder()
|
|
.setColor(0xff6b6b)
|
|
.setTitle("❌ Not Linked")
|
|
.setDescription(
|
|
"You must link your Discord account to AeThex first.\nUse `/verify` to get started.",
|
|
);
|
|
|
|
return await interaction.editReply({ embeds: [embed] });
|
|
}
|
|
|
|
const { data: profile } = await supabase
|
|
.from("user_profiles")
|
|
.select("user_type")
|
|
.eq("id", link.user_id)
|
|
.maybeSingle();
|
|
|
|
const { data: mappings } = await supabase
|
|
.from("discord_role_mappings")
|
|
.select("discord_role")
|
|
.eq("arm", link.primary_arm)
|
|
.eq("user_type", profile?.user_type || "community_member");
|
|
|
|
const member = await interaction.guild.members.fetch(interaction.user.id);
|
|
const aethexRoles = member.roles.cache.filter(
|
|
(role) =>
|
|
role.name.includes("Labs") ||
|
|
role.name.includes("GameForge") ||
|
|
role.name.includes("Corp") ||
|
|
role.name.includes("Foundation") ||
|
|
role.name.includes("Dev-Link") ||
|
|
role.name.includes("Premium") ||
|
|
role.name.includes("Creator"),
|
|
);
|
|
|
|
const embed = new EmbedBuilder()
|
|
.setColor(0x7289da)
|
|
.setTitle("🔐 Your AeThex Roles")
|
|
.addFields(
|
|
{
|
|
name: "⚔️ Primary Realm",
|
|
value: link.primary_arm || "Not set",
|
|
inline: true,
|
|
},
|
|
{
|
|
name: "👤 User Type",
|
|
value: profile?.user_type || "community_member",
|
|
inline: true,
|
|
},
|
|
{
|
|
name: "🎭 Discord Roles",
|
|
value:
|
|
aethexRoles.size > 0
|
|
? aethexRoles.map((r) => r.name).join(", ")
|
|
: "None assigned yet",
|
|
},
|
|
{
|
|
name: "📋 Expected Roles",
|
|
value:
|
|
mappings?.length > 0
|
|
? mappings.map((m) => m.discord_role).join(", ")
|
|
: "No mappings found",
|
|
},
|
|
)
|
|
.setFooter({
|
|
text: "Roles are assigned automatically based on your AeThex profile",
|
|
});
|
|
|
|
await interaction.editReply({ embeds: [embed] });
|
|
} catch (error) {
|
|
console.error("Verify-role command error:", error);
|
|
const embed = new EmbedBuilder()
|
|
.setColor(0xff0000)
|
|
.setTitle("❌ Error")
|
|
.setDescription("Failed to verify roles. Please try again.");
|
|
|
|
await interaction.editReply({ embeds: [embed] });
|
|
}
|
|
},
|
|
};
|