AeThex-Bot-Master/aethex-bot/commands/unlink.js
sirpiglr b178664f99 Make Supabase features optional and integrate new security systems
Updates bot.js to make Supabase integration optional, adds Sentinel security listeners, and modifies several commands to handle missing Supabase configurations gracefully. Also updates package.json and replit.md for new dependencies and features.

Replit-Commit-Author: Agent
Replit-Commit-Session-Id: aed2e46d-25bb-4b73-81a1-bb9e8437c261
Replit-Commit-Checkpoint-Type: intermediate_checkpoint
Replit-Commit-Event-Id: 0d645005-4840-49ef-9446-2c62d2bb7eed
Replit-Commit-Screenshot-Url: https://storage.googleapis.com/screenshot-production-us-central1/3bdfff67-975a-46ad-9845-fbb6b4a4c4b5/aed2e46d-25bb-4b73-81a1-bb9e8437c261/Wmps8l5
Replit-Helium-Checkpoint-Created: true
2025-12-07 23:41:11 +00:00

78 lines
2.4 KiB
JavaScript
Raw Blame History

This file contains invisible Unicode characters

This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

const { SlashCommandBuilder, EmbedBuilder } = require("discord.js");
module.exports = {
data: new SlashCommandBuilder()
.setName("unlink")
.setDescription("Unlink your Discord account from AeThex"),
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("*")
.eq("discord_id", interaction.user.id)
.single();
if (!link) {
const embed = new EmbedBuilder()
.setColor(0xff6b6b)
.setTitle(" Not Linked")
.setDescription("Your Discord account is not linked to AeThex.");
return await interaction.editReply({ embeds: [embed] });
}
// Delete the link
await supabase
.from("discord_links")
.delete()
.eq("discord_id", interaction.user.id);
// Remove Discord roles from user
const guild = interaction.guild;
const member = await guild.members.fetch(interaction.user.id);
// Find and remove all AeThex-related roles
const rolesToRemove = 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"),
);
for (const [, role] of rolesToRemove) {
try {
await member.roles.remove(role);
} catch (e) {
console.warn(`Could not remove role ${role.name}`);
}
}
const embed = new EmbedBuilder()
.setColor(0x00ff00)
.setTitle("✅ Account Unlinked")
.setDescription(
"Your Discord account has been unlinked from AeThex.\nAll associated roles have been removed.",
);
await interaction.editReply({ embeds: [embed] });
} catch (error) {
console.error("Unlink command error:", error);
const embed = new EmbedBuilder()
.setColor(0xff0000)
.setTitle("❌ Error")
.setDescription("Failed to unlink account. Please try again.");
await interaction.editReply({ embeds: [embed] });
}
},
};